01.04.2013, 19:44
PHP Code:
new CarFireObj[MAX_PLAYERS]; // Under the script
#define HOLDING(%0) \
((newkeys & (%0)) == (%0))
#define RELEASED(%0) \
(((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (HOLDING( 4 ))// if player use nitro
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(IsValidObject(CarFireObj[playerid]) == 0)// add fire from exhaust when player use nitro
{
CarFireObj[playerid] = CreateObject(18694, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(CarFireObj[playerid], GetPlayerVehicleID(playerid), 0.0, -2.3, 1.2, 180.0, 0.0, 0.0);
}
}
}
if (RELEASED( 4 ))// if player stop use nitro
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(IsValidObject(CarFireObj[playerid]) == 1)DestroyObject(CarFireObj[playerid]);// remove fire from exhaust when player stop use nitro
}
}
return 1;
}