Raised This Month: $ Target: $400
 0% 

Jumping Out of Water


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mlk27
Veteran Member
Join Date: May 2008
Old 01-09-2009 , 22:43   Jumping Out of Water
Reply With Quote #1

I can't find exisiting codes for this one. Can someone please show me how to code this.

when you're in water, point your crosshair to the surface of water and do a ctrl+jump, you'll speedly jump out of water (like a dolphin) and land on ground.

thanks

+karma
Mlk27 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-09-2009 , 23:40   Re: Jumping Out of Water
Reply With Quote #2

Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta> // the speed player will travel towards surface #define JUMP_SPEED 1000.0 // maximum distance player can be from the surface for the jump to work #define REQUIRED_SURFACE_DISTANCE 100.0 // the amount of time player should be finished with the jump // speed = distance / time, speed * time = distance, time = distance / time #define FINISH_TIME (REQUIRED_SURFACE_DISTANCE / JUMP_SPEED) // the delay between jump uses // the delay MUST include the "FINISH_TIME" #define #define JUMP_DELAY (FINISH_TIME + 5.0) new bool:g_alive[33]; new bool:g_jumping[33]; new Float:g_jump_wait[33]; public plugin_init() {     register_plugin("Dolphin Jumping", "0.1", "Exolent");         register_event("ResetHUD", "EventResetHud", "be");     register_event("DeathMsg", "EventDeathMsg", "a");         register_forward(FM_CmdStart, "FwdCmdStart");     register_forward(FM_PlayerPreThink, "FwdPlayerPreThink"); } public client_disconnect(client) {     g_alive[client] = false;     g_jumping[client] = false;     g_jump_wait[client] = 0.0; } public EventResetHud(client) {     g_alive[client] = bool:is_user_alive(client); } public EventDeathMsg() {     new client = read_data(2);         g_alive[client] = false;     g_jumping[client] = false;     g_jump_wait[client] = 0.0; } public FwdCmdStart(client, uc_handle, seed) {     if( !g_alive[client] || g_jumping[client] || pev(client, pev_waterlevel) != 3 ) return;         new button = get_uc(uc_handle, UC_Buttons);     new oldbuttons = pev(client, pev_oldbuttons);         if( !((button & IN_DUCK) && (oldbuttons & IN_DUCK)     && (button & IN_JUMP) && !(oldbuttons & IN_JUMP)) ) return;         new Float:gametime = get_gametime();     if( gametime < g_jump_wait[client] ) return;         static Float:origin[3], Float:maxs[3];     pev(client, pev_origin, origin);     pev(client, pev_maxs, maxs);         origin[2] += REQUIRED_SURFACE_DISTANCE - maxs[2];         if( engfunc(EngFunc_PointContents, origin) != CONTENTS_EMPTY )     {         // punish player for trying from too deep by waiting 1 second before trying again?         // comment the line below to remove this feature         g_jump_wait[client] = gametime + 1.0;                 return;     }         g_jumping[client] = true;     g_jump_wait[client] = gametime + JUMP_DELAY; } public FwdPlayerPreThink(client) {     if( !g_jumping[client] ) return;         if( get_gametime() >= g_jump_wait[client] )     {         g_jumping[client] = false;         g_jump_wait[client] = 0.0;                 return;     }         static Float:origin[3];     pev(client, pev_origin, origin);         static Float:maxs[3];     pev(client, pev_maxs, maxs);     origin[2] -= maxs[2];         if( engfunc(EngFunc_PointContents, origin) == CONTENTS_WATER )     {         // feet are touching water, so keep flying         set_pev(client, pev_movetype, MOVETYPE_FLY);     }         origin[2] += (maxs[2] * 2.0);         if( engfunc(EngFunc_PointContents, origin) == CONTENTS_WATER )     {         // head is still underwater, so keep the speed                 static Float:velocity[3];         velocity[2] = JUMP_SPEED;         set_pev(client, pev_velocity, velocity);     } }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 01-10-2009 at 00:18.
Exolent[jNr] is offline
Mlk27
Veteran Member
Join Date: May 2008
Old 01-10-2009 , 00:17   Re: Jumping Out of Water
Reply With Quote #3

line #69 compile error

pev(client, pev_origin, start); -> origin?
Mlk27 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-10-2009 , 00:19   Re: Jumping Out of Water
Reply With Quote #4

Sorry about that. I coded about 3 versions before I posted it. It should be fixed now.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Mlk27
Veteran Member
Join Date: May 2008
Old 01-10-2009 , 01:25   Re: Jumping Out of Water
Reply With Quote #5

i've just tested it out in map zm_ice_attack. it's half working..some it doesnt work at all..thanks for trying though
Mlk27 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-10-2009 , 03:18   Re: Jumping Out of Water
Reply With Quote #6

Remember you have to be within a certain distance from the surface for it to work.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:08.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode