AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Removing Flag A (https://forums.alliedmods.net/showthread.php?t=108061)

KadiR 11-01-2009 09:54

Removing Flag A
 
This code does remove all flags for admins:

PHP Code:

remove_user_flags(id

How can I make, that it only should remove the A flag?

Bugsy 11-01-2009 09:57

Re: Removing Flag A
 
Try this (untested)

PHP Code:

new iFlags = ( get_user_flagsid ) & ~ADMIN_LEVEL_A );
remove_user_flagsid );
set_user_flagsid iFlags ); 


KadiR 11-01-2009 10:20

Re: Removing Flag A
 
Didn't work for me..

hleV 11-01-2009 10:40

Re: Removing Flag A
 
PHP Code:

new iFlags get_user_flags(id);
 
if (
iFlags ADMIN_LEVEL_A)
{
        
iFlags &= ~ADMIN_LEVEL_A;
 
        
remove_user_flags(id);
        
set_user_flags(idiFlags);


If by flag A you mean immunity (flag "a"), change ADMIN_LEVEL_A to ADMIN_IMMUNITY.

Bugsy 11-01-2009 10:58

Re: Removing Flag A
 
hlev, that is the same as my code except w\ an if statement; you can also shorten it with set_user_flags( id, iFlags & ~ADMIN_LEVEL_A );

Kadir, it should work. Are you properly testing if the flag exists?

Try this:
PHP Code:

//check if player has level a prior to removing
if ( get_user_flagsid ) & ADMIN_LEVEL_A )
    
client_printid print_chat "player has level a" );
else
    
client_printid print_chat "player does not have level a" );

//remove level a from flags
new iFlags = ( get_user_flagsid ) & ~ADMIN_LEVEL_A );
remove_user_flagsid );
set_user_flagsid iFlags );

//check again if player has level a
if ( get_user_flagsid ) & ADMIN_LEVEL_A )
    
client_printid print_chat "player has level a" );
else
    
client_printid print_chat "player does not have level a" ); 


ConnorMcLeod 11-01-2009 17:21

Re: Removing Flag A
 
Code:

set_user_flags(id, get_user_flags(id) & ~ADMIN_IMMUNITY)

Bugsy 11-01-2009 17:36

Re: Removing Flag A
 
Quote:

Originally Posted by ConnorMcLeod (Post 978259)
Code:

set_user_flags(id, get_user_flags(id) & ~ADMIN_IMMUNITY)

Will not work Connor, you must remove flags too.

Try it:
PHP Code:

public testid )
{
    
//check if player has level a prior to removing
    
if ( get_user_flagsid ) & ADMIN_LEVEL_A )
        
client_printid print_chat "player has level a" );
    else
        
client_printid print_chat "player does not have level a" );
    
    
set_user_flagsid , ( get_user_flagsid ) & ~ADMIN_LEVEL_A ) );
    
    
//check again if player has level a
    
if ( get_user_flagsid ) & ADMIN_LEVEL_A )
        
client_printid print_chat "player has level a" );
    else
        
client_printid print_chat "player does not have level a" ); 



ConnorMcLeod 11-01-2009 17:43

Re: Removing Flag A
 
Exact :

Code:

        pPlayer->flags[id] |= flag;

Which idiot wrote :
Code:

        if (id < 0)
                id = 0;
       
        if (id > 31)
                id = 31;

??

Bugsy 11-01-2009 18:20

Re: Removing Flag A
 
:stupid:
PHP Code:

remove_user_flagsid ADMIN_LEVEL_A ); 


ConnorMcLeod 11-01-2009 19:14

Re: Removing Flag A
 
I still wonder what is the 3rd arg.


All times are GMT -4. The time now is 17:48.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.