Vice City Multiplayer

VC:MP => mIRC/pawn Scripting => Topic started by: ramandu on March 03, 2010, 01:43:28 PM

Title: switch case help
Post by: ramandu on March 03, 2010, 01:43:28 PM
i'm trying to make a command group hierarchy.

if the players primary group is any of the four in the "case" statement, he has access to all of that groups commands.

but as soon as i increase any of the "case" values above two characters, it throws many compile errors.



stock
IsPlayerGroup_Mod(Player[], Primary_Group[])
{

switch (Primary_Group[0])
{


// case 'a', 'b', 'c', 'd' : // ->  works
// case '1', '2', '3', '4': // -> This works too

case 'USER', 'ADMIN', 'HALF-ADMIN', 'MODERATOR': // -> but this dosnt work, why ?
{
return 1;

}
}
return 0;
}


calling syntax: IsPlayerGroup_Mod("Ramandu", "ADMIN");

how do i solve it ?

thankyou very much
Title: Re: switch case help
Post by: Boss on March 03, 2010, 02:26:39 PM
Afair ' is used for characters only. Use " for strings.
Title: Re: switch case help
Post by: ramandu on March 03, 2010, 02:43:34 PM
thankyou boss, it suppressed allot of the errors and leaves just this one;



error 008: must be a constant expression; assumed zero
Title: Re: switch case help
Post by: Boss on March 03, 2010, 03:01:20 PM
Which exactly line gives that error?

It is usually thrown if you try to use variables outside of callbacks (e.g. specify array size with a variable).
Title: Re: switch case help
Post by: ramandu on March 03, 2010, 03:13:24 PM
hi, it points directly to this line


case "USER", "ADMIN", "HALF-ADMIN", "MODERATOR":


i am calling it like this,


if ( IsPlayerGroup_Mod("ramandu", "MODERATOR") ) { printf("yes, ramandu's group MODERATOR is found and also has access to user, admin, half-admin commands"); }
Title: Re: switch case help
Post by: Boss on March 03, 2010, 03:20:30 PM
Why do you use Primary_Group[0]? It will switch only the first letter.
Title: switch case help
Post by: ramandu on March 03, 2010, 03:27:33 PM
hi, it seems the topic was locked for no apparent reason.

you asked me a question.

Why do you use Primary_Group
its simply just name i gave it to represent the value of the function.

It will switch only the first letter.
ok thankyou for this information, how do i make it switch the complete word ?
Title: Re: switch case help
Post by: Boss on March 03, 2010, 03:31:55 PM
Quote from: ramandu on March 03, 2010, 03:27:33 PM
hi, it seems the topic was locked for no apparent reason.
Might've been some bug, sorry.

Quote from: ramandu on March 03, 2010, 03:27:33 PM
ok thankyou for this information, how do i make it switch the complete word ?
Don't use [ 0 ] in switch. Just switch(Primary_Group).