Quick help on command that has timer
#1

Ok so I decided to create a command in my GM that acts as hazard lights. What it does it constantly turn the lights on and off when someone does /hazard. But I am trying to get it where /hazard turns it on AND off. How do I do this? Please tell me what to add so that /hazard will both set the timer to on if its off and kill the timer if it's is on.

Thanks,
jakejohnsonusa

Here is what I have so far:
pawn Код:
if(!strcmp(cmd, "/hazard", true))
    {
        if(IsPlayerConnected(playerid))
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                flashers1 = SetTimer("Flashers", 1000, true);
            }
        }
    }
And for the flashers timer:
pawn Код:
public Flashers ()
{
    new playerid;
    new newcar = GetPlayerVehicleID(playerid);
    ToggleVehicleLights(newcar)
    return 1;
}
**I do have the defined things and it compiles and works, all I need is to make it where /hazard will also turn it off once it's on***
Reply
#2

pawn Код:
new CarFlasher[MAX_VEH];
if(!strcmp(cmd, "/hazard", true))
    {
        if(IsPlayerConnected(playerid))
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                new newcar = GetPlayerVehicleID(playerid);
                if(CarFlasher[newcar] == -1)
                {
                CarFlasher[newcar] = SetTimer("Flashers", 1000, true);
                }
                if(CarFlasher[newcar] != -1)
               {
                KillTimer(CarFlasher[newcar]);
                CarFlasher[newcar] == -1;
               }
            }
        }
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)