Raised This Month: $ Target: $400
 0% 

Jumping Detection low CPU


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TandborsteN
Member
Join Date: Sep 2008
Old 11-07-2010 , 12:57   Jumping Detection low CPU
Reply With Quote #1

Hello!
Im trying to detect when a player jumps and i want to have so low CPU as possible.
So what way is the best way?

My code:
Code:
public client_PreThink(id)
{
    new New_Button = get_user_button(id);
    new Old_Button = get_user_oldbutton(id);
    if((New_Button & IN_JUMP) && !(Old_Button & IN_JUMP) && is_user_alive(id))
    {
        //ACTION CODE
    }
}
__________________
TANDBORSTEN!
TandborsteN is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-07-2010 , 13:06   Re: Jumping Detection low CPU
Reply With Quote #2

Move to FM_CmdStart.
Use get_uc() for buttons instead of get_user_button()
Check if player is on ground (get_entity_flags() & FL_ONGROUND).
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
TandborsteN
Member
Join Date: Sep 2008
Old 11-07-2010 , 13:09   Re: Jumping Detection low CPU
Reply With Quote #3

Can you PLEASE show me an example?
Doesen't get anything of what you mean.
__________________
TANDBORSTEN!
TandborsteN is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-07-2010 , 13:12   Re: Jumping Detection low CPU
Reply With Quote #4

Search for FM_CmdStart. You can find funciton examples here: http://www.amxmodx.org/funcwiki.php
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
TandborsteN
Member
Join Date: Sep 2008
Old 11-07-2010 , 13:14   Re: Jumping Detection low CPU
Reply With Quote #5

Okey thank you very much, u are awsome!
__________________
TANDBORSTEN!
TandborsteN is offline
TandborsteN
Member
Join Date: Sep 2008
Old 11-07-2010 , 13:22   Re: Jumping Detection low CPU
Reply With Quote #6

So something like this?
Code:
public FM_CmdStart_Pre(id, uc_handle)
{
    new button = get_uc(uc_handle, UC_Buttons);
    new oldbutton = pev(id, pev_oldbuttons);
    new flags = pev(id, pev_flags);
    if(button & IN_JUMP && !(oldbutton & IN_JUMP) && flags & FL_ONGROUND)
    {
        //CODE
    }
}
__________________
TANDBORSTEN!
TandborsteN is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 11-07-2010 , 13:36   Re: Jumping Detection low CPU
Reply With Quote #7

Exolent isn't ham better?

PHP Code:
RegisterHam(Ham_Player_Jump"player""Player_Jump"
bibu is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-07-2010 , 13:45   Re: Jumping Detection low CPU
Reply With Quote #8

Quote:
Originally Posted by TandborsteN View Post
So something like this?
Code:
public FM_CmdStart_Pre(id, uc_handle)
{
    new button = get_uc(uc_handle, UC_Buttons);
    new oldbutton = pev(id, pev_oldbuttons);
    new flags = pev(id, pev_flags);
    if(button & IN_JUMP && !(oldbutton & IN_JUMP) && flags & FL_ONGROUND)
    {
        //CODE
    }
}
Yes.

Quote:
Originally Posted by bibu View Post
Exolent isn't ham better?

PHP Code:
RegisterHam(Ham_Player_Jump"player""Player_Jump"
Ham would be better to do the same check in this case, but you would still have to check it like in FM_CmdStart because it isn't called only when a player jumps.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 11-08-2010 , 09:48   Re: Jumping Detection low CPU
Reply With Quote #9

Quote:
Originally Posted by TandborsteN View Post
So something like this?
Code:
public FM_CmdStart_Pre(id, uc_handle)
{
    new button = get_uc(uc_handle, UC_Buttons);
    new oldbutton = pev(id, pev_oldbuttons);
    new flags = pev(id, pev_flags);
    if(button & IN_JUMP && !(oldbutton & IN_JUMP) && flags & FL_ONGROUND)
    {
        //CODE
    }
}
Ya but its better if you would make the variables static since this forward sometimes get called very quickly
__________________

My Plugins For ZP

Inactive due to College and Studies
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
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 11:21.


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