command for /changename?
#3

Quote:
Originally Posted by West X
View Post
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.
Thanks for this man.. But how could I start the command for change name?

Like this?

pawn Code:
CMD:changename(playerid,params[])
{
        SendClientMessage(playerid, white, "{FFFF00}Usage: /changename [NewName]");
        if(length < 3 || length > MAX_PLAYER_NAME) return SendClientMessage(playerid,white,"{FF0000}>> Incorrect Name Length");
        new string[64];
        format(string,sizeof(string),"Your have been changed your current Name to %s, ", tmp);
        SendClientMessage(playerid, LIGHTBLUE, string);
        SetPlayerName(playerid, );
        return OnPlayerConnect(playerid);
}
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: 3 Guest(s)