17.01.2016, 19:13
I just updated the code, it should work now - typo basically.
PHP код:
new sprint[MAX_PLAYERS];
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
#define RELEASED(%0) \
(((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
PHP код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(PRESSED(KEY_SPRINT))
{
sprint[playerid] = 1; // Player pressed the sprint key
}
if(RELEASED(KEY_SPRINT))
{
sprint[playerid] = 0; // Player letgo of the sprint key
}
return 1;
}