how to change player name on game, i use dini for saving
#1

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
Reply
#2

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;
}
Reply
#3

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)