PDA

View Full Version : Change name mysql


Bogdan1992
18/01/2012, 10:47 PM
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.
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;
}

2KY
18/01/2012, 10:52 PM
SetPlayerName(playerid ,params);

That's your problem, find everywhere "params" is used, and replace it with "newname".

Bogdan1992
18/01/2012, 10:55 PM
Anyway i really don't care about that , the real problem is that it changes the name into this "" in database.

Jefff
18/01/2012, 11:03 PM
field user must be a text in database

Bogdan1992
18/01/2012, 11:07 PM
Type | Collation
varchar(24) | utf8_unicode_ci
I have this on database.

Jefff
18/01/2012, 11:12 PM
eh :D replace u[24] to s[24]

Bogdan1992
18/01/2012, 11:14 PM
Auuuu, yeh, I'm such an idiot xD, Thanks.