• Welcome to Vice City Multiplayer.
 

switch case help

Started by ramandu, March 03, 2010, 01:43:28 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ramandu

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

Boss

Afair ' is used for characters only. Use " for strings.

ramandu

thankyou boss, it suppressed allot of the errors and leaves just this one;



error 008: must be a constant expression; assumed zero

Boss

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).

ramandu

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"); }

Boss

#5
Why do you use Primary_Group[0]? It will switch only the first letter.

ramandu

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 ?

Boss

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).