how to change player name on game, i use dini for saving - 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 to change player name on game, i use dini for saving (
/showthread.php?tid=470237)
how to change player name on game, i use dini for saving -
Chrisli520 - 16.10.2013
as i said, i want player type /changename to change their name ongame, and the .txt file of that player will change too. i save at LARP/Users/%s.txt
Re: how to change player name on game, i use dini for saving -
tyler12 - 16.10.2013
pawn Code:
stock frename(oldname[], newname[])
{
if (!fexist(oldname)) return 0;
new File:oldfile = fopen(oldname, io_read);
new File:newfile = fopen(newname, io_write);
new line[256];
while (fread(oldfile, line))
{
fwrite(newfile, line);
}
fclose(oldfile);
fclose(newfile);
fremove(oldname);
return 1;
}
Re: how to change player name on game, i use dini for saving -
Juniiro3 - 16.10.2013
pawn Code:
CMD:changename ( playerid , params [ ] )
{
new newName [ MAX_PLAYER_NAME ];
if ( sscanf ( params , "s[24]" , newName ) )
return SendClientMessage ( playerid , 0xFF0000FF , "[ERROR] Use /changename [ new Name ]" );
SetPlayerName ( playerid , newName );
return 1;
}
//OnPlayerDisconnect
if ( !fexists ( "LARP/Users/%s.txt" ) ) //format your string to do it
fcreate ( "LARP/Users/%s.txt");
//Now, save player account in the new directory ;)
A base to make your command