AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Solved][Help] How to detect a player landing (https://forums.alliedmods.net/showthread.php?t=233136)

dias 01-10-2014 08:30

[Solved][Help] How to detect a player landing
 
Like the title, How to detect a player who is landing?
Example: When player jumps down from a high tree, i want to detect when he/she touchs the surface

bibu 01-10-2014 18:35

Re: [Help] How to detect a player landing
 
Not really efficient..

http://forums.alliedmods.net/showthread.php?p=232294

hornet 01-10-2014 21:09

Re: [Help] How to detect a player landing
 
There doesn't seem to be a solid way to do this. The game engine detects landing on PostThink() so we have to do the same, unless the player incurs damage on the fall.

I suppose you could polish it up a little using a bitsum for alive checks, and unregister the forward where possible:

Code:
#include <amxmodx> #include <fakemeta> const XO_PLAYER     =   5; const m_flFallVelocity  =   251; public plugin_init() {     register_plugin( "Detect Landing", "0.0.1", "hornet" );     register_forward( FM_PlayerPostThink, "CBasePlayer_PostThink" ); } public CBasePlayer_PostThink( id ) {     if( is_user_alive( id ) )     {         static Float:flFallVelocity; flFallVelocity = get_pdata_float( id, m_flFallVelocity, XO_PLAYER );                 if( flFallVelocity && pev( id, pev_flags ) & FL_ONGROUND )         {             //PLAYER JUST LANDED         }     } }

.Dare Devil. 01-10-2014 23:27

Re: [Help] How to detect a player landing
 
Quote:

Originally Posted by hornet (Post 2084188)
There doesn't seem to be a solid way to do this. The game engine detects landing on PostThink() so we have to do the same, unless the player incurs damage on the fall.

I suppose you could polish it up a little using a bitsum for alive checks, and unregister the forward where possible:

Code:
#include <amxmodx> #include <fakemeta> const XO_PLAYER     =   5; const m_flFallVelocity  =   251; public plugin_init() {     register_plugin( "Detect Landing", "0.0.1", "hornet" );     register_forward( FM_PlayerPostThink, "CBasePlayer_PostThink" ); } public CBasePlayer_PostThink( id ) {     if( is_user_alive( id ) )     {         static Float:flFallVelocity; flFallVelocity = get_pdata_float( id, m_flFallVelocity, XO_PLAYER );                 if( flFallVelocity && pev( id, pev_flags ) & FL_ONGROUND )         {             //PLAYER JUST LANDED         }     } }

Do you know that touch is called one time when player is landing?

hornet 01-11-2014 00:14

Re: [Help] How to detect a player landing
 
Quote:

Originally Posted by .Dare Devil. (Post 2084225)
Do you know that touch is called one time when player is landing?

It can be used but could be unreliable depending on exactly what the thread author is trying to do.

dias 01-11-2014 01:33

Re: [Help] How to detect a player landing
 
Quote:

Originally Posted by hornet (Post 2084188)
#include <amxmodx>
#include <fakemeta>

const
XO_PLAYER = 5;
const
m_flFallVelocity = 251;

public plugin_init()
{

register_plugin( "Detect Landing", "0.0.1", "hornet" );
register_forward( FM_PlayerPostThink, "CBasePlayer_PostThink" );
}


public CBasePlayer_PostThink( id )
{

if( is_user_alive( id ) )
{
static Float:flFallVelocity; flFallVelocity = get_pdata_float( id, m_flFallVelocity, XO_PLAYER ); if( flFallVelocity && pev( id, pev_flags ) & FL_ONGROUND ) { //PLAYER JUST LANDED }
}

}

Thanks. this is what i need


All times are GMT -4. The time now is 10:06.

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