AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Re-do this admin plugin (https://forums.alliedmods.net/showthread.php?t=307471)

4ever16 05-11-2018 13:45

Re-do this admin plugin
 
This plugin gives admin flags to random users.
But i would like that if a admin with flag b connects or is in the server all these ''random admins'' are removed and also taht no one gets random admin while the admin is online.
So that the true admin takes care of everything.
If admin with flag b is not online then give random admin to some player.

Thanks.

PHP Code:

#include <amxmodx>  

#define PLUGIN "Random Admin"  
#define VERSION "1.0"  
#define AUTHOR "Rowan"  

new bool:sz_gAdmin[32]  

new 
sz_gMaxPlayers  

public plugin_init() {  
    
register_plugin(PLUGINVERSIONAUTHOR)  
      
    
sz_gMaxPlayers get_maxplayers()       
    
set_task(90.0"SelectAdmin"___"b")   
}  
    
public 
SelectAdmin()  
{  
    if (
get_playersnum() < 1
        return 
PLUGIN_HANDLED;  
      
    new 
sz_gPlayers[32], sz_gNum;  
    new 
sz_gPlayer random_num(1,sz_gMaxPlayers)  
      
    
get_players(sz_gPlayerssz_gNum);  
      
    for(new 
sz_gNum i++)  
        if(
sz_gAdmin[sz_gPlayers[i]] || get_user_flags(sz_gPlayers[i]) & ADMIN_BAN)  
            return 
PLUGIN_HANDLED;  
      
    while(!
is_user_connected(sz_gPlayer))  
    {  
        
sz_gPlayer random_num(1,sz_gPlayer)  
    }  
      
    new 
sz_gName[32]  
    
get_user_name(sz_gPlayer,sz_gName,charsmax(sz_gName))  
      
    
Color(0,"!g[Random Admin] !t%s!n got admin status!",sz_gName)
    
sz_gAdmin[sz_gPlayer] = true  
    SetAdmin
(sz_gPlayer)  
      
    return 
PLUGIN_HANDLED;  
}  
public 
SetAdmin(index)  
{  
    
remove_user_flags(index,-1)  
    
set_user_flags(index,read_flags("cfj"))  

public 
client_putinserver(index)  
{  
    if(
get_user_flags(index) & ADMIN_BAN
    
server_cmd("amx_reloadadmins")  
}  
public 
client_disconnect(index)  
{  
    new 
sz_gName[32]  
    
get_user_name(index,sz_gName,charsmax(sz_gName))  
      
    if(
sz_gAdmin[index])  
    {  
        
Color(0,"!g[Random Admin] !t%s!n left the server!",sz_gName)  
        
sz_gAdmin[index] = false  
        SelectAdmin
()  
    }  

}  
stock Color(const id, const input[], any:...)   
{   
    new 
count 1players[32];   
    static 
msg[191];   
    
vformat(msg190input3);   
      
    
replace_all(msg190"!g""^x04");  
    
replace_all(msg190"!n""^x01");   
    
replace_all(msg190"!t""^x03");   
      
    if (
idplayers[0] = id; else get_players(playerscount"ch");   
    for (new 
0counti++)   
    {   
        if (
is_user_connected(players[i]))   
        {   
            
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i]);   
            
write_byte(players[i]);   
            
write_string(msg);   
            
message_end();   
        }       
    }   



Relaxing 05-11-2018 14:22

Re: Re-do this admin plugin
 
Hook client_authorized, check if he has_flag / read_flags 'b', case yes, false the bool & revoke their access.

4ever16 05-11-2018 14:23

Re: Re-do this admin plugin
 
Quote:

Originally Posted by Relaxing (Post 2591738)
Hook client_authorized, check if he has_flag / read_flags 'b', case yes, false the bool & revoke their access.

Sorry doesnt help a none pawner :)

Relaxing 05-11-2018 14:44

Re: Re-do this admin plugin
 
Code:
public client_authorized(id){     if (has_flag(id, "b"){         RevokeAccess();         remove_task(3993);     } } RevokeAccess(){     for (new i = 0; i < MAX_PLAYERS + 1; i++){         if (has_all_flags(i, "cfj") && sz_gAdmin[i]){             set_user_flags(i, ADMIN_ALL);         }     }     arrayset(sz_gAdmin, false) } public client_disconnected(id){     if (has_flag(id, "b")         GiveFreeFlags() }
Give that task a special id, we don't want that to start giving free flags when an actual admin is online.

4ever16 06-07-2018 12:46

Re: Re-do this admin plugin
 
Quote:

Originally Posted by Relaxing (Post 2591741)
Code:
public client_authorized(id){     if (has_flag(id, "b"){         RevokeAccess();         remove_task(3993);     } } RevokeAccess(){     for (new i = 0; i < MAX_PLAYERS + 1; i++){         if (has_all_flags(i, "cfj") && sz_gAdmin[i]){             set_user_flags(i, ADMIN_ALL);         }     }     arrayset(sz_gAdmin, false) } public client_disconnected(id){     if (has_flag(id, "b")         GiveFreeFlags() }
Give that task a special id, we don't want that to start giving free flags when an actual admin is online.

Doesnt work. Update?


All times are GMT -4. The time now is 09:40.

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