It is something I want to discuss than actually a question.
1. Wrong way to detect walk
PHP Code:
buttons = pev(id, pev_buttons) //or buttons = get_uc(cmd, UC_Buttons) if using at CmdStart
//Check running
if(buttons & IN_RUN)
{
//Do stuff
}
This is most people thought at first if they try to check running/walking but
it actually didn't work at all
Because
IN_RUN exist but it never been called or set anywhere
2. The usual way to detect walk
Usually, when we want to detect walk/run, we have to check via
Player Maxspeed
There was an old topic discussed about this (
Link)
3. Detect via player sequence
This way, we try to detect walk/run via checking player sequence. More specifically -
Gaitsequence
PHP Code:
stock IsPlayerWalking(id)
{
static buttons, sequence;
buttons = pev(id, pev_button);
sequence = pev(id, pev_gaitsequence);
if((buttons & IN_FORWARD || buttons & IN_BACK || buttons & IN_LEFT || buttons & IN_RIGHT))
{
if(sequence == 3)
return true;
else
return false
}
return false
}
sequence == 3 because
Player Model's walk sequence is 3 and we know it is gaitsequence because the animation was on the lower part of the body.
4. Detect via m_Activity (reHLDS/reGameDLL)
When I look up in reGameDLL, I saw player animation was set depend on Activity and from Activity, to LookUpSequence
In ReAPI we have a member called m_Activity so we can actually check it like this
PHP Code:
stock IsPlayerWalking(id)
{
static Activity:Act; //cssdk_const
Act = get_member(id, m_Activity) //I am not sure what this return though, haven't try
if(Act == ACT_WALK)
return true;
return false
}
I don't want to post in TUT section because I am not sure how many % all of this is correct so I want to make it as a discussion first.
PS: Also, I saw this part which related to speed
PHP Code:
if (speed > 135.0f)
pev->gaitsequence = LookupActivity(ACT_RUN);
else
pev->gaitsequence = LookupActivity(ACT_WALK);
So it still lead to a problem when we try to detect walk to turn it into "Sprint" (Hold Shift to run faster) or the player speed modified (like Zombie Mod), it will automatically change to RUN when speed > 135.0f (I am lazy to convert for now).
This all might be non-sense so forgive me if all of this is wrong
__________________