[Tutorial] Making a command "/skin [ID]" [ZCMD + SSCANF]
#3

Nice to see this as your first tutorial. Although I noticed some mistakes, but since this is your first I won't be that rude.
The "new's" are actually called variables. Just to mention it.
And the 6c. is a bit incorrect.
Quote:

Explanation: We're not using SendClientMessage because it contains a string (%d), we must convert the string before we go on to our SendClientMessage!

Actaully it doesn't contain a string, but an integer. (Correct me if i'm wrong )
But don't take it so badly .

Almost forgot it, one more thing that the last why do you have:

pawn Код:
else
    {
        SetPlayerSkin(playerid, skinid);
        skinnumber = GetPlayerSkin(playerid);
        format(string, sizeof(string), "{ffff00}=INFO=: {ffffff}You have changed your skin to %d", skinnumber);
        SendClientMessage(playerid, -1, string);
    }
In my opinion i don't see why you wanted to add the else statement, but (not sure about this) you could just have removed it. It is actually hard to explain in words so i'll just show you the way I would have done this command.

YOURS:
pawn Код:
CMD:skin(playerid,params[])
{
    new skinnumber, skinid, string[128];
    if(sscanf(params, "d", skinid)) SendClientMessage(playerid, -1, "{ffff00}=USAGE=: {ffffff}/skin <skinid>");
    else if(skinid < 0 || skinid > 299) SendClientMessage(playerid, 0xFF000000, "{ff0000}=ERROR=: {ffffff}Choose a skin between 0 to 299!");
    else
    {
        SetPlayerSkin(playerid, skinid);
        skinnumber = GetPlayerSkin(playerid);
        format(string, sizeof(string), "{ffff00}=INFO=: {ffffff}You have changed your skin to %d", skinnumber);
        SendClientMessage(playerid, -1, string);
    }
    return 1;
}
MINE:
pawn Код:
CMD:skin(playerid,params[])
{
    new skinnumber, skinid, string[128];
    if(sscanf(params, "d", skinid)) return SendClientMessage(playerid, -1, "{ffff00}=USAGE=: {ffffff}/skin <skinid>");
    if(skinid < 0 || skinid > 299) return SendClientMessage(playerid, 0xFF000000, "{ff0000}=ERROR=: {ffffff}Choose a skin between 0 to 299!");
    SetPlayerSkin(playerid, skinid);
    skinnumber = GetPlayerSkin(playerid);
    format(string, sizeof(string), "{ffff00}=INFO=: {ffffff}You have changed your skin to %d", skinnumber);
    SendClientMessage(playerid, -1, string);
    return 1;
}
It's actually pretty similar to yours, but still a bit different.

Anyway my conclusion would be nice tutorial! Just gonna 'hit' the star today
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)