24.11.2012, 14:15
What did I do wrong with the following code, when I do /detectoron everything works fine. If I do /detector off it does the same things as detector on. Can someone tell me how to fix this?
Here is the code:
***The indentation is correct in the first lines, the site is not displaying it right***
Here is the code:
pawn Код:
new DetectorTimer[MAX_PLAYERS];
if (strcmp("/detectoron", cmdtext, true, 10) == 0)
{
if(PlayerInfo[playerid][pDetector])
{
if(IsPlayerInAnyVehicle(playerid))
{
if(DetectorTimer[playerid] != -1) KillTimer(DetectorTimer[playerid]);//
SetTimerEx("RunDetector", 2000, true, "i", playerid);
SendClientMessage(playerid,-1,"Detector On");
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, 10) == 0)
{
if(PlayerInfo[playerid][pDetector])
{
if(IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid,-1,"Detector OFF");
KillTimer(DetectorTimer[playerid]);
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;
}