Raised This Month: $ Target: $400
 0% 

Slot reservation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
reinert
Veteran Member
Join Date: Feb 2007
Old 04-06-2011 , 15:01   Slot reservation
Reply With Quote #1

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

reinert is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-06-2011 , 15:12   Re: Slot reservation
Reply With Quote #2

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(); }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 04-06-2011 , 15:19   Re: Slot reservation
Reply With Quote #3

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 ?
reinert is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-06-2011 , 15:33   Re: Slot reservation
Reply With Quote #4

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.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 14:01.


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