Timer Repeat
#1

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?
Reply
#2

Change
pawn Код:
SetTimer("Haz_Timer", 500, false);
to
pawn Код:
SetTimer("Haz_Timer", 500, true);
Reply
#3

it still only goes on then off once
Reply
#4

SetTimerEx ( "Haz_Timer", 500, 1, "d", playerid );
Reply
#5

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:

pawn Код:
OnGameModeInit()
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)