Raised This Month: $ Target: $400
 0% 

[REQ] Bot Management


Post New Thread Reply   
 
Thread Tools Display Modes
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 03-23-2009 , 15:19   Re: [REQ] Bot Management
Reply With Quote #41

Quote:
Originally Posted by Ğiego View Post
Right, some bots have joined now. I wasn't watching at the time, but I *think* the human players dropped below 15?
So is it working or not? I need a final answer.
__________________
O o
/¯________________________
| IMMA FIRIN' MAH LAZOR!!!
\_¯¯¯
Dores is offline
VulturEMaN
Member
Join Date: Jan 2008
Old 03-23-2009 , 15:29   Re: [REQ] Bot Management
Reply With Quote #42

If I'm not mistaken, just from looking over the code quickly, it seems that it only needs some parenthesis in the right places to make sure the order of operations is right....

maybe (for the first if)
Code:
        if((get_pcvar_num(p_bot_quota) && g_playersNum) >= (get_pcvar_num(p_kickat) - get_pcvar_num(p_maxbots) + 1))
and (for the 2nd if)
Code:
        if((get_pcvar_num(p_bot_quota) < get_pcvar_num(p_maxbots)) && (g_playersNum < get_pcvar_num(p_kickat) - get_pcvar_num(p_maxbots) + 1))
but once again, i'm just a garden variety n00b ;)

I've got that code running on my server right now, but we'll never get that many normal human players for a while....

Last edited by VulturEMaN; 03-23-2009 at 15:50.
VulturEMaN is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 03-23-2009 , 16:20   Re: [REQ] Bot Management
Reply With Quote #43

@VulturEMaN:

A. It doesn't matter, the calculations will still work as should even without brackets, it's only a matter of optimization(which I guess I lack ).

B. You've misunderstood this part:
PHP Code:
if(get_pcvar_num(p_bot_quota) && g_playersNum >= get_pcvar_num(p_kickat) - get_pcvar_num(p_maxbots) + 1
It checks the value of the cvar that is held by p_bot_quota, and make sure it's positive. Then separately by AND(&&), it makes sure that g_playersNum's value is bigger or equal to the other value.

C. If you don't have a big amount of players in your server, change abk_players to a more appropriate value, according to the average amount of players in your server usually.
__________________
O o
/¯________________________
| IMMA FIRIN' MAH LAZOR!!!
\_¯¯¯
Dores is offline
vato loco [GE-S]
Veteran Member
Join Date: Oct 2006
Location: Germany
Old 03-23-2009 , 17:00   Re: [REQ] Bot Management
Reply With Quote #44

is it working now ???
__________________
vato loco [GE-S] is offline
Ğiego
Senior Member
Join Date: May 2004
Location: Currently: UK
Old 03-24-2009 , 09:04   Re: [REQ] Bot Management
Reply With Quote #45

It's working for the most part, yes. The bots don't rejoin until the players drop below 15 (or the map changes, naturally), but that isn't a bad thing in any way.

Thank you very much for the most excellent coding


Ğ
__________________
Ğiego is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 03-24-2009 , 09:35   Re: [REQ] Bot Management
Reply With Quote #46

Fixed.

PHP Code:
#include <amxmodx>

const TASK_ID 5000;

new 
p_maxbots;
new 
p_kickat;
new 
p_bot_quota;
new 
g_playersNum;

public 
plugin_init()
{
    
register_plugin("Auto Bot(s) Kick""1.1""Dores");
    
    
p_maxbots register_cvar("abk_max""6");
    
p_kickat register_cvar("abk_players""20");
    
    
p_bot_quota get_cvar_pointer("bot_quota");
}

public 
client_putinserver(id
{
    if(!
is_user_bot(id))
    {
        
g_playersNum++;
        
        if(
get_pcvar_num(p_bot_quota) && g_playersNum >= get_pcvar_num(p_kickat) - get_pcvar_num(p_maxbots) + 1)
            
set_pcvar_num(p_bot_quotaget_pcvar_num(p_bot_quota) - 1);
    }
}
public 
client_disconnect(id)
{
    if(!
is_user_bot(id))
    {
        
g_playersNum--;
        
        if(
get_pcvar_num(p_bot_quota) < get_pcvar_num(p_maxbots) && g_playersNum get_pcvar_num(p_kickat))
            
set_pcvar_num(p_bot_quotaget_pcvar_num(p_bot_quota) + 1);
    }
}

public 
plugin_pause()
{
    
remove_task(TASK_ID);
    
    
g_playersNum 0;
}

public 
server_changelevel(map[])
{
    
remove_task(TASK_ID);
    
    
g_playersNum 0;

__________________
O o
/¯________________________
| IMMA FIRIN' MAH LAZOR!!!
\_¯¯¯
Dores is offline
VulturEMaN
Member
Join Date: Jan 2008
Old 03-24-2009 , 12:51   Re: [REQ] Bot Management
Reply With Quote #47

lol thanks dores....you're truly epic
VulturEMaN is offline
Ğiego
Senior Member
Join Date: May 2004
Location: Currently: UK
Old 03-24-2009 , 13:06   Re: [REQ] Bot Management
Reply With Quote #48

Very much thanks again


Ğ
__________________
Ğiego is offline
VulturEMaN
Member
Join Date: Jan 2008
Old 03-25-2009 , 09:25   Re: [REQ] Bot Management
Reply With Quote #49

It seems to mess up on map change. I set the maxbots at 6, and the kickat at 12, and something went awry.

It could have also been messed up from someone manually setting bot_quota to 0....i am unsure...
VulturEMaN is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 03-25-2009 , 10:20   Re: [REQ] Bot Management
Reply With Quote #50

Yes, bot_quota shouldn't be changed for the code to work properly.
But what happens?
__________________
O o
/¯________________________
| IMMA FIRIN' MAH LAZOR!!!
\_¯¯¯
Dores 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 16:11.


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