Setskin Command
#1

The command:
pawn Код:
CMD:setskin(playerid, params[])
{
    new Player, Skinid;
    if (sscanf(params, "ui", Player, Skinid))
    {
        SendClientMessage(playerid, COLOR_GREY, "[Command Usage]: /setskin [PlayerID or Name] [SkinID]");
    }
    else if (Player == INVALID_PLAYER_ID)
    {
        SendClientMessage(playerid, COLOR_GREY, "Invalid player name or id entered!");
    }
    else
    {
        if(IsPlayerConnected(playerid) && IsPlayerConnected(Player))
        {
            if(gPlayerLogged[playerid] == 1)
            {
                if(PlayerInfo[playerid][pAdminLevel] > 0)
                {
                    if(AdminDuty[playerid] == 1)
                    {
                        new playername[MAX_PLAYER_NAME], playername2[MAX_PLAYER_NAME], string[256], string2[256];
                        GetPlayerName(playerid, playername, sizeof(playername));
                        GetPlayerName(Player, playername2, sizeof(playername2));
                        format(string, sizeof(string), "Your skin has been set to %i by %s", Skinid, playername);
                        SendClientMessage(Player, COLOR_YELLOW, string);
                        format(string2, sizeof(string2), "You have set %s's skin to %i", playername2, Skinid);
                        SendClientMessage(playerid, COLOR_YELLOW, string2);
                        SetPlayerSkin(Player, Skinid);
                        PlayerInfo[Player][pSkin] = Skinid;
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GREY, "You must be on duty to perform this command");
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "You must be a moderator/administrator to perform this command");
                }
            }
        }
    }
    return 1;
}
I get no errors, but in game nothing happens, I made sure we were both logged in and connected, and I was on admin duty... Nothing happens no string no nothing... And the player doesn't get their skin set by the admin... Why is this? I get no errors...
Reply
#2

Other commands works fine on your server?
Reply
#3

Yeah others work fine, even the admin ones... It is just this one, not even sure why, cant seem to see anything wrong with it.
Reply
#4

Do you get any errors in the console?
Reply
#5

You are using LuxAdmin system? or..
Reply
#6

Because you don't get any messages i think this var may be your problem "gPlayerLogged[playerid]" simply because it has no matching "else" statement. Neither does your connection check so you may also want to add an else statement to that (with messages/prints inside).

BTW, there is no need to check if "playerid" is connected because a player cannot enter a command if he/she is not connected
Reply
#7

Okay so I changed the command to this:
pawn Код:
CMD:setskin(playerid, params[])
{
    new Player, Skinid;
    if (sscanf(params, "ui", Player, Skinid))
    {
        SendClientMessage(playerid, COLOR_GREY, "[Command Usage]: /setskin [PlayerID or Name] [SkinID]");
    }
    else if (Player == INVALID_PLAYER_ID)
    {
        SendClientMessage(playerid, COLOR_GREY, "Invalid player name or id entered!");
    }
    else if(PlayerInfo[playerid][pAdminLevel] < 1)
    {
        SendClientMessage(playerid, COLOR_GREY, "You must be a administrator or moderator to use this command");
    }
    else if(AdminDuty[playerid] < 1)
    {
        SendClientMessage(playerid, COLOR_GREY, "You must be on duty to perform this command");
    }
    else
    {
        new string[256], string2[256];
        format(string, sizeof(string), "Your skin has been set to %i by %s", Skinid, GetPlayerNameEx(playerid));
        SendClientMessage(Player, COLOR_YELLOW, string);
        format(string2, sizeof(string2), "You have set %s's skin to %i", GetPlayerNameEx(Player), Skinid);
        SendClientMessage(playerid, COLOR_YELLOW, string2);
        SetPlayerSkin(Player, Skinid);
        PlayerInfo[Player][pSkin] = Skinid;
    }
    return 1;
}
Again I get no errors, but in game it does nothing... You type it on a player and their skin is not changed.
Reply
#8

I cannot tell you exactly what the error is, but some tips for your code:
1. Don't call sscanf when you're not sure if the result is going to be used. Run the pAdminLevel and AdminDuty checks before using sscanf.
2. No need to create another string if you're going to send 2 messages in a row. Just use the 1st string when formatting the second message.
pawn Код:
CMD:setskin(playerid, params[])
{
    if(!PlayerInfo[playerid][pAdminLevel])
        return SendClientMessage(playerid, COLOR_GREY, "You must be a administrator or moderator to use this command"), true;
    if(AdminDuty[playerid] < 1)
        return SendClientMessage(playerid, COLOR_GREY, "You must be on duty to perform this command"), true;
   
    new Player, Skinid;
    if(sscanf(params, "ui", Player, Skinid))
        return SendClientMessage(playerid, COLOR_GREY, "[Command Usage]: /setskin [PlayerID or Name] [SkinID]"), true;
    if(Player == INVALID_PLAYER_ID)
        return SendClientMessage(playerid, COLOR_GREY, "Invalid player name or id entered!"), true;

    new string[128];
    format(string, sizeof(string), "Your skin has been set to %i by %s", Skinid, GetPlayerNameEx(playerid));
    SendClientMessage(Player, COLOR_YELLOW, string);
    format(string, sizeof(string), "You have set %s's skin to %i", GetPlayerNameEx(Player), Skinid);
    SendClientMessage(playerid, COLOR_YELLOW, string);
    SetPlayerSkin(Player, Skinid);
    PlayerInfo[Player][pSkin] = Skinid;
    return true;
}
Reply
#9

Okay changed it to this:

pawn Код:
CMD:setskin(playerid, params[])
{
    if(PlayerInfo[playerid][pAdminLevel] >= 1)
    {
        if(AdminDuty[playerid] >= 1)
        {
            new Player, Skinid;
            if (sscanf(params, "ui", Player, Skinid))
            {
                SendClientMessage(playerid, COLOR_GREY, "[Command Usage]: /setskin [PlayerID or Name] [SkinID]");
            }
            else if (Player == INVALID_PLAYER_ID)
            {
                SendClientMessage(playerid, COLOR_GREY, "Invalid player name or id entered!");
            }
            else
            {
                new string[256];
                format(string, sizeof(string), "Your skin has been set to %i by %s", Skinid, GetPlayerNameEx(playerid));
                SendClientMessage(Player, COLOR_YELLOW, string);
                format(string, sizeof(string), "You have set %s's skin to %i", GetPlayerNameEx(Player), Skinid);
                SendClientMessage(playerid, COLOR_YELLOW, string);
                SetPlayerSkin(Player, Skinid);
                PlayerInfo[Player][pSkin] = Skinid;
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "You must be on duty to perform this command");
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_GREY, "You must be a administrator or moderator to use this command");
    }
    return 1;
}
Again no errors, but now this happens:


But the player's skin still DOES NOT change...
Reply
#10

What server version are you using? If anything above 0.3c R2, then have you updated sscanf 2.0 to the custom compiled one by Zeex?

Add a small debug before your messages:
pawn Код:
printf("Player -> %d", Player);
to see what it gives.
Reply
#11

I have not updated it to the custom compiled one by zeex, where can I get it?
Reply
#12

Bump, it might have to do with sscanf.. Since the Player, is not getting anything and their name is not showing but the playerid is showing... Why is this? Please someone help me out.
Reply
#13

Quote:
Originally Posted by Dr
Посмотреть сообщение
I have not updated it to the custom compiled one by zeex, where can I get it?
http://solidfiles.com/d/329c7/
Reply
#14

Same result, no errors, but in game it does not set the player's skin... Anyone please help me?
Reply
#15

Use "d" instead "u" and see what happen.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)