command for /changename?
#2

Use the function SetPlayerName to change a user's name when they are currently in game.
As for detecting if the username is already taken, format the path of the new name and use fexist to determine if it's taken or not.
(If your using MySQL, fexist will not work obviously). If the user's file currently exists and they are registered, you can use this custom stock function:


pawn Code:
stock frename(oldname[], newname[])
{
    if(!fexist(oldname)) return false;
    new string[128], File:old, File:neww;
    old = fopen(oldname, io_read);
    neww = fopen(newname, io_write);
    while(fread(old, string))
    {
        StripNewLine(string);
        format(string, sizeof(string), "%s\r\n", string);
        fwrite(neww, string);
    }
    fclose(old);
    fclose(neww);
    fremove(oldname);
    return true;
}
To modify and re-name their userfile to the new username.
Reply


Messages In This Thread
command for /changename? - by .v - 25.09.2012, 10:54
Re: command for /changename? - by West X - 26.09.2012, 22:04
Re: command for /changename? - by .v - 26.09.2012, 23:53
Re: command for /changename? - by West X - 27.09.2012, 00:27
Re: command for /changename? - by .v - 27.09.2012, 00:59
Re: command for /changename? - by West X - 27.09.2012, 01:06
Re: command for /changename? - by .v - 27.09.2012, 01:17
Re: command for /changename? - by West X - 27.09.2012, 01:22
Re: command for /changename? - by .v - 27.09.2012, 01:25
Re: command for /changename? - by West X - 27.09.2012, 01:33

Forum Jump:


Users browsing this thread: 1 Guest(s)