How? - 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: How? (
/showthread.php?tid=372294)
How? -
Johnson_Brooks - 26.08.2012
How can i change a player's name without him/her losing his/her current data/stats?
e.g
/ask Can u change my name to Pig99?
*[Question]Horse99:Can u change my name to Pig99?(my /ask command shows the question to the online admins)
So /changename [playerid] [New Name]
Re: How? -
ikkentim - 26.08.2012
You have to change the name in your database / user storage too.
Re: How? -
Johnson_Brooks - 26.08.2012
I want to change his name via a command without him/her loosing their status/data.
+Without clicking his .ini
Re: How? -
Akira297 - 26.08.2012
I'm busy IRL < Take these basically all you need
Код:
new string[128], giveplayerid;
new playername[MAX_PLAYER_NAME];
SetPlayerName(giveplayerid, newname);
OnPlayerStatsUpdate(giveplayerid);
format(newname, sizeof(newname), "users/%s.ini", playername);
fremove(newname);
if(doesAccountExist(playername)) // If it doesn't get removed, blank the file with write io and check its length when a player attempts to authenticate (it'll be 0)
{
new File: BlankTheFile = fopen(newname, io_write);
SendClientMessageEx(playerid, COLOR_GRAD2, "The old account couldn't be removed completely (it's been blanked for future use).");
fclose(BlankTheFile);
Re: How? -
ikkentim - 26.08.2012
Change the filename of the .ini within your script.
Since frename doesnt exist, use both fwrite and fread.
fread the old user file and fwrite the new user file. Afterwards delete the old one.
See the wiki for reference about fread and fwrite
Re: How? -
UnknownGamer - 26.08.2012
----------------------
Re: How? -
Johnson_Brooks - 26.08.2012
Thank you all .
Akira <3