Server crashing command -
CalvinC - 24.11.2014
Hello, i have a problem with this command.
When i change the name of one of the divisions with this command, it has a random chance of crashing the server, which it most likely does.
Код HTML:
CMD:adjustdivisionname(playerid, params[])
{
new division, name[8], 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 leader.");
if(sscanf(params, "is[32]", division, name)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /adjustdivisionname [division 1-5] [name]");
switch(division)
{
case 1:
{
FacInfo[1][fDiv1] = name;
format(string, sizeof(string), "You have set division 1's name to %s", name);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
case 2:
{
FacInfo[1][fDiv2] = name;
format(string, sizeof(string), "You have set division 2's name to %s", name);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
case 3:
{
FacInfo[1][fDiv3] = name;
format(string, sizeof(string), "You have set division 3's name to %s", name);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
case 4:
{
FacInfo[1][fDiv4] = name;
format(string, sizeof(string), "You have set division 4's name to %s", name);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
case 5:
{
FacInfo[1][fDiv5] = name;
format(string, sizeof(string), "You have set division 5's name to %s", name);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
}
return 1;
}
Re : Server crashing command -
Dutheil - 24.11.2014
Try this
pawn Код:
CMD:adjustdivisionname(playerid, params[])
{
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 leader.");
new division, name[8];
if(sscanf(params, "is[8]", division, name)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /adjustdivisionname [division 1-5] [name]");
new string[128];
switch(division)
{
case 1:
{
strins(FacInfo[1][fDiv1], name, 0);
format(string, sizeof(string), "You have set division 1's name to %s", name);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
case 2:
{
strins(FacInfo[1][fDiv2], name, 0);
format(string, sizeof(string), "You have set division 2's name to %s", name);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
case 3:
{
strins(FacInfo[1][fDiv3], name, 0);
format(string, sizeof(string), "You have set division 3's name to %s", name);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
case 4:
{
strins(FacInfo[1][fDiv4], name, 0);
format(string, sizeof(string), "You have set division 4's name to %s", name);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
case 5:
{
strins(FacInfo[1][fDiv5], name, 0);
format(string, sizeof(string), "You have set division 5's name to %s", name);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
}
return 1;
}
Re: Server crashing command -
CalvinC - 24.11.2014
No, that makes it unable to replace the existing division names, thereby making their names longer and longer when you change them.
But it fixed the crashing.
Re: Server crashing command -
CalvinC - 25.11.2014
Bump.
Re: Server crashing command -
CalvinC - 26.11.2014
Bump again.
Re: Server crashing command -
dusk - 26.11.2014
So we can assume that the problem is different string sizes. What's the size of "fIdv" ?
Re: Server crashing command -
CalvinC - 26.11.2014
What do you mean?
Re: Server crashing command -
dusk - 26.11.2014
FacInfo[1][fDiv3] variable and its enum. Show it.
Re: Server crashing command -
CalvinC - 26.11.2014
You mean this?
pawn Код:
stock RPFDN(playerid)
{
new divname[8];
if(PlayerInfo[playerid][pFac] == 1)
{
if(PlayerInfo[playerid][pFacDiv] == 1) format(divname, sizeof(divname), "%s", FacInfo[1][fDiv1]);
else if(PlayerInfo[playerid][pFacDiv] == 2) format(divname, sizeof(divname), "%s", FacInfo[1][fDiv2]);
else if(PlayerInfo[playerid][pFacDiv] == 3) format(divname, sizeof(divname), "%s", FacInfo[1][fDiv3]);
else if(PlayerInfo[playerid][pFacDiv] == 4) format(divname, sizeof(divname), "%s", FacInfo[1][fDiv4]);
else if(PlayerInfo[playerid][pFacDiv] == 5) format(divname, sizeof(divname), "%s", FacInfo[1][fDiv5]);
}
if(PlayerInfo[playerid][pFacDiv] == 0) format(divname, sizeof(divname), "None");
return divname;
}
Re: Server crashing command -
CalvinC - 10.12.2014
Third bump.