Quote:
Originally Posted by d1git
Could this work?
PHP код:
new sprint[MAX_PLAYERS];
// PRESSING(keyVariable, keys)
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
// RELEASED(keys)
#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;
}
Pretty simple really - but I would use the method Pottus explained.
EDIT: Typo.
EDIT2: Just tested this in-game, it does work.
|
giving me an error "undefined symbol PRESSED" also tried to change it to "PRESSING" but still the same error