Timer Questions
#1

Whats the difference between SetTimer and SetTimerEx? And what does the format letter mean (which would I use)?

The reason I am asking is because I am having problems with the timer bellow, it starts fine, but I can't get it to stop. What should I do or fix:

pawn Код:
new DetectorTimer[MAX_PLAYERS];
    new DetectorOn[MAX_PLAYERS]=1;
    if (strcmp("/detectoron", cmdtext, true, 11) == 0)
    {
        if(PlayerInfo[playerid][pDetector])
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                if(DetectorTimer[playerid] != -1) KillTimer(DetectorTimer[playerid]);//
                DetectorTimer[playerid] = SetTimerEx("RunDetector", 2000, true, "i", playerid);
                SendClientMessage(playerid,-1,"Detector On");
                DetectorOn[playerid]=1;
                return 1;
            }
            SendClientMessage(playerid, COLOR_GREY, "** You aren't in a vehicle!");
            return 1;
        }
        SendClientMessage(playerid, COLOR_GREY, "** You don't have a Radar Detector!");
        return 1;
    }
    if (strcmp("/detectoroff", cmdtext, true, 12) == 0)
    {
        if(PlayerInfo[playerid][pDetector])
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                if(DetectorOn[playerid]==0)return SendClientMessage(playerid,-1,"Detector Already OFF");
                SendClientMessage(playerid,-1,"Detector OFF");
                KillTimer(DetectorTimer[playerid]);
                DetectorOn[playerid]=0;
                return 1;
            }
            SendClientMessage(playerid, COLOR_GREY, "** You aren't in a vehicle!");
            return 1;
        }
        SendClientMessage(playerid, COLOR_GREY, "** You don't have a Radar Detector!");
        return 1;
    }
Reply
#2

SetTimer just calls which ever function directly (after the timer ends ofc)

SetTimerEx allows you to pass numbers to the function (perhaps a playerid), you can read about it here.
Reply
#3

So why can't I kill my timer? Everything looks right to me, am I doing somthing wrong?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)