SA-MP Forums Archive
Setskin Command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Setskin Command (/showthread.php?tid=273278)



Setskin Command - Dr - 01.08.2011

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...


Re: Setskin Command - Kingunit - 01.08.2011

Other commands works fine on your server?


Re: Setskin Command - Dr - 01.08.2011

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.


Re: Setskin Command - Famalamalam - 01.08.2011

Do you get any errors in the console?


Re: Setskin Command - Ironboy - 01.08.2011

You are using LuxAdmin system? or..


Re: Setskin Command - iggy1 - 01.08.2011

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


Re: Setskin Command - Dr - 01.08.2011

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.


Re: Setskin Command - AndreT - 01.08.2011

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;
}



Re: Setskin Command - Dr - 01.08.2011

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...


Re: Setskin Command - AndreT - 01.08.2011

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.


Re: Setskin Command - Dr - 01.08.2011

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


Re: Setskin Command - Dr - 01.08.2011

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.


Re: Setskin Command - =WoR=Varth - 02.08.2011

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/


Re: Setskin Command - Dr - 02.08.2011

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


Re: Setskin Command - =WoR=Varth - 02.08.2011

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