Trying to use multiple numbers in one value...
#1

So I've made a /skin command but I'm trying to restrict skins unless your an admin, it works but I can only do one skin at a time, I'm trying to do multiple skins at a time..
this is the code:
Код:
if(strcmp(cmd, "/skin", true) == 0)
	{
 	tmp = strtok(cmdtext, idx);
	if(!strlen(tmp))
	{
	 SendClientMessage(playerid, 0x919191FF, "Usage: /skin [SKINID]");
	 return 1;
	 }
	 if(PlayerInfo[playerid][pAdmin] < 1 && strval(tmp) == 280)
	 {
	 SendClientMessage(playerid,COLOR_YELLOW,"  You're not allowed to choose that skin!");
	 return 1;
	 }
	else if(IsAtClothShop(playerid) || PlayerInfo[playerid][pDonateRank] >= 1)
	{
 	new chosenskin = strval(tmp);
 	SetPlayerSkin(playerid, chosenskin);
 	PlayerInfo[playerid][pModel] = chosenskin;
 	return 1;
 	}
 	else {
 	SendClientMessage(playerid, COLOR_YELLOW, "  You are not inside a clothing store!");
 	}
 }
So if someone who isn't an admin types /skin 280 is says you're not allowed to choose that skin, but I want say 280, 281, 282 etc. to be restricted, but I'm not sure what method to use. I thought about "enums" but wasn't sure how I would.
Reply
#2

delete sorry
Reply
#3

pawn Код:
if(PlayerInfo[playerid][pAdmin] < 1 && strval(tmp) == 280)
to
pawn Код:
if(PlayerInfo[playerid][pAdmin] < 1 && strval(tmp) >= 280 || strval(tmp) <= 282)
Reply
#4

use a switch, something like this:
pawn Код:
switch(strval(tmp))
{
     case 280:
     {
          SendClientMessage(playerid, COLOR_YELLOW, "You're not allowed to use that skin!");
     }
}
Since you have more than one number, you can set all of them in a list, like this:
pawn Код:
case 250, 256,  270, 272, 278, 280:
Also, if the numbers are in order, you can do this:
pawn Код:
case 250..280: //will send the message for all skins between 250 and 280
Just put that under your Admin check
Reply
#5

Quote:
Originally Posted by randomkid88
Посмотреть сообщение
use a switch, something like this:
pawn Код:
switch(strval(tmp))
{
     case 280:
     {
          SendClientMessage(playerid, COLOR_YELLOW, "You're not allowed to use that skin!");
     }
}
Since you have more than one number, you can set all of them in a list, like this:
pawn Код:
case 250, 256,  270, 272, 278, 280:
Also, if the numbers are in order, you can do this:
pawn Код:
case 250..280: //will send the message for all skins between 250 and 280
Just put that under your Admin check
Where abouts would I place the switch?
Reply
#6

pawn Код:
if(strcmp(cmd, "/skin", true) == 0)
{
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
        SendClientMessage(playerid, 0x919191FF, "Usage: /skin [SKINID]");
        return 1;
    }
    if(PlayerInfo[playerid][pAdmin] < 1 )
    {
        switch(strval(tmp))
        {
            case 280:
            {
                //code
            }
        }
    }
    else if(IsAtClothShop(playerid) || PlayerInfo[playerid][pDonateRank] >= 1)
    {
        new chosenskin = strval(tmp);
        SetPlayerSkin(playerid, chosenskin);
        PlayerInfo[playerid][pModel] = chosenskin;
        return 1;
    }
    else {
    SendClientMessage(playerid, COLOR_YELLOW, "  You are not inside a clothing store!");
    }
    return 1;
}
Reply
#7

Quote:
Originally Posted by randomkid88
Посмотреть сообщение
pawn Код:
if(strcmp(cmd, "/skin", true) == 0)
{
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
        SendClientMessage(playerid, 0x919191FF, "Usage: /skin [SKINID]");
        return 1;
    }
    if(PlayerInfo[playerid][pAdmin] < 1 )
    {
        switch(strval(tmp))
        {
            case 280:
            {
                //code
            }
        }
    }
    else if(IsAtClothShop(playerid) || PlayerInfo[playerid][pDonateRank] >= 1)
    {
        new chosenskin = strval(tmp);
        SetPlayerSkin(playerid, chosenskin);
        PlayerInfo[playerid][pModel] = chosenskin;
        return 1;
    }
    else {
    SendClientMessage(playerid, COLOR_YELLOW, "  You are not inside a clothing store!");
    }
    return 1;
}
It doesn't work, I have:
Код:
if(strcmp(cmd, "/skin", true) == 0)
	{
 	tmp = strtok(cmdtext, idx);
	if(!strlen(tmp))
	{
	 SendClientMessage(playerid, 0x919191FF, "Usage: /skin [SKINID]");
	 return 1;
	 }
	 if(PlayerInfo[playerid][pAdmin] < 1)
	  {
  		switch(strval(tmp))
        {
            case 280:
            {
                SendClientMessage(playerid, 0x919191FF, "Restricted skin!");
                return 1;
            }
        }
	 }
	else if(IsAtClothShop(playerid) || PlayerInfo[playerid][pDonateRank] >= 1)
	{
 	new chosenskin = strval(tmp);
 	SetPlayerSkin(playerid, chosenskin);
 	PlayerInfo[playerid][pModel] = chosenskin;
 	return 1;
 	}
 	else {
 	SendClientMessage(playerid, COLOR_YELLOW, "  You are not inside a clothing store!");
 	}
 }
And it completely stops at the new case switch you gave to me.
Reply
#8

Someone help, it's really urgent.

XD
Reply
#9

pawn Код:
case 280: return SendClientMessage(playerid, 0x919191FF, "Restricted skin!");
This might work, worth a try.
Reply
#10

Quote:
Originally Posted by Wesley221
Посмотреть сообщение
pawn Код:
case 280: return SendClientMessage(playerid, 0x919191FF, "Restricted skin!");
This might work, worth a try.
That worked, thankyou!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)