[HELP]Change Name. - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP]Change Name. (
/showthread.php?tid=208806)
[HELP]Change Name. -
GaB1TzZzu - 09.01.2011
I have this command:
Код:
if(strcmp(cmd, "/changename", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "[USAGE]: /changename [id] [newname]");
return 1;
}
giveplayerid = ReturnUser(tmp);
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
if (PlayerInfo[playerid][pAdmin] >= 4)
{
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GRAD2, "[USAGE]: /changename [id] [newname]");
return 1;
}
SetPlayerName(giveplayerid, (result));
return 1;
}
}
}
}
return 1;
}
But is a problem, after relog, or server restart, the new name doesn't save in MySQL. How can i save the new name in MySQL DataBase?
Re: [HELP]Change Name. -
Ash. - 09.01.2011
Its not that it doesnt save, but surely you will have to change your name on the client aswell, as that is what you connect with and initialize the game with.
Re: [HELP]Change Name. -
GaB1TzZzu - 09.01.2011
Yes, but i want to save the name.. How can i do? I need a function .. something like MysqlAccountUpdate().. I don`t know
Re: [HELP]Change Name. -
GaB1TzZzu - 09.01.2011
Someone ..?
Re: [HELP]Change Name. -
GaB1TzZzu - 10.01.2011
Helppp xD.
Re: [HELP]Change Name. -
GaB1TzZzu - 11.01.2011
Help me xD.
Re: [HELP]Change Name. -
Yvax - 11.01.2011
Just use mysql query:"UPDATE players SET Username='%s' where ID=%d",VARIABLE_WHERE_THE_NEW_NAME_IS_SAVED, SQL_ID
Re: [HELP]Change Name. -
Rizard - 11.01.2011
srsly dude, you are having this one command while you clearly don't know anything about mysql... do you even have a database? do you even have a plugin? is your gamemode mysql based and in order? if you do... you know how to update and process a mysql query...
http://forum.sa-mp.com/showthread.ph...ighlight=mysql
https://sampwiki.blast.hk/wiki/MySQL_Plugin
Re: [HELP]Change Name. -
_rAped - 11.01.2011
I don't know what database structure you are using but.
Add this before SetPlayerName():
pawn Код:
new
query[128];
format(query, sizeof(query), "UPDATE `players` SET `name` = '%s' WHERE `name` = '%s';", result, giveplayer);
mysql_query(query);
Change players, and name to whatever suits your structure.
Re: [HELP]Change Name. -
GaB1TzZzu - 11.01.2011
Quote:
Originally Posted by _rAped
I don't know what database structure you are using but.
Add this before SetPlayerName():
pawn Код:
new query[128]; format(query, sizeof(query), "UPDATE `players` SET `name` = '%s' WHERE `name` = '%s';", result, giveplayer); mysql_query(query);
Change players, and name to whatever suits your structure.
|
This is the correct form: samp_mysql_query(query);
RESOLVED !
Help me with these problems: https://sampforum.blast.hk/showthread.php?tid=208516&page=2
https://sampforum.blast.hk/showthread.php?tid=207996