10.06.2013, 13:10
Actually when i execute this code the server crashes and the samp-server.exe closes, and the name is not changed in the database!!
Try to fix this problem as soon as possible..
pawn Код:
CMD:setname(playerid, params[])
{
if(aDuty[playerid] == 1)
if(PlayerInfo[playerid][pAdmin] >= 4)
{
new name[MAX_PLAYER_NAME],string1[128],query[128],q[128];
new targetid, inputtext[25];
if(sscanf(params, "u", targetid, inputtext)) return SendClientMessage(playerid, C_GREY, "USAGE: /setname [playerid] [new name]");
{
format(q,sizeof(q),"SELECT * FROM `accounts` WHERE user = '%s'",inputtext);
mysql_query(q);
mysql_store_result();
if(mysql_num_rows()>0)
{
SendClientMessage(playerid, C_RED,"SERVER: That name is already taken. Please choose another name.");
}
else
{
GetPlayerName(playerid, name, sizeof(name));
format(query, sizeof(query), "UPDATE `accounts` SET user ='%s' WHERE user ='%s'",inputtext,name);
mysql_query(query);
format(string1, sizeof(string1), "ADMIN: %s have changed your name to %s [Use this username while logging in next time].",Name(playerid), inputtext);
SendClientMessage(targetid, C_CYAN, string1);
SendClientMessage(playerid, C_YELLOW, "You have successfully changed the name!");
SetPlayerName(targetid, inputtext);
mysql_free_result();
}
}
} else return SendClientMessage(playerid, C_RED, "You are not authorized to use this command!");
return 1;
}