Help please on Killing a Timer, it won't die!
#1

For some reason I can't get the timer to Kill using /detectoroff after it's created with /detectoron. How do I fix this so It kills it?

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;
    }
**Note that I will also need to add the kill timer function to other places in my GM**
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)