command for /changename?
#7

Quote:
Originally Posted by West X
View Post
Here is the fix:

pawn Code:
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_WHITE 0xFFFFFFAA

CMD:changename(playerid, params[])
{
    new newname[MAX_PLAYER_NAME], file1[128], file2[128];
    if(sscanf(params, "s[24]", newname)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /changename [New Username]");
    if(strlen(newname) < 3 || strlen(newname) > MAX_PLAYER_NAME) return SendClientMessage(playerid, COLOR_GREY, "Invalid username length.");
    format(file2, sizeof(file2), "/Users/%s.ini", newname);
    if(fexist(file2)) return SendClientMessage(playerid, COLOR_GREY, "The specified username is already taken.");
    format(file1, sizeof(file1), "/Users/%s.ini", pName(playerid));
    format(file2, sizeof(file2), "/Users/%s.ini", newname);
    frename(file1, file2);
    SetPlayerName(playerid, newname);
    format(file1, sizeof(file1), "You have changed your name to %s.", newname);
    SendClientMessage(playerid, COLOR_WHITE, file1);
    return 1;
}
You will also need this stock function:

pawn Code:
stock StripNewLine(string[])
{
    new len = strlen(string);
    if(string[0] == 0) return;
    if((string[len - 1] == '\n') || (string[len - 1] == '\r'))
    {
        string[len - 1] = 0;
        if(string[0]==0) return ;
        if((string[len - 2] == '\n') || (string[len - 2] == '\r')) string[len - 2] = 0;
    }
}
Thanks +rep it's all working now. Also it deletes the old account and replaced it with the new one and that is great! And lastly could you help me with Unban command? just like changename command.
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)