Raised This Month: $ Target: $400
 0% 

Detect when jumping


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KviZ
Senior Member
Join Date: Feb 2011
Location: Lithuania
Old 03-29-2011 , 15:25   Detect when jumping
Reply With Quote #1

Is it hard to make a function that is called whenever player jumps? And how can I do it?

P.S. I'm just a begginer
KviZ is offline
naven
Veteran Member
Join Date: Jun 2008
Location: Poland, Cieszyn
Old 03-29-2011 , 16:37   Re: Detect when jumping
Reply With Quote #2

Check this out:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>

#define ADMINACCESS ADMIN_CHAT

new jumpnum[33] = 0
new bool:dojump[33] = false

public plugin_init()
{
    
register_plugin("MultiJump","1.1","twistedeuphoria")
    
register_cvar("amx_maxjumps","1")
    
register_cvar("amx_mjadminonly","0")
}

public 
client_putinserver(id)
{
    
jumpnum[id] = 0
    dojump
[id] = false
}

public 
client_disconnect(id)
{
    
jumpnum[id] = 0
    dojump
[id] = false
}

public 
client_PreThink(id)
{
    if(!
is_user_alive(id)) return PLUGIN_CONTINUE
    
if(get_cvar_num("amx_mjadminonly") && (!access(id,ADMINACCESS))) return PLUGIN_CONTINUE
    
new nbut get_user_button(id)
    new 
obut get_user_oldbutton(id)
    if((
nbut IN_JUMP) && !(get_entity_flags(id) & FL_ONGROUND) && !(obut IN_JUMP))
    {
        if(
jumpnum[id] < get_cvar_num("amx_maxjumps"))
        {
            
dojump[id] = true
            jumpnum
[id]++
            return 
PLUGIN_CONTINUE
        
}
    }
    if((
nbut IN_JUMP) && (get_entity_flags(id) & FL_ONGROUND))
    {
        
jumpnum[id] = 0
        
return PLUGIN_CONTINUE
    
}
    return 
PLUGIN_CONTINUE
}

public 
client_PostThink(id)
{
    if(!
is_user_alive(id)) return PLUGIN_CONTINUE
    
if(get_cvar_num("amx_mjadminonly") && (!access(id,ADMINACCESS))) return PLUGIN_CONTINUE
    
if(dojump[id] == true)
    {
        new 
Float:velocity[3]    
        
entity_get_vector(id,EV_VEC_velocity,velocity)
        
velocity[2] = random_float(265.0,285.0)
        
entity_set_vector(id,EV_VEC_velocity,velocity)
        
dojump[id] = false
        
return PLUGIN_CONTINUE
    
}
    return 
PLUGIN_CONTINUE

__________________
naven.com.pl
"At the end of the day, there are always going to be mental disorders and people who cause violence for no other reason than the fact that they're fucked up and lost. And all we can do is try to learn from it." Corey Taylor.
naven is offline
KviZ
Senior Member
Join Date: Feb 2011
Location: Lithuania
Old 03-30-2011 , 07:17   Re: Detect when jumping
Reply With Quote #3

It's from multijump plugin and I have it and for my basebuilder plugin it's good when you're not gravity zombie, this plugin changes the gravity to 800 after second jump in the air and it makes gravity zombie useless... and it looks difficult, like I said I'm just a begginer. And I want to know what is client_PreThink?

Edit: I fixed my problem!

Last edited by KviZ; 03-30-2011 at 07:41.
KviZ is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 03-30-2011 , 07:47   Re: Detect when jumping
Reply With Quote #4

client_PreThink is an engine forward.
Funcwiki doesn't seem to give a good explanation about it.
This is from the hlsdk:
Quote:
================
PlayerPreThink

Called every frame before physics are run
================
The fakemeta way for this is:
PHP Code:
register_forward(FM_PlayerPreThink"FwdPlayerPreThink"); 
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
KviZ
Senior Member
Join Date: Feb 2011
Location: Lithuania
Old 03-30-2011 , 08:03   Re: Detect when jumping
Reply With Quote #5

Oh thanks a lot

Last edited by KviZ; 03-30-2011 at 08:35.
KviZ is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 03-30-2011 , 08:41   Re: Detect when jumping
Reply With Quote #6

PHP Code:
RegisterHam(Ham_Player_Jump,"player","function",1
__________________
<VeCo> is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-30-2011 , 17:49   Re: Detect when jumping
Reply With Quote #7

Quote:
Originally Posted by <VeCo> View Post
PHP Code:
RegisterHam(Ham_Player_Jump,"player","function",1
That isn't proper for detecting when player jumps, because you still have to check flags and button.

For detecting when player jumps, you should use Orpheu and hook PM_Jump().
__________________
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 14:34.


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