Posts: 296
Threads: 70
Joined: Aug 2012
Reputation:
0
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]
Posts: 1,052
Threads: 46
Joined: Jan 2010
Reputation:
0
You have to change the name in your database / user storage too.
Posts: 296
Threads: 70
Joined: Aug 2012
Reputation:
0
I want to change his name via a command without him/her loosing their status/data.
+Without clicking his .ini
Posts: 1,274
Threads: 54
Joined: Jul 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);
Posts: 1,052
Threads: 46
Joined: Jan 2010
Reputation:
0
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