16.10.2013, 22:32
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
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;
}
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 ;)