Raised This Month: $32 Target: $400
 8% 

Re-do this admin plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
4ever16
Veteran Member
Join Date: Apr 2015
Old 05-11-2018 , 13:45   Re-do this admin plugin
Reply With Quote #1

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();   
        }       
    }   


Last edited by 4ever16; 06-07-2018 at 13:01.
4ever16 is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 05-11-2018 , 14:22   Re: Re-do this admin plugin
Reply With Quote #2

Hook client_authorized, check if he has_flag / read_flags 'b', case yes, false the bool & revoke their access.
__________________
Relaxing is offline
4ever16
Veteran Member
Join Date: Apr 2015
Old 05-11-2018 , 14:23   Re: Re-do this admin plugin
Reply With Quote #3

Quote:
Originally Posted by Relaxing View Post
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
4ever16 is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 05-11-2018 , 14:44   Re: Re-do this admin plugin
Reply With Quote #4

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.
__________________

Last edited by Relaxing; 05-11-2018 at 14:52.
Relaxing is offline
4ever16
Veteran Member
Join Date: Apr 2015
Old 06-07-2018 , 12:46   Re: Re-do this admin plugin
Reply With Quote #5

Quote:
Originally Posted by Relaxing View Post
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?
4ever16 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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