Check if some key is down - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Check if some key is down (
/showthread.php?tid=297019)
Check if some key is down -
SourceCode - 14.11.2011
How to check if certain key is being pressed by the player and assign a variable, and if he stops pressing remove the variable, how to do it efficiently and time-effective (meaning it should change in matter of seconds)
Re: Check if some key is down -
Camacorn - 14.11.2011
Example:
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (PRESSED(KEY_ACTION))
{
// They just pressed the action key, save their
// old health for restoration.
GetPlayerHealth(playerid, gPlayerHealth[playerid]);
SetPlayerHealth(playerid, INFINITY);
}
else if (RELEASED(KEY_ACTION))
{
// They just let go of action - restore
// their old health again.
SetPlayerHealth(playerid, gPlayerHealth[playerid]);
}
return 1;
}
Wiki Link:
https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
Hope this helps,
Camacorn