SA-MP Forums Archive
Command to Button - 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: Command to Button (/showthread.php?tid=330626)



Command to Button - MrEnd - 01.04.2012

Hey, how can i make /fix to something like the button "H"
I hope its not something very easy xD


Re: Command to Button - Catalyst- - 01.04.2012

Here...
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
	{
		if((oldkeys & KEY_CROUCH) && !(newkeys & KEY_CROUCH))
		{
			// Put your /fix code here...
		}
	}
	return 1;
}



Re: Command to Button - MrEnd - 01.04.2012

Heh i found it self

Код:
#define PRESSED(%0) \
	(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if (PRESSED(KEY_CROUCH))
	{
		if (IsPlayerInAnyVehicle(playerid))
                if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
		{
			RepairVehicle(GetPlayerVehicleID(playerid));
		}
	}
	return 1;
}