PDA

View Full Version : detecting player condition (run,duck,prone,stand,camp)


ghzero
10-09-2007, 04:02 AM
hello,

I like to ask you how it is the best(simple) procedere for detecting the players condition ..if he stands, runs, ducks, prone(yes that can be requested with funktion).

reason is: i'd like to check that due later kills for saving the player condition in that he does kills other as mostly.

I think the information of the actual player-model-sequence can help out really simple?!


greetz,
ghzero

Wilson [29th ID]
10-09-2007, 05:24 AM
#include <amxmodx>
#include <fakemeta>
#include <dodx>

public plug_init() {
register_forward( FM_PlayerPreThink, "hook_PreThink" );
}

public hook_PreThink( id ) {
new button = pev( id, pev_button );

if( button & IN_DUCK )
{
// Ducking
}
if( button & IN_FORWARD || button & IN_MOVELEFT || button & IN_MOVERIGHT || button & IN_BACK )
{
// Moving
}
if( dod_get_pronestate( id ) )
{
// Proning
}
}

ghzero
10-09-2007, 12:45 PM
I thank you very much!! :)

is it possible to use:
button & IN_SPEED to detect running by +speed-key ?!

I try to uses that procedere and will give feedback if works well or adaptions done..

diamond-optic
10-09-2007, 01:02 PM
i think its IN_RUN

ghzero
10-09-2007, 01:05 PM
i think its IN_RUN

allright.. take a look at the changed code ..pls tell me if you notice an logic error/failture..
if( dod_get_pronestate( id )>0 )
{
// Proning
}
else if( button & IN_DUCK )
{
// Ducking
}
else if( button & IN_RUN )
{
// running
if( button & IN_FORWARD || button & IN_MOVELEFT || button & IN_MOVERIGHT || button & IN_BACK )
{
// Moving WITH speed (running)
}
else
{
//standstill
}
}
else if( button & IN_FORWARD || button & IN_MOVELEFT || button & IN_MOVERIGHT || button & IN_BACK )
{
// Moving
}
else
{
//standstill
}

Wilson [29th ID]
10-10-2007, 07:16 AM
You can change


else if( button & IN_RUN )
{
// running
if( button & IN_FORWARD || button & IN_MOVELEFT || button & IN_MOVERIGHT || button & IN_BACK )
{
// Moving WITH speed (running)
}
else
{
//standstill
}
}


To


else if( button & IN_RUN && (button & IN_FORWARD || button & IN_MOVELEFT || button & IN_MOVERIGHT || button & IN_BACK) )
{
// Moving WITH speed (running)
}

ghzero
10-10-2007, 08:23 PM
hello,

thanks, yes I changed .. some other things too to detecting safer and exacter..

public hook_PreThink( id )
{
if(!is_user_alive(id))
return;

new button = pev( id, pev_button );
// Proning
if( dod_get_pronestate( id )>0 )
pl_condition[id]=4
// Ducking
else if( button & IN_DUCK )
pl_condition[id]=3
//moving
else if( button & IN_FORWARD || button & IN_MOVELEFT || button & IN_MOVERIGHT || button & IN_BACK )
{
new Float:plyr_speed=get_speed_f(id);
new flags = entity_get_int(id, EV_INT_flags)
// Moving WITH speed (running)
if( plyr_speed>220.0 && (flags & FL_ONGROUND) )//an unit amount over walk-speed (bis 219.99999)
pl_condition[id]=2
// Moving/Walk
else if( plyr_speed>3.0 )
pl_condition[id]=1
//walking against obstacle in map (e.g. window/sky/wall/noclip-entity)
else
pl_condition[id]=0
}
//standstill
else
pl_condition[id]=0


//if(ghr_debug==1)
// client_print(id,print_chat,"player-condition(id:%d) is #%d (speed:%f) (camp:%d/%d) (scope:%d) (drug:%d)", id, pl_condition[id], get_speed_f(id), pl_camp[id], pl_campmeter[id], pl_scope[id], pl_drug[id] );
}