Posts: 1,767
	Threads: 124
	Joined: Mar 2010
	
	
 
	
	
		
pawn Код:
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);
    }
}
 Any ideas how to write levels after commas?
pawn Код:
SetAdminCommand("ban", 1, 2, 3, 4, 5, 6[...]);
 
	 
	
	
	
		
	
 
 
	
	
	
		
	Posts: 1,767
	Threads: 124
	Joined: Mar 2010
	
	
 
	
	
		Tried:
pawn Код:
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);
        }
    }
}
 Not working at all..
	
		
	
 
 
	
	
	
		
	Posts: 1,767
	Threads: 124
	Joined: Mar 2010
	
	
 
 
	
	
	
		
	Posts: 1,767
	Threads: 124
	Joined: Mar 2010
	
	
 
	
	
		
Quote:
| 
					Originally Posted by LarzI   | 
 Tried, no idea how to start with it.. any advice?
	
 
	
	
	
		
	
 
 
	
	
	
		
	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.