24.04.2012, 13:57
Hey im making a drift server and I want to have so when you click on LMB you get nitro but when you release LMB it goes away.
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (PRESSED(KEY_FIRE))
{
if (IsPlayerInAnyVehicle(playerid))
{
AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
}
}
return 1;
}
pawn Код:
|
#define PRESSED(%0) \ (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0))) #define RELEASED(%0) \ (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0))) public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if (PRESSED(KEY_FIRE)) { if (IsPlayerInAnyVehicle(playerid)) { new component = AddVehicleComponent(GetPlayerVehicleID(playerid), 1010); } } if (RELEASED(KEY_FIRE)) { if (IsPlayerInAnyVehicle(playerid)) { RemoveVehicleComponent(GetPlayerVehicleID(playerid), component); } } return 1; }