23.04.2013, 20:46
Ok so for some reason this timer isn't being killed when the player does /dispatch off (It turns on fine with /dispatch on). Does anyone see somthing I am doing wrong? I have no compile errors.
I have added these in the right spots BTW:
forward DispatchAlert(playerid);
new DispatchAlertVar[MAX_PLAYERS];
Here is the command code:
Here is the timer code:
I have added these in the right spots BTW:
forward DispatchAlert(playerid);
new DispatchAlertVar[MAX_PLAYERS];
Here is the command code:
pawn Код:
if(strcmp(cmd,"/dispatch",true)==0)
{
new rslt[24];
rslt = strtok(cmdtext, idx);
if(!strlen(rslt))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /dispatch [ON/OFF)");
return 1;
}
if(strcmp(rslt,"on",true) == 0)
{
if(PlayerInfo[playerid][pDBanned] == 1)
{
SendClientMessage(playerid, COLOR_GREY, "** You are banned From Cop Duty!");
return 1;
}
GameTextForPlayer(playerid, "~w~Powering Up...", 11000, 5);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(playerid) && IsACop(playerid) || IsAFiremen(playerid))
{
if(PlayerInfo[i][pDuty] == 1 && IsACop(i) || IsPlayerAdmin(i) && IsACop(i))
{
SetPlayerMarkerForPlayer(playerid, i, COLOR_YELLOW);
}
if(JobDuty[i] == 1 && IsAFiremen(i))
{
SetPlayerMarkerForPlayer(playerid, i, COLOR_YELLOW);
}
//GameTextForPlayer(playerid, "~w~Searching for vehicles...", 11000, 5);
DispatchAlertVar[playerid] = SetTimerEx("DispatchAlert",10000,true, "i", playerid);
}
}
}
else if(strcmp(rslt,"off",true) == 0)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(playerid) && IsACop(playerid) || IsAFiremen(playerid)|| IsPlayerAdmin(playerid))
{
KillTimer(DispatchAlertVar[playerid]);
SetPlayerMarkerForPlayer(i, playerid, TEAM_HIT_COLOR);
//GameTextForPlayer(playerid, "~w~DVDS Powering Down......", 1000, 5);
GameTextForPlayer(playerid, "~w~Powering Down...", 11000, 5);
}
}
}
new y, m, d;
new h,mi,s;
getdate(y,m,d);
gettime(h,mi,s);
format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /dispatch",d,m,y,h,mi,s,sendername);
CommandLog(string);
return 1;
}
pawn Код:
public DispatchAlert(playerid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
SetPlayerMarkerForPlayer(i, playerid, TEAM_HIT_COLOR);
if(IsPlayerConnected(playerid) && IsACop(i) || IsAFiremen(i))
{
if(PlayerInfo[playerid][pDuty] == 1 && IsACop(playerid) || IsPlayerAdmin(playerid) && IsACop(i))
{
SetPlayerMarkerForPlayer(playerid, i, COLOR_BLUE);
}
if(JobDuty[playerid] == 1 && IsAFiremen(playerid) && IsAFiremen(i))
{
SetPlayerMarkerForPlayer(playerid, i, COLOR_ORANGE);
}
}
}
new string[800 char];
new CurrentCars;
CurrentCars = 0;
for(new i = 0; i < MAX_VEHICLES; i++) // MY WIP Police Vehicle Info system. Includes Health, driver, passengers, Location?, and Veh ID
{
if(IsACopCar(i))//All Cop Cars
{
for(new q = 0; q < MAX_PLAYERS; q++)
{
if(IsPlayerInVehicle(q, i))//All Cop Cars with People in the vehicle
{
if(GetPlayerVehicleSeat(q) == 0)//All cop cars with a driver
{
new vehicle[24];
new player[800];
new Float:engine;
GetVehicleHealth(i, engine);
new Float:currenthealth;
currenthealth = engine / 10;
GetVehicleName(i, vehicle, sizeof(vehicle));
new zone[MAX_ZONE_NAME];
GetVehicle2DZone(i, zone, MAX_ZONE_NAME);
new atext[20];
if(gEngine[i] == 1) { atext = "{76EE00}ON{FFFFFF}"; }
else if(gEngine[i] == 0) { atext = "{EE0000}OFF{FFFFFF}"; }
new kmh = GetPlayerSpeed(q, true);
format(player, sizeof(player), "{FFFFFF}Vehicle: %s (%d) | Gov ID: %d | Driver: %s (%d) \n", vehicle, GetVehicleModel(i), i, Nick(q), q);// Want to add more stuff here...
strcat(string, player)
format(player, sizeof(player), " {FFFFFF}Engine Status: %s | Health: %.1f %% | Speed: %d | Location: %s \n", atext, currenthealth, kmh, zone);// Want to add more stuff here...
strcat(string, player)
ShowPlayerDialog(playerid, 1592, DIALOG_STYLE_MSGBOX, "Dispatch Vehicles Display System (DVDS)", string, "Close", "");
strdel(string, 0, strlen(string));
CurrentCars = 1;
return 1;
}
}
}
}
/*else if (CurrentCars == 0)// If no cars are found
{
new player[800];
format(player, sizeof(player), " - No Occupied Vehicles Found! - \n");
strins(string, player, strlen(string), sizeof(string));
ShowPlayerDialog(playerid, 1592, DIALOG_STYLE_MSGBOX, "Dispatch Vehicles Display System (DVDS)", string, "Close", "");
strdel(string, 0, strlen(string));
}
return 1;*/
}
return 1;
}