stock SetAdminCommand(command[], level)
{
if(level)
{
Group_SetGlobalCommand(Command_GetID(command), false);
new cl = 0;
while(cl != MAX_ADMIN_LEVELS)
{
cl += 1;
if(cl == level)
{
Group_SetCommand(SerwerData[E_SERWER_GROUP_ADMINS][cl], Command_GetID(command), true);
}
else
{
Group_SetCommand(SerwerData[E_SERWER_GROUP_ADMINS][cl], Command_GetID(command), false);
}
}
}
else
{
Group_SetGlobalCommand(Command_GetID(command), true);
}
}
SetAdminCommand("ban", 1, 2, 3, 4, 5, 6[...]);
stock SetAdminCommand(command[], ...)
{
for(new level = 1; level < numargs(); level++)
{
if(getarg(level))
{
Group_SetGlobalCommand(Command_GetID(command), false);
new cl = 0;
while(cl != MAX_ADMIN_LEVELS)
{
cl += 1;
if(cl == level)
{
Group_SetCommand(SerwerData[E_SERWER_GROUP_ADMINS][cl], Command_GetID(command), true);
}
else
{
Group_SetCommand(SerwerData[E_SERWER_GROUP_ADMINS][cl], Command_GetID(command), false);
}
}
}
else
{
Group_SetGlobalCommand(Command_GetID(command), true);
}
}
}
You should look up y_va.inc https://sampforum.blast.hk/showthread.php?tid=399069
|
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);
}
}
}
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 Код:
|
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! |