Help with command - 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)
+--- Thread: Help with command (
/showthread.php?tid=394037)
Help with command -
jakejohnsonusa - 20.11.2012
Ok so I have a command that will turn vehicles lights on and off constantly. I wanted the same command thatturns them on to also turn them off, but I must have made a mistake becuase when I do it again it just adds another timer (they flash faster)... Here is what I have:
pawn Код:
if(!strcmp(cmd, "/hazard", true))//hazard lights
{
if(IsPlayerConnected(playerid))
{
if(IsPlayerInAnyVehicle(playerid))
{
new newcar = GetPlayerVehicleID(playerid);
if(CarFlasher[newcar] == 0)
{
CarFlasher[newcar] = SetTimer("Flashers", 1000, true);
CarFlasher[newcar] = 1;
}
if(CarFlasher[newcar] == 1)
{
KillTimer(CarFlasher[newcar]);
CarFlasher[newcar] = 0;
}
}
}
}
And under the playerentervehicle part in my script I have this:
So what do I need to do/fix?
Re: Help with command -
kaisersouse - 20.11.2012
I'm surprised its working at all
Quote:
if(CarFlasher[newcar] == 0)
{
CarFlasher[newcar] = SetTimer("Flashers", 1000, true);
CarFlasher[newcar] = 1;
}
if(CarFlasher[newcar] == 1)
{
KillTimer(CarFlasher[newcar]);
CarFlasher[newcar] = 0;
}
|
You may want to return 1 at the end of each "CarFlasher[newcar] = " bit...because from the looks of that you start the timer, set carflasher to '1', and then immediately after that set carflasher to '0' and kill the timer...
Re: Help with command -
jakejohnsonusa - 20.11.2012
So your saying I should add two "return 1;" 's to the script one after each "CarFlasher[newcar] = ..." part?
And thanks +1 Rep.