17.01.2012, 19:10
ok can u help me telling me how i can have NOS on a car by pressing LMB? when i leave LMB i want NOS to stop. can it be?
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(newkeys & KEY_FIRE)
{
new vehicleid = GetPlayerVehicleID(playerid);
AddVehicleComponent(vehicleid, 1010);
}
}
return 1;
}
After it expire, addvehiclecomponent with nos again.
something like this; pawn Код:
|
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
#define RELEASED(%0) \
(((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new State = GetPlayerState(playerid);
if(State == PLAYER_STATE_DRIVER)
{
new VehID = GetPlayerVehicleID(playerid);
if(PRESSED(KEY_FIRE))
{
AddVehicleComponent(VehID, 1010);
return 0;
}
if(RELEASED(KEY_FIRE))
{
if(VehID > 0 && VehID != INVALID_VEHICLE_ID)
{
new component = GetVehicleComponentInSlot(VehID, CARMODTYPE_NITRO);
if(component == 1010)
RemoveVehicleComponent(VehID,1010);
}
return 0;
}
return 0;
}
return 1;
}