Raised This Month: $ Target: $400
 0% 

[REQ] Auto Kick on join if no admin online


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Old.School
Senior Member
Join Date: Sep 2015
Location: France
Old 06-01-2016 , 00:32   [REQ] Auto Kick on join if no admin online
Reply With Quote #1

i need code Auto Kick Any Player Try to join the server except the admins if no admin on server anx thnx
__________________
You keep bringing B.R down .. He will rise again and kick Enemies asses !
Old.School is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 06-01-2016 , 09:02   Re: [REQ] Auto Kick on join if no admin online
Reply With Quote #2

PHP Code:
#include <amxmodx>

#define ADMIN_FLAG ADMIN_SLAY
#define KICK_REASON "You can't play without any admins online."

public plugin_init()
    
register_plugin("Kick Players if no Admin Online""1.0""OciXCrom")

public 
client_putinserver(id)
    if(!(
get_user_flags(id) & ADMIN_FLAG))
        if(!
is_admin_online())
            
server_cmd("kick #%i ^"%s^""get_user_userid(id), KICK_REASON)
    
bool:is_admin_online()
{
    new 
iPlayers[32], iPnumiAdmins
    get_players
(iPlayersiPnum)
    
    for(new 
iiPnumi++)
        if(
get_user_flags(iPlayers[i]) & ADMIN_FLAG)
            
iAdmins++
            
    return 
iAdmins true false

OciXCrom is offline
Send a message via Skype™ to OciXCrom
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 06-01-2016 , 10:53   Re: [REQ] Auto Kick on join if no admin online
Reply With Quote #3

OcixCrom, no need function if you use it one time...

PHP Code:
#include <amxmodx>

#define ADMIN_FLAG ADMIN_SLAY
new const KICK_REASON[] = "You can't play without any admins online."

new g_maxplayers;

public 
plugin_init(){
    
register_plugin("Kick Players if no Admin Online""1.0""OciXCrom");
    
g_maxplayers get_maxplayers()
}    

public 
client_putinserver(id)
{
    if(
get_user_flags(id) & ADMIN_FLAG)
    return;
    
    for(new 
1<= g_maxplayersi++)
        if(
is_user_connected(i) && get_user_flags(i) & ADMIN_FLAG)
        return;
    
    
server_cmd("kick #%i ^"%s^""get_user_userid(id), KICK_REASON)


Last edited by siriusmd99; 06-01-2016 at 10:54.
siriusmd99 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 06-01-2016 , 15:40   Re: [REQ] Auto Kick on join if no admin online
Reply With Quote #4

It won't affect the code in any way, it only makes it look better. Not a big deal, I prefer using it that way.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 06-01-2016 , 16:12   Re: [REQ] Auto Kick on join if no admin online
Reply With Quote #5

No problem , we are learning not judging someone:

Look here:

PHP Code:
bool:is_admin_online()
{
    new 
iPlayers[32], iPnumiAdmins
    get_players
(iPlayersiPnum)
    
    for(new 
iiPnumi++)
        if(
get_user_flags(iPlayers[i]) & ADMIN_FLAG)
            
iAdmins++
            
    return 
iAdmins true false

no need for iAdmins variable, just return true if found an admin, like this :

PHP Code:
bool:is_admin_online()
{
    new 
iPlayers[32], iPnum;
    
get_players(iPlayersiPnum)
    
    for(new 
iiPnumi++)
        if(
get_user_flags(iPlayers[i]) & ADMIN_FLAG)
            return 
true;
            
   return 
false;

siriusmd99 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 06-01-2016 , 17:05   Re: [REQ] Auto Kick on join if no admin online
Reply With Quote #6

Oh, yeah, didn't thought about that.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Old.School
Senior Member
Join Date: Sep 2015
Location: France
Old 06-02-2016 , 21:47   Re: [REQ] Auto Kick on join if no admin online
Reply With Quote #7

thnx guys but can you make task check if the if the admin online every 10 min or kick all the players and thnx cause i didn't have time to do it
__________________
You keep bringing B.R down .. He will rise again and kick Enemies asses !
Old.School is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 06-03-2016 , 03:05   Re: [REQ] Auto Kick on join if no admin online
Reply With Quote #8

PHP Code:
#include <amxmodx>

#define ADMIN_FLAG ADMIN_SLAY
new const KICK_REASON[] = "You can't play without any admins online."

new g_maxplayers;

public 
plugin_init(){
   
register_plugin("Kick Players if no Admin Online""1.0""OciXCrom")
   
g_maxplayers get_maxplayers();
}
public 
client_putinserver(id)
    if(!(
get_user_flags(id) & ADMIN_FLAG))
        if(!
is_admin_online())
            
server_cmd("kick #%i ^"%s^""get_user_userid(id), KICK_REASON)
    
public 
client_disconnect(id)
    if(
get_user_flags(id) & ADMIN_FLAG)
         
set_task(1.0"check_admins")

public 
check_admins()
     if(!
is_admin_online())
          for(new 
i=1<= g_maxplayersi++)
             if(
is_user_connected(i
                    
server_cmd("kick #%i ^"%s^""get_user_userid(i), KICK_REASON)

                  
bool:is_admin_online()
{
    for(new 
i=1<= g_maxplayersi++)
        if(
is_user_connected(i) && get_user_flags(i) & ADMIN_FLAG)
            return 
true;
            
    return 
false;


Last edited by siriusmd99; 06-05-2016 at 07:02.
siriusmd99 is offline
Whitez
Member
Join Date: Apr 2016
Location: London, UK
Old 06-04-2016 , 18:51   Re: [REQ] Auto Kick on join if no admin online
Reply With Quote #9

Gratz, you will keep your server 0/32 24/7
Whitez is offline
Reply



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:17.


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