AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Slot reservation (https://forums.alliedmods.net/showthread.php?t=154345)

reinert 04-06-2011 15:01

Slot reservation
 
Why this doesn't work ? It should kick except for Estonia random player.

Like if admin comes, the Sweden or Russian player will be kicked...

PHP Code:

public client_authorized(id) {

    new 
maxplayers get_maxplayers()
    new 
players get_playersnum
    new 
limit maxplayers 1
    
new who
    
    
if ( players limit )
    { 
        if ( 
get_user_flags(id) & ADMIN_RESERVATION 
        { 
            
who kickEmi()
            
            if(
who)  {
                new 
name[32]
                   
get_user_namewhoname 31 )
                   
client_cmd(id,"echo ^"* %s was kicked to free this slot^"" ,name )
               }
            return 
PLUGIN_CONTINUE 
        
}

        if ( 
is_user_bot(id) ) 
            
server_cmd("kick #%d"get_user_userid(id)  ) 
        else 
            
client_cmd(id,"echo ^"Server is Full.^";disconnect")
            
        return 
PLUGIN_HANDLED // block connect in other plugins (especially in consgreet)     
    

    return 
PLUGIN_CONTINUE;


PHP Code:

kickEmi() {
    new 
who 0
    
new maxplayers get_maxplayers()
    for(new 
1<= maxplayers; ++i){
        new 
szCountry[3];
        new 
iIp[35];
        
get_user_ip(iiIp341)
        
geoip_code2(iIpszCountry)
        
strtolower(szCountry)
        
        if ( !
is_user_connected(i) && !is_user_connecting(i) )
            continue 
// not used slot
        
if (get_user_flags(i)&ADMIN_RESERVATION)
            continue 
// has reservation, skip him
        
if (equali(szCountry"ee") || equali(szCountry"er"))
            continue 
// is from estonia or unknown country (may be estonia aswell)
            
        
if(who)
        {
            
who i
        
}
    }
    if(
who
        if ( 
is_user_bot(who) ) 
            
server_cmd("kick #%d"get_user_userid(who)  ) 
        else 
            
client_cmd(who,"disconnect")
    return 
who



Exolent[jNr] 04-06-2011 15:12

Re: Slot reservation
 
Code:
#include <amxmodx> #define RESERVED_SLOTS 1 new g_max_players; public plugin_init() {     g_max_players = get_maxplayers(); } public client_authorized(id) {     new pnum = get_playersnum(1);         if( pnum > (g_max_players - RESERVED_SLOTS) )     {         if( get_user_flags(id) & ADMIN_RESERVATION )         {             new ip[32], country[3];             for( new i = 1; i <= g_max_players; i++ )             {                 if( is_user_connected(i) && !(get_user_flags(i) & ADMIN_RESERVATION) )                 {                     get_user_ip(i, ip, charsmax(ip), 1);                     geoip_code2(ip, country);                                         if( !equali(country, "ee") && !equali(country, "er") )                     {                         get_user_name(i, ip, charsmax(ip));                                                 client_cmd(id, "echo ^"* %s was kicked to free this slot *^"", ip);                                                 DisconnectPlayer(i, "You were kicked due to slot reservation");                                                 break;                     }                 }             }         }         else         {             DisconnectPlayer(id, "You were kicked due to slot reservation");         }     } } DisconnectPlayer(id, const reason[]) {     message_begin(MSG_ONE_UNRELIABLE, SVC_DISCONNECT, _, id);     write_string(reason);     message_end(); }

reinert 04-06-2011 15:19

Re: Slot reservation
 
Thanks, also is it possible to make that there will be 32/32 players playing, but the 33rd will be redirected or so...

something with sv_visiblemaxplayers ?

Exolent[jNr] 04-06-2011 15:33

Re: Slot reservation
 
No. If the server is full, then the player cannot connect so AMXX cannot do anything with the player.
You should set your visible max players to 31, then redirect the 32nd player.


All times are GMT -4. The time now is 19:51.

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