Posts: 1,767
Threads: 124
Joined: Mar 2010
Quote:
Originally Posted by iggy1
Edited your code a bit, changed it into two functions so it should be a little easier to debug if you have problems.
UNTESTED:
pawn Код:
stock SetAdminCommand(command[], ...) { new idx = 0; for(new level = 1; level < numargs(); level++) { if( ( idx = getarg(level) ) )//if level is more than zero { Group_SetGlobalCommand(Command_GetID(command), false);
//you appeared to use the admin level as an index in your code. //You should add bounds checks to make sure you don't access elements OOB Group_SetCommand(SerwerData[E_SERWER_GROUP_ADMINS][ idx ], Command_GetID(command), true); } else { Group_SetGlobalCommand(Command_GetID(command), true); } } }
stock UnSetAdminCommand(command[], ...) { new idx = 0; for(new level = 1; level < numargs(); level++) { if( ( idx = getarg(level) ) ) { Group_SetGlobalCommand(Command_GetID(command), true); //You should add bounds checks to make sure you don't access elements OOB Group_SetCommand(SerwerData[E_SERWER_GROUP_ADMINS][ idx ], Command_GetID(command), false); } else { Group_SetGlobalCommand(Command_GetID(command), false); } } }
|
Works like a charm, thanks.
Quote:
Originally Posted by LarzI
I apologise! I was certain y_va was easy to use with integers too, but I couldn't quite understand how you would do it - if it's even possible.
Read iggy's response - it should work!
|
No worries, both repped.