Help with SetPlayerName
#1

Ok, I tried to make a SetPlayerName command using sscanf, but it gives me error argument type mismatch

pawn Код:
dcmd_setname(playerid, params[])
{
    new id, nombre;
    if(sscanf(params, "u,s", id, nombre)) SendClientMessage(playerid, COLOR_WHITE, "USO: /setname [id][nombre]");
    else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_GREY, "ID invбlida.");
    else
    {
        if(adminlevel[playerid] >= 1) return SendClientMessage(playerid, COLOR_GREY, "No tenes permiso para usar este comando!");
        {
            new name1[30];
            new name2[30];
            new string[128];
            GetPlayerName(playerid, name1, 30);
            GetPlayerName(id, name2, 30);
            printf("Administraciуn: %s ha cambiado el nombre de %s a %s", name1, name2, nombre);
            format(string, 128, "Administraciуn: %s ha cambiado el nombre de %s a %s", name1, name2, nombre);
            SendClientMessageToAll(ADMIN_RED, string);
            format(string, 128, "Administraciуn: %s te ha cambiado el nombre de %s a %s", name1, name2, nombre);
            SendClientMessage(id, ADMIN_RED, string);
            switch(SetPlayerName(id, nombre)) //This is the error line
             {
                 case -1: SendClientMessage(playerid, COLOR_GREY, "Ya hay otro usuario con ese nombre!");
                  case 0: SendClientMessage(playerid, COLOR_GREY, "Ya tiene ese nombre!");
                   case 1:
                {
                       new str[64];
                    format(str, 64, "Cambiastes el nombre de %s a %s", name2, nombre);
                       SendClientMessage(playerid, COLOR_WHITE, str);
                }
             }
        }
    }
    return 1;
}
Thanks.
Reply
#2

pawn Код:
if(sscanf(params, "u,s", id, nombre)) SendClientMessage(playerid, COLOR_WHITE, "USO: /setname [id][nombre]");
To:
pawn Код:
if(sscanf(params, "us", id, nombre)) SendClientMessage(playerid, COLOR_WHITE, "USO: /setname [id][nombre]");
Reply
#3

Quote:
Originally Posted by Seven.
Посмотреть сообщение
pawn Код:
if(sscanf(params, "u,s", id, nombre)) SendClientMessage(playerid, COLOR_WHITE, "USO: /setname [id][nombre]");
To:
pawn Код:
if(sscanf(params, "us", id, nombre)) SendClientMessage(playerid, COLOR_WHITE, "USO: /setname [id][nombre]");
Mh.. nop, still the same :S
Reply
#4

which line?
Reply
#5

On the first post is the error line, in the code.
Reply
#6

pawn Код:
new id, nombre[MAX_PLAYER_NAME];
Reply
#7

Quote:
Originally Posted by Cank
Посмотреть сообщение
pawn Код:
new id, nombre[MAX_PLAYER_NAME];
LOL yes, I forgot to put the variable size

Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)