View Single Post
[FIX] Better method for auto vacate.
Old
  (#1)
wbyokomo
Zombie Slayer
 
Status: Offline
Posts: 17
Join Date: Apr 2012
Location: Cyberjaya MY
Default [FIX] Better method for auto vacate. - 12-06-2016

I'm tired of auto vacate issue, it's not work as i want.

Here i attach a possible fix for this issue, but it was in pawn language, i hope you can convert to cpp language.

I have 0 knowledge about cpp.

Fix:
PHP Code:
#include <amxmodx>
#include <fakemeta>

#define PLUGIN "Yapb Quota Fix"
#define VERSION "0.0.1"
#define AUTHOR "wbyokomo"

//lets say this is yb_quota cvar
#define MAX_BOT 9

new iMaxClients

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
iMaxClients get_maxplayers()
    
    
register_forward(FM_ClientDisconnect"OnClientDisconnectPost"1)
}

public 
client_putinserver(id)
{
    
UTIL_BotQuota()
}

//yes we need to use post
public OnClientDisconnectPost(id)
{
    
UTIL_BotQuota()
}

UTIL_BotQuota()
{
    new 
iBotiHuman
    iHuman 
UTIL_CountHumans()
    
iBot MAX_BOT iHuman
    
if(iBot)
    {
        
//here we set our bot count (iBot) correctly.
    
}
    else
    {
        
//human count >= 9, so we dont need bots anymore, kick them all.
    
}
}

UTIL_CountHumans()
{
    new 
idiCount=0
    
for(id=1;id<=iMaxClients;id++)
    {
        
//count only connected human, not a bot or hltv.
        
if(is_user_connected(id) && !is_user_bot(id) && !is_user_hltv(id))
        {
            
iCount++
        }
    }
    
    return 
iCount;

With this method:
  • 1 bot will leave if 1 human join.
  • 1 bot will join if 1 human leave.
Max bot is decided by yb_quota value.. easy right?
  
Reply With Quote