AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   bot_quota control help CS/CZ bots (https://forums.alliedmods.net/showthread.php?t=299440)

Ricky 07-14-2017 16:04

bot_quota control help CS/CZ bots
 
Looking for a script that will control the bot_quota of cz bots/humans on either T or CT. For example, if bot_quota is set to 10, the number of players on both teams should total 10 at any given time. This excludes spectators and unassigned. There is this https://forums.alliedmods.net/showth...08253?p=808253 that works almost perfectly but it causes crashes sometimes right after a bot gets kicked and disconnects. Adding connected and team checks didn't help. Any help would be appreciated.

eyal282 07-15-2017 04:50

Re: bot_quota control help CS/CZ bots
 
I'll check how it's done soon ( it has a cvar ), but do you have a steam counter strike or non steam counter strike?

Ricky 07-15-2017 16:20

Re: bot_quota control help CS/CZ bots
 
Currently running steam only, metamod 1.21-am, latest dev build amxx 1.8.3, windows. The crash happens when a real player joins team and a bot is kicked. For example, these are the last few logs before crash.

L 07/14/2017 - 11:33:52: "???<880><STEAM_0:1:???????><>" joined team "TERRORIST"
L 07/14/2017 - 11:33:53: Server cvar "bot_quota" = "11"
L 07/14/2017 - 11:33:53: Kick: "Superbot<877><BOT><>" was kicked by "Console"
L 07/14/2017 - 11:33:53: "Superbot<877><BOT><TERRORIST>" disconnected

Ricky 07-18-2017 16:48

Re: bot_quota control help CS/CZ bots
 
Still trying to find a fix or replacement script for this function.

Code:

public check_players() {
       
        if(get_pcvar_num(g_bot_enabled)) {
               
                if(get_pcvar_num(g_bot_balance)) {
                       
                        new iPlayerNum
                       
                        for(new i = 1 ; i <= g_iMaxPlayers ; i++) {
                               
                                if(!is_user_bot(i)) {
                                       
                                        new team = get_user_team(i)
                                        if(team == 1 || team == 2)
                                                ++iPlayerNum
                                }
                        }
                        if(iPlayerNum <= get_pcvar_num(g_bot_max)) {
                               
                                set_pcvar_num(g_bot_quota, get_pcvar_num(g_bot_max) - iPlayerNum)
                        }
                        else if(iPlayerNum > get_pcvar_num(g_bot_max)) {
                               
                                if(get_pcvar_num(g_bot_quota) != 0) {
                                       
                                        set_pcvar_num(g_bot_quota, 0)
                                       
                                        for(new bi = 1 ; bi <= g_iMaxPlayers ; bi++) {
                                               
                                                if(is_user_bot(bi)){
                                                       
                                                        new userid = get_user_userid(bi)
                                                        server_cmd("kick #%d", userid)
                                                }
                                        }
                                        return PLUGIN_HANDLED
                                }
                                return PLUGIN_HANDLED
                        }
                        check_balance()
                }
                else {
                        if(get_pcvar_num(g_bot_max) < get_pcvar_num(g_bot_maxslots)) {
                               
                                set_pcvar_num(g_bot_quota, get_pcvar_num(g_bot_max))
                               
                                return PLUGIN_HANDLED
                        }
                }
        }
        else {
                if(task_exists(TASK_CZBOT_MODE)) {
                       
                        remove_task(TASK_CZBOT_MODE)
                }
                set_pcvar_num(g_bot_quota, 0)
               
                for(new bi = 1 ; bi <= g_iMaxPlayers ; bi++) {
                       
                        if(is_user_bot(bi)){
                               
                                new userid = get_user_userid(bi)
                                server_cmd("kick #%d", userid)
                        }
                }
        }
        return PLUGIN_CONTINUE
}


baneado 07-18-2017 18:17

Re: bot_quota control help CS/CZ bots
 
When do you call check_players?

Maybe doing a break after Kick the bot to stop the loop

Ricky 07-19-2017 00:44

Re: bot_quota control help CS/CZ bots
 
Quote:

Originally Posted by baneado (Post 2536225)
When do you call check_players?

Maybe doing a break after Kick the bot to stop the loop

Code:

public plugin_cfg() {
       
        if(!get_pcvar_num(g_bot_enabled))
                return PLUGIN_HANDLED
       
        set_task(1.0, "check_players", TASK_CZBOT_MODE, _, _, "b")
        set_task(3.0, "map_loaded", TASK_CZBOT_SLOTS)
       
        return PLUGIN_CONTINUE
}

What line should I edit with the break code? Example?

Ricky 07-31-2017 14:47

Re: bot_quota control help CS/CZ bots
 
Bump.


All times are GMT -4. The time now is 23:11.

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