Timer Repeat - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Timer Repeat (
/showthread.php?tid=207415)
Timer Repeat -
wilko1995 - 06.01.2011
pawn Код:
forward Haz_Timer(playerid);
public Haz_Timer(playerid)
{
new veh = GetPlayerVehicleID(playerid);
SetVehicleParamsEx(veh,engine,0,alarm,doors,bonnet,boot,objective);
}
dcmd_hazards(playerid, params[])
{
#pragma unused params
if(IsPlayerInAnyVehicle(playerid))
{
new veh = GetPlayerVehicleID(playerid);
SetTimer("Haz_Timer", 500, false);
SetVehicleParamsEx(veh,engine,1,alarm,doors,bonnet,boot,objective);
return 1;
}
return 0;
}
Hi,
How do i get the timer "Haz_Timer" to repeat so that i get flashing lights. i type /hazards and the lights come on then go off which is what its meant to do but how do i repeat that?
Re: Timer Repeat -
Krx17 - 06.01.2011
Change
pawn Код:
SetTimer("Haz_Timer", 500, false);
to
pawn Код:
SetTimer("Haz_Timer", 500, true);
Re: Timer Repeat -
wilko1995 - 06.01.2011
it still only goes on then off once
Re: Timer Repeat -
Retardedwolf - 06.01.2011
SetTimerEx ( "Haz_Timer", 500, 1, "d", playerid );
Re: Timer Repeat -
Whizion - 06.01.2011
Try this:
pawn Код:
forward Haz_Timer();
public Haz_Timer()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
{
if(GetPVarInt(i, "VehLightStatus") > 0)
{
SetVehicleParamsEx(GetPlayerVehicleID(i),engine,0,alarm,doors,bonnet,boot,objective);
SetPVarInt(i, "VehLightStatus", 0);
}
else
{
SetVehicleParamsEx(GetPlayerVehicleID(i),engine,1,alarm,doors,bonnet,boot,objective);
SetPVarInt(i, "VehLightStatus", 1);
}
}
}
return 1;
}
dcmd_hazards(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid))
{
new veh = GetPlayerVehicleID(playerid);
SetVehicleParamsEx(veh,engine,1,alarm,doors,bonnet,boot,objective);
SetPVarInt(playerid, "VehLightStatus", 1);
return 1;
}
return 0;
}
EDIT:
You should also put this:
pawn Код:
SetTimer("Haz_Timer", 500, true);
Under: