Trying to use multiple numbers in one value... -
Jack_Leslie - 14.06.2011
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.
Re: Trying to use multiple numbers in one value... -
Skaizo - 14.06.2011
delete sorry
Re: Trying to use multiple numbers in one value... -
King Ace - 14.06.2011
pawn Код:
if(PlayerInfo[playerid][pAdmin] < 1 && strval(tmp) == 280)
to
pawn Код:
if(PlayerInfo[playerid][pAdmin] < 1 && strval(tmp) >= 280 || strval(tmp) <= 282)
Re: Trying to use multiple numbers in one value... -
randomkid88 - 14.06.2011
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
Re: Trying to use multiple numbers in one value... -
Jack_Leslie - 15.06.2011
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?
Re: Trying to use multiple numbers in one value... -
randomkid88 - 15.06.2011
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;
}
Re: Trying to use multiple numbers in one value... -
Jack_Leslie - 15.06.2011
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.
Re: Trying to use multiple numbers in one value... -
Jack_Leslie - 15.06.2011
Someone help, it's really urgent.
XD
Re: Trying to use multiple numbers in one value... -
Wesley221 - 15.06.2011
pawn Код:
case 280: return SendClientMessage(playerid, 0x919191FF, "Restricted skin!");
This might work, worth a try.
Re: Trying to use multiple numbers in one value... -
Jack_Leslie - 15.06.2011
Quote:
Originally Posted by Wesley221
pawn Код:
case 280: return SendClientMessage(playerid, 0x919191FF, "Restricted skin!");
This might work, worth a try.
|
That worked, thankyou!