Raised This Month: $32 Target: $400
 8% 

[CS] Player jump event


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 12-27-2014 , 08:13   [CS] Player jump event
Reply With Quote #1

Hello and sorry for basic question.
How I can detect player jump event? I try:
PHP Code:
RegisterHam(Ham_Player_Jump"player""ham_PlayerJumpPost"0
But this called everytime when player send +jump (when player presses spacebar).
Phant is offline
Send a message via ICQ to Phant
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-27-2014 , 08:20   Re: [CS] Player jump event
Reply With Quote #2

Hook as post, if you want callback be called after some sanity checks. It will filter probably most of cases.

Code:
void CBasePlayer::Jump(void)
{
	if (pev->flags & FL_WATERJUMP)
		return;

	if (pev->waterlevel >= 2)
		return;

	if (!(m_afButtonPressed & IN_JUMP))
		return;

	if (!(pev->flags & FL_ONGROUND) || !pev->groundentity)
		return;
        ...
__________________

Last edited by Arkshine; 12-27-2014 at 08:20.
Arkshine is offline
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 12-27-2014 , 21:27   Re: [CS] Player jump event
Reply With Quote #3

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
 
public plugin_init()
{
        
RegisterHam(Ham_Player_Jump"player""ham_PlayerJumpPost"0)
}
public 
ham_PlayerJumpPost(id)
{
        if((
pev(idpev_flags) & FL_ONGROUND) && !(pev(idpev_oldbuttons) & IN_JUMP)) client_print(idprint_chat"1 jump")


Last edited by Phant; 12-27-2014 at 21:28.
Phant is offline
Send a message via ICQ to Phant
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 23:28.


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