SA-MP Forums Archive
SetTimer problem... - 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: SetTimer problem... (/showthread.php?tid=160787)



SetTimer problem... - Ash. - 17.07.2010

I have a timer that checks to see if a trailer is attached to a vehicle every second (its only a very small script). If my trailer disconnects, the timer, which runs every second will pick it up and exectue a code. Here is the checking script.

pawn Код:
forward TruckCheck(playerid);
public TruckCheck(playerid)
{
    if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)) == 0)
    {
        SendClientMessage(playerid, WORK, "Please reconnect your trailer");
    }
    if(IsPlayerInAnyVehicle(playerid) == 0)
    {
        SendClientMessage(playerid, WORK, "Get back in your truck!");
    }
}
And under the OnPlayerCommandText(playerid, cmdtext[]) command, (the actual command is "/work") i run the timer (after a lot of ifs)

pawn Код:
new truckchecktime; // This is called way before the actual timer
truckchecktime = SetTimer("TruckCheck", 1000, true);
EDIT: Do i then just have to call truckchecktime? Like this:
pawn Код:
truckchecktime;
I also end (KillTimer) the timer when the player has completed the mission

pawn Код:
KillTimer(truckchecktime);
This fails to work. Although compiles without warnings and errors.

I dont understand why it doesnt work.
Thanks, Ash!


Re: SetTimer problem... - bigcomfycouch - 17.07.2010

pawn Код:
truckchecktime = SetTimerEx("TruckCheck", 1000, true, "i", playerid)



Re: SetTimer problem... - Jay_ - 17.07.2010

EDIT: See above


Re: SetTimer problem... - Ash. - 17.07.2010

bigcomfycouch: Thanks, ill try that now
Jay_: no, when the trailer disconnects, it should run the first script bit. But it doesnt. So that means the timer isnt working.