Hi,

I'm trying to adjust the number of slots in my server based on the number of bots online.

Here is code I'm using:

PHP Code:
if(getCvarInt("mod_slotadjust") == 1)
{
    
slots 16;

    
players getentarray("player""classname");

    for(
0players.sizei++)
    {
        if(
isdefined(players[i].isbot))
        {
            
slots++;
        }
    }

    
setCvar("sv_maxclients"slots);

It is placed inside checkTimeLimit(), which is called every second.

The problem is, the game crashes, dedicated or not.

I tried starting the server with mod_slotadjust set to 0, waiting for all bots to be added and only then turn it to 1, and that will also crash.

Here's what I've got in my console, and that is all:

PHP Code:
]/mod_slotadjust 1
      dvar set mod_slotadjust 1
      dvar set restart 
      dvar set sv_cheats 0
      dvar set restart 
      dvar set sv_cheats 0
      dvar set restart 
      dvar set sv_cheats 0
      dvar set restart 
      dvar set sv_cheats 0
      dvar set sv_maxclients 31 
I also tried to create a new function that was called every 30 seconds with the same functionality, it still crashed.

Any ideas? Am I missing something obvious?