Okay so I have a command where the police factions on my server can create separate divisions using a command. The command compiles fine and all but when they use the command it crashes the server.
pawn Код:
CMD:setdivision(playerid, params[])
{
new playerb, division, string[128];
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(!IsACop(playerid) || !PlayerInfo[playerid][pFacLeader]) return SendClientMessage(playerid, COLOR_GREY, "You are not an LSPD faction leader.");
if(sscanf(params, "ui", playerb, division))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: setdivision [playerid] [division]");
format(string, sizeof(string), "DIVISIONS: 1) %s | 2) %s | 3) %s | 4) %s", FacInfo[1][fDiv1], FacInfo[1][fDiv2], FacInfo[1][fDiv3], FacInfo[1][fDiv4]);
SendClientMessage(playerid, COLOR_GREY, string);
return 1;
}
if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
if(PlayerInfo[playerb][pFac] != PlayerInfo[playerid][pFac]) return SendClientMessage(playerid, COLOR_GREY, "Player is not in your faction.");
if(division < 0 || division > 4) return SendClientMessage(playerid, COLOR_GREY, "Divisions are between 1 and 4.");
if(PlayerInfo[playerb][pFacDiv] == division) return SendClientMessage(playerid, COLOR_GREY, "Player is already in a division.");
PlayerInfo[playerb][pFacDiv] = division;
PlayerInfo[playerb][pFacDivLeader] = division;
format(string, sizeof(string), "You have assigned %s to lead the %s division.", RPN(playerb), RPFDN(playerb));
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "%s has assigned you to lead the %s division.", RPN(playerid), RPFDN(playerb));
SendClientMessage(playerb, COLOR_LIGHTBLUE, string);
return 1;
}
You have some "stocks" / "functions" that we can't tell like this but the best way is to debug it as you would find ou exactly where is the problem.
and so on after each function and the last one that doesn't not show that's where the problem is.
Alright. Will test.