[Help] /Skin command
#1

Код:
    if (strcmp("/skin", cmdtext, true, 10) == 0)
    {
        IsPlayerInRangeOfPoint(playerid,10,198.9780,-127.8640,1003.5152);
        new tmp[256];
        tmp = strtok ( cmdtext, idx );
        if ( !strlen ( tmp ) )
        {
            SendClientMessage(playerid, COLOR_RED, "USAGE: /skin [ID]");
            return 1;
  }
        SetPlayerSkin(playerid, strval(tmp));
        // Do something here
        return 1;
    }
What am I doing wrong there? I want it so that if the player is on that point or coords it would let him do the /skin command and if he isnt it would tell him you must be in the clothes store! Please Help .
Reply
#2

pawn Код:
if(strcmp("/skin", cmdtext, true, 10) == 0)
{
    if(IsPlayerInRangeOfPoint(playerid,10,198.9780,-127.8640,1003.5152))
    {
        new tmp[256];
        tmp = strtok (cmdtext, idx);

        if(!strlen(tmp)) SendClientMessage(playerid, COLOR_RED, "USAGE: /skin [ID]");
        else SetPlayerSkin(playerid, strval(tmp));
    }
    else SendClientMessage(playerid, COLOR_RED, "You must be in the clothing store.");
    return 1;
}

I'd suggest that you add a few more checks to make sure the skin can be set, as there are some invalid skin IDs.
Reply
#3

Umm how can I do that can you give me a example ? Im kinda new to scripting srry.
Reply
#4

pawn Код:
if(strcmp("/skin", cmdtext, true, 10) == 0)
{
    if(IsPlayerInRangeOfPoint(playerid,10,198.9780,-127.8640,1003.5152))
    {
        new tmp[128];
        tmp = strtok (cmdtext, idx);

        if(!strlen(tmp)) SendClientMessage(playerid, COLOR_RED, "USAGE: /skin [ID]");
        else if(!IsValidSkin(strval(tmp))) SendClientMessage(playerid, COLOR_RED, "Invalid Skin ID.");
        else SetPlayerSkin(playerid, strval(tmp));
    }
    else SendClientMessage(playerid, COLOR_RED, "You must be in the clothing store.");
    return 1;
}

stock IsValidSkin(skinid) // place this somewhere in your script, make sure it's not in any other code brackets {}
{
    #define MAX_BAD_SKINS   22

    new badSkins[MAX_BAD_SKINS] =
    {
        3, 4, 5, 6, 8, 42, 65, 74, 86,
        119, 149, 208, 265, 266, 267,
        268, 269, 270, 271, 272, 273, 289
    };

    if(skinid < 0 || skinid > 299) return false;
   
    for(new i = 0; i < MAX_BAD_SKINS; i++)
    {
        if(skinid == badSkins[i]) return false;
    }

    #undef MAX_BAD_SKINS
    return true;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)