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(PLUGIN, VERSION, AUTHOR)
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_gPlayers, sz_gNum);
for(new i = 0 ; i < 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 = 1, players[32];
static msg[191];
vformat(msg, 190, input, 3);
replace_all(msg, 190, "!g", "^x04");
replace_all(msg, 190, "!n", "^x01");
replace_all(msg, 190, "!t", "^x03");
if (id) players[0] = id; else get_players(players, count, "ch");
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}