Cmd make server crashing - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Cmd make server crashing (
/showthread.php?tid=347442)
Cmd make server crashing -
N0FeaR - 01.06.2012
When i using this cmd my server crashing then can you see the problem?
pawn Код:
CMD:setadminname(playerid, params[])
{
if(PlayerInfo[playerid][pAdministrator] < 4)
return true;
new
userID,
playerNameString[MAX_PLAYER_NAME];
if(sscanf(params, "us[24]", userID, playerNameString))
return SendClientMessage(playerid, COLOR_GREY, "/setadminname [playerid] [adminname]");
if(!IsPlayerConnected(userID))
return SendClientMessage(playerid, COLOR_GREY, "The specified player ID is either not connected or has not authenticated.");
if(PlayerInfo[userID][pAdministrator] > PlayerInfo[playerid][pAdministrator])
return SendClientMessage(playerid, COLOR_GREY, "You can't change the admin name of a higher level administrator.");
new messageString[128];
new Query[128];
new result[80];
format( Query, sizeof( Query ), "SELECT * FROM `Accounts` WHERE `Adminname` = '%s'", (result) );
mysql_query( Query );
printf(" SQL: %s",Query);
mysql_store_result();
if( mysql_num_rows() >= 1 )
{
mysql_free_result();
SendClientMessage( playerid, COLOR_WHITE, "This Admin Name is already taken, tell him to take another one." );
return 1;
}
else
mysql_free_result();
format(messageString, sizeof(messageString), "You have changed %s's admin name to %s.", PlayerInfo[userID][AdminName], playerNameString);
SendClientMessage(playerid, COLOR_WHITE, messageString);
format(messageString, sizeof(messageString), "%s has changed your admin name to %s.", PlayerInfo[playerid][AdminName], playerNameString);
SendClientMessage(userID, COLOR_WHITE, messageString);
format(PlayerInfo[userID][AdminName], MAX_PLAYER_NAME, "%s", playerNameString);
if(AdminDuty[playerid] >= 1)
SetPlayerName(userID, playerNameString);
// More stupid shit
new string[128];
new giveplayerid;
SetPlayerName(giveplayerid,(result));
format( string, sizeof( string ), "UPDATE `Accounts` SET `AdminName` = '%s' WHERE `UserID` = '%d'",(result),PlayerInfo[ giveplayerid ][pDatabaseID]);
mysql_query(string);
return 1;
}
Re: Cmd make server crashing -
iggy1 - 01.06.2012
Add some prints to see if any get printed and where they stop.
EDIT: crash detect plugin may also help.
Re: Cmd make server crashing -
[MG]Dimi - 01.06.2012
I bet on this:
pawn Код:
new result[80];
format( Query, sizeof( Query ), "SELECT * FROM `Accounts` WHERE `Adminname` = '%s'", (result) );
Result is empty...
Re: Cmd make server crashing -
SuperViper - 01.06.2012
You're setting the player's name to a blank name, which crashes the server.