18.01.2012, 21:47
Well, when i try to change my name it doesn't work properly. In database the name it change to this character я.
And it doesn't set the players name.
And it doesn't set the players name.
PHP код:
CMD:changename(playerid, params[])
{
new newname[24];
if(sscanf(params, "u[24]",newname))return SendClientMessage(playerid,COLOR_LIGHTBLUE,"USAGE: {FFFFFF}/changename [New Name]");
GetPlayerName(playerid,pname,24);
new query1[256],escapename[24];
mysql_real_escape_string(newname, escapename);
format(query1, sizeof(query1), "SELECT `user` FROM `playerdata` WHERE `user` = '%s'", escapename);
mysql_query(query1);
mysql_store_result();
new rows = mysql_num_rows();
if(!rows)
{
new query[256];
format(query, sizeof(query), "UPDATE `playerdata` SET `user`= '%s' WHERE `user` ='%s'",escapename,pname);
mysql_query(query);
SetPlayerName(playerid ,params);
format(mystring, sizeof(mystring),"%s has changed hes name into %s", pname, params);
SendClientMessageToAll(COLOR_WHITE, mystring);
}
else if(rows == 1)
{
SendClientMessage(playerid, 0xFF0000FF, "This name already exists!");
}
mysql_free_result();
return 1;
}