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