25.07.2012, 10:39
Hi guyz.I tried to make when i press the KEY_FIRE to start the nitro and when i realese the KEY_FIRE the nitro ends.How to do that ?
if(PRESSED(KEY_FIRE)) { if(IsPlayerInAnyVehicle(playerid)) { AddVehicleComponent(GetPlayerVehicleID(playerid), 1010); } } else if(RELEASED(KEY_FIRE)) { if(IsPlayerInAnyVehicle(playerid)) { RemoveVehicleComponent(0,1010); } }
if(PRESSED(KEY_FIRE))
{
if(IsPlayerInAnyVehicle(playerid))
{
AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
}
else if(RELEASED(KEY_FIRE))
{
if(IsPlayerInAnyVehicle(playerid))
{
RemoveVehicleComponent(0,1010);
}
}
}
if(PRESSED(KEY_FIRE)) { if(IsPlayerInAnyVehicle(playerid)) { AddVehicleComponent(GetPlayerVehicleID(playerid), 1010); } } else if(RELEASED(KEY_FIRE)) { if(IsPlayerInAnyVehicle(playerid)) { RemoveVehicleComponent(0,1010); } }
#define HOLDING(%0) \
((newkeys & (%0)) == (%0))
#define RELEASED(%0) \
(((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(HOLDING(KEY_FIRE))
{
if(IsPlayerInAnyVehicle(playerid))
{
AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
}
}
else if(RELEASED(KEY_FIRE))
{
if(IsPlayerInAnyVehicle(playerid))
{
RemoveVehicleComponent(GetPlayerVehicleID(playerid), 1010);
}
}
return 1;
}