CMD:changename is not working
#1

@guys, There is a problem in this cmd to pawn errors its just not working as exact as I want, all I wanted is to change user udb file name I mean his acc name without removing it or changing anything in it!
my cmd:
pawn Код:
CMD:changename(playerid,params[]) {
    if(PlayerInfo[playerid][Level] <= 5 || IsPlayerAdmin(playerid)) return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
    new tmp[128], tmp2[128], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
    if(isnull(tmp) || isnull(tmp2)) return SendClientMessage(playerid, red, "USAGE: /changename [playerid] [new name]");
    new player1 = strval(tmp), length = strlen(tmp2), string[128], file[256];
    if(length < 3 || length > MAX_PLAYER_NAME) return SendClientMessage(playerid,red,"ERROR: Incorrect Name Length");
    if(PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
    if(!IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) return SendClientMessage(playerid,red,"ERROR: Player is not connected");
    if(!udb_Exists(tmp2)){
        CMDMessageToAdmins(playerid,"CHANGENAME");
        format(string, sizeof(string), "You have set \"%s's\" name to \"%s\" ", pName(player1), tmp2); SendClientMessage(playerid,blue,string);
        SetPlayerName(player1, tmp2);
        OnPlayerConnect(player1);
        SaveToFile("NAMECHANGELOG ",string);
        format(file, sizeof(file), "/ladmin/users/%s.sav",pName(player1));
        udb_UserSet(file,"%s.sav",tmp2);
    } else return SendClientMessage(playerid,red, "ERROR: That name was already taken");
    return 1;}
regards!
Reply
#2

try this...

but this script is untested yet...

pawn Код:
CMD:changename(playerid,params[]) {
    if(PlayerInfo[playerid][Level] <= 5 || IsPlayerAdmin(playerid)) return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
    new tmp[128], tmp2[128], Index;
    if(sscanf(params,"is[128]",tmp,tmp2)) return SendClientMessage(playerid, red, "USAGE: /changename [playerid] [new name]");
    new length = strlen(tmp2), string[128], file[256], file2[256];
    if(length < 3 || length > MAX_PLAYER_NAME) return SendClientMessage(playerid,red,"ERROR: Incorrect Name Length");
    if(PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
    if(!IsPlayerConnected(tmp) || tmp != INVALID_PLAYER_ID) return SendClientMessage(playerid,red,"ERROR: Player is not connected");
    format(file, sizeof(file), "/ladmin/users/%s.sav",pName(tmp));
    format(file2, sizeof(file2), "/ladmin/users/%s.sav",pName(tmp2));
    if(!udb_Exists(file2)){
        CMDMessageToAdmins(playerid,"CHANGENAME");
        format(string, sizeof(string), "You have set \"%s's\" name to \"%s\" ", pName(tmp), tmp2); SendClientMessage(playerid,blue,string);
        SetPlayerName(tmp, tmp2);
        OnPlayerConnect(tmp);
        SaveToFile("NAMECHANGELOG ",string);
        udb_UserSet(file,"%s.sav",tmp2);
    } else return SendClientMessage(playerid,red, "ERROR: That name was already taken");
    return 1;
}
Reply
#3

Hmm, this?
pawn Код:
CMD:changename(playerid,params[]) {
    if(PlayerInfo[playerid][Level] <= 5 || IsPlayerAdmin(playerid)) return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
    new tmp[128], tmp2[128], Index;
    if(sscanf(params,"is[128]",tmp,tmp2)) return SendClientMessage(playerid, red, "USAGE: /changename [playerid] [new name]");
    new length = strlen(tmp2), string[128], file[256], file2[256];
    if(length < 3 || length > MAX_PLAYER_NAME) return SendClientMessage(playerid,red,"ERROR: Incorrect Name Length");
    if(PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
    if(!IsPlayerConnected(tmp) || tmp != INVALID_PLAYER_ID) return SendClientMessage(playerid,red,"ERROR: Player is not connected");
    format(file, sizeof(file), "/ladmin/users/%s.sav",pName(tmp));
    format(file2, sizeof(file2), "/ladmin/users/%s.sav",pName(tmp2));
    if(!udb_Exists(file2)){
        CMDMessageToAdmins(playerid,"CHANGENAME");
        format(string, sizeof(string), "You have set \"%s's\" name to \"%s\" ", pName(tmp), tmp2); SendClientMessage(playerid,blue,string);
        SetPlayerName(tmp, tmp2);
        OnPlayerConnect(tmp);
        SaveToFile("NAMECHANGELOG ",string);
        udb_RenameUser(pName(tmp),tmp2);
    } else return SendClientMessage(playerid,red, "ERROR: That name was already taken");
    return 1;
}
Reply
#4

PHP код:
D:\desktop files\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(9647) : error 017undefined symbol "player1"
D:\desktop files\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(9648) : error 035argument type mismatch (argument 1)
D:\desktop files\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(9649) : error 035argument type mismatch (argument 1)
D:\desktop files\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(9650) : error 035argument type mismatch (argument 1)
D:\desktop files\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(9653) : error 035argument type mismatch (argument 1)
D:\desktop files\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(9655) : error 035argument type mismatch (argument 1)
D:\desktop files\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(9656) : error 035argument type mismatch (argument 1)
D:\desktop files\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(9658) : error 017undefined symbol "udb_RenameUser"
D:\desktop files\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(9643) : warning 203symbol is never used"Index"
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
8 Errors

wow !!!
Reply
#5

bump*
Reply
#6

I updated it but still not working!
pawn Код:
CMD:changename(playerid,params[]) {
    if(PlayerInfo[playerid][Level] >= 5 || IsPlayerAdmin(playerid)) {
        new tmp[128], tmp2[128], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
        if(isnull(tmp) || isnull(tmp2)) return SendClientMessage(playerid, red, "USAGE: /changename [playerid] [new user name]");
        new player1 = strval(tmp), length = strlen(tmp2), string[128];
        if(length < 3 || length > MAX_PLAYER_NAME) return SendClientMessage(playerid,red,"ERROR: Incorrect Name Length");
        if(PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
        if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
            if(!udb_Exists(tmp2)) {
                CMDMessageToAdmins(playerid,"CHANGENAME");
                format(string, sizeof(string), "You have changed \"%s's\" account name to \"%s\" ", pName(player1), tmp2);
                SendClientMessage(playerid,blue,string);
                SetPlayerName(player1, tmp2);
                udb_RenameUser(pName(player1), tmp2);
                return OnPlayerConnect(player1);
            } else return SendClientMessage(playerid,red,"ERROR: That name had been already taken choose another one");
        } else return SendClientMessage(playerid,red,"ERROR: Player is not connected");
    } else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");}
Reply
#7

that cmd scrawled my life, I got more errors.
Reply
#8

show us the errors dude !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)