Raised This Month: $ Target: $400
 0% 

[Solved][Help] How to detect a player landing


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dias
BANNED
Join Date: Jul 2009
Location: South Vietnam
Old 01-10-2014 , 08:30   [Solved][Help] How to detect a player landing
Reply With Quote #1

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

Last edited by dias; 01-11-2014 at 01:41.
dias is offline
Send a message via Yahoo to dias Send a message via Skype™ to dias
bibu
Veteran Member
Join Date: Sep 2010
Old 01-10-2014 , 18:35   Re: [Help] How to detect a player landing
Reply With Quote #2

Not really efficient..

http://forums.alliedmods.net/showthread.php?p=232294
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 01-10-2014 , 21:09   Re: [Help] How to detect a player landing
Reply With Quote #3

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         }     } }
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 01-10-2014 , 23:27   Re: [Help] How to detect a player landing
Reply With Quote #4

Quote:
Originally Posted by hornet View Post
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?
.Dare Devil. is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 01-11-2014 , 00:14   Re: [Help] How to detect a player landing
Reply With Quote #5

Quote:
Originally Posted by .Dare Devil. View Post
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.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
dias
BANNED
Join Date: Jul 2009
Location: South Vietnam
Old 01-11-2014 , 01:33   Re: [Help] How to detect a player landing
Reply With Quote #6

Quote:
Originally Posted by hornet View Post
#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

Last edited by dias; 01-11-2014 at 01:35.
dias is offline
Send a message via Yahoo to dias Send a message via Skype™ to dias
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 10:06.


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