Skins Arrays
#1

I was thinking if there is any way if I can change this long condition to a simple array:
pawn Код:
if(strval(inputtext) > -1 && strval(inputtext) < 300)
            {
                if(strval(inputtext) == 107||106||105||86||271||269||270||284||280||281||282||283||165||287||286||288||285) return SendClientMessage(playerid,COLOR_GREY,"This skin is used by a faction !");
                else
                {
                    SetPlayerSkin(playerid,strval(inputtext));
                    PlayerInfo[playerid][pClothes] = strval(inputtext);
                    PlayerInfo[playerid][pCash] -= 500;
                    new oldcash = GetPlayerMoney(playerid);
                    ResetPlayerMoney(playerid);
                    GivePlayerMoney(playerid, oldcash-500);
                    SendClientMessage(playerid,COLOR_YELLOW,"[Clothes]: You have changed your suit !");
                }
            }
To change into something like this:
pawn Код:
new Skins[][] = { 107,106,...285 }
if(strval(inputtext) > -1 && strval(inputtext) < 300)
            {
                if(strval(inputtext) == sizeof(Skins)) return SendClientMessage(playerid,COLOR_GREY,"This skin is used by a faction !");
                else
                {
                    SetPlayerSkin(playerid,strval(inputtext));
                    PlayerInfo[playerid][pClothes] = strval(inputtext);
                    PlayerInfo[playerid][pCash] -= 500;
                    new oldcash = GetPlayerMoney(playerid);
                    ResetPlayerMoney(playerid);
                    GivePlayerMoney(playerid, oldcash-500);
                    SendClientMessage(playerid,COLOR_YELLOW,"[Clothes]: You have changed your suit !");
                }
            }
Reply
#2

pawn Код:
IsFactionSkin(skin)
{
   switch(skin) { case 107,106,105,86,271,269,270,284,280,281,282,283,165,287,286,288,285: return 1; }
   return 0;
}
Reply
#3

ooh... this it's a good ideea too
tnx Pottus
Reply
#4

pawn Код:
IsFactionSkin(skin)
{
    switch(skin) { case 86, 105 .. 107, 165, 269 .. 271, 280 .. 288: return 1; }
    return 0;
}
Just to be a dick
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)