if(PRESSED(KEY_LOOK_RIGHT))
{
new vehicleid = GetPlayerVehicleID(playerid);
if(IsPlayerInVehicle(playerid, vehicleid))
{
if(!IsVehicleAirVehicleEx(vehicleid))
{
FlashTimerR[vehicleid] = SetTimerEx("FlashLightR", 120, true,"i",vehicleid);
DestroyFlashTimerR[vehicleid] = SetTimerEx("DestroyFlashLightR", 700, false,"i",vehicleid);
}
}
}
if(PRESSED(KEY_LOOK_LEFT))
{
new vehicleid = GetPlayerVehicleID(playerid);
if(IsPlayerInVehicle(playerid, vehicleid))
{
if(!IsVehicleAirVehicleEx(vehicleid))
{
FlashTimerL[vehicleid] = SetTimerEx("FlashLightL", 120, true,"i",vehicleid);
DestroyFlashTimerL[vehicleid] = SetTimerEx("DestroyFlashLightL", 700, false,"i",vehicleid);
}
}
}
forward FlashLightR(vehicleid);
public FlashLightR(vehicleid)
{
new panels,doors,lights,tires;
GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
if(lights == 1)
{
UpdateVehicleDamageStatus(vehicleid, panels, doors, 5, tires);
lights = 5;
}
else if(lights == 5)
{
UpdateVehicleDamageStatus(vehicleid, panels, doors, 1, tires);
lights = 1;
}
return 1;
}
forward DestroyFlashLightR(vehicleid);
public DestroyFlashLightR(vehicleid)
{
new panels,doors,lights,tires;
GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
UpdateVehicleDamageStatus(vehicleid, panels, doors, 5, tires);
KillTimer(FlashTimerR[vehicleid]);
return 1;
}
forward FlashLightL(vehicleid);
public FlashLightL(vehicleid)
{
new panels,doors,lights,tires;
GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
if(lights == 4)
{
UpdateVehicleDamageStatus(vehicleid, panels, doors, 5, tires);
lights = 5;
}
else if(lights == 5)
{
UpdateVehicleDamageStatus(vehicleid, panels, doors, 4, tires);
lights = 4;
}
return 1;
}
forward DestroyFlashLightL(vehicleid);
public DestroyFlashLightL(vehicleid)
{
new panels,doors,lights,tires;
GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
UpdateVehicleDamageStatus(vehicleid, panels, doors, 5, tires);
KillTimer(DestroyFlashTimerL[vehicleid]);
return 1;
}
You should probably check if the timer is already active before setting it (again). If I'd press the key in rapid succession then multiple timers would be set and they would overwrite the already existing timer handles. This means that these timers can't be killed anymore.
|