SA-MP Forums Archive
Making commands to change skin, etc - 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)
+--- Thread: Making commands to change skin, etc (/showthread.php?tid=332963)



Making commands to change skin, etc - Trekkx - 09.04.2012

Basically, what I'd like to know is how do you make commands that set skin etc..
Now, I know you could do like ...

if (strcmp("/myskin", cmdtext, true) == 0)
{
SetPlayerSkin(playerid,186);
return 1;
}

And its changes skin, but I want to know how to make a command that would be something like

/skin [id]

And the skin changes to whatever ID they specify.

I realize this is possible if you just did a command over and over for /skin 1, /skin 2 etc but I want a cleaner and easier way of doing that but I've got no idea how and I need help.

I'd also like to know how to do this for more things, such as weapons and vehicles and so on.

Any help would be greatly appreciated.
(Sorry if this was posted in the wrong place, I just really need help with this :P)


Re: Making commands to change skin, etc - Jack.7331 - 09.04.2012

If you use sscanf and zcmd, I can do this.
I'd recommend using it, as it's easier for beginners.

pawn Код:
CMD:skin(playerid, params[])
{
    new
        skinid,
        msg[80];

    if(sscanf(params, "d", skinid))return SendClientMessage(playerid, COLOR_GREY, "USAGE: /skin [skinid]");
   
    else if(!IsValidSkin(skinid)) return SendClientMessage(playerid, COLOR_GREY, "Invalid Skin ID!");
   
    else if(IsValidSkin(skinid)) {
    SetPlayerSkin(playerid, skinid);
    format(msg, sizeof(msg), "You have changed your skin to skin ID %i.", skinid);
    SendClientMessage(playerid, COLOR_GREY, msg);
    }
    return 1;
}



Re: Making commands to change skin, etc - .FuneraL. - 09.04.2012

pawn Код:
if(strcmp("/skin 1", cmdtext ,true) == 0)
{
    SetPlayerSkin(playerid, 1);
    return 1;
}
Simple Command Example!


Re: Making commands to change skin, etc - Trekkx - 09.04.2012

C:\Users\Josh\Documents\GTA San Andreas User Files\Testing Server\gamemodes\testing.pwn(551) : error 029: invalid expression, assumed zero
C:\Users\Josh\Documents\GTA San Andreas User Files\Testing Server\gamemodes\testing.pwn(551) : error 017: undefined symbol "cmd_skin"
C:\Users\Josh\Documents\GTA San Andreas User Files\Testing Server\gamemodes\testing.pwn(551) : error 029: invalid expression, assumed zero
C:\Users\Josh\Documents\GTA San Andreas User Files\Testing Server\gamemodes\testing.pwn(551) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

That is the error I get when I try to use that code. Line 551 is
CMDkin(playerid, params[])


Re: Making commands to change skin, etc - Trekkx - 09.04.2012

Quote:
Originally Posted by .FuneraL.
Посмотреть сообщение
pawn Код:
if(strcmp("/skin 1", cmdtext ,true) == 0)
{
    SetPlayerSkin(playerid, 1);
    return 1;
}
Simple Command Example!
Thanks, but thats what I knew how to do; what I'm aiming to do is have it so they can type any ID they want into /skin and it'll change it to that.

I could easily do commands for /skin 1, /skin 2, /skin 3 and so on but that'd take forever. I'm looking at achieveing it was a single command.

I have zcmd and sscanf ready.


Re: Making commands to change skin, etc - Onyx - 09.04.2012

pawn Код:
COMMAND:skin(playerid, params[])
{
    new skinid, string[128];
    if(sscanf(params, "d", skinid))
    {
        SendClientMessage(playerid, COLOR, "Syntax: /skin [skinID].");
    }
    else
    {
        if(skinid > 299 || skinid < 0)
        {
            SendClientMessage(playerid, COLOR, "Error: Invalid skin ID.");
        }
        else
        {
            SetPlayerSkin(playerid, skinid);
            format(string, sizeof(string), "Info: You have changed your skin to %d.", skinid);
            SendClientMessage(playerid, COLOR, string);
        }
    }
    return 1;
}



Re: Making commands to change skin, etc - Jack.7331 - 09.04.2012

Onyx, that wouldn't necessarily work, because there isn't a skin for every number from 0 to 299.


Re: Making commands to change skin, etc - Toreno - 09.04.2012

Go down, and see my next post with the correct command.


Re: Making commands to change skin, etc - WarriorEd22 - 09.04.2012

If you want people to change their skins after death, just press F4


Re: Making commands to change skin, etc - Toreno - 09.04.2012

Quote:
Originally Posted by Jack.7331
Посмотреть сообщение
Onyx, that wouldn't necessarily work, because there isn't a skin for every number from 0 to 299.
"These skins (3, 4, 5, 6, 8, 42, 65, 86, 119, 149, 208, 273, 289) were added in SA-MP 0.3d RC5 and will not work in earlier versions!"

But, there is only one skin which is still, not exist.

pawn Код:
CMD:skin(playerid, params[])
{
    new
        skinid,
        a_string[65]
    ;

    if(sscanf(params, "i", skinid))
    {
        return SendClientMessage(playerid, -1, "USAGE: /skin [skinid]");
    }

    if(skinid > 299 || skinid < 0 || skinid == 74)
    {
        return SendClientMessage(playerid, -1, "Invalid skin ID.");
    }

    SetPlayerSkin(playerid, skinid);
    format(a_string, 65, "You've changed your skin to ID %i.", skinid);
    SendClientMessage(playerid, -1, a_string);

    return 1;
}