Check if some key is down
#1

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)
Reply
#2

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)