Results 1 to 7 of 7

Thread: Adjusting maxclients

  1. #1
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts

    Adjusting maxclients

    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?
    set logfile 2

  2. #2
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Have you considered the possibility that sv_maxclients wasnt meant to be changed?
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  3. The Following User Says Thank You to IzNoGoD For This Useful Post:

    guiismiti (18th February 2015)

  4. #3
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    As Izno rightly points out - once the server is compiled, you cannot change the number of maxclients without restarting the server over again. It is not a dynamic dvar.

    When you start a server, the game allocates a set amount of memory to each client slot, irrespective of whether or not there are the max number of players online. To do this it has to hard-code the compilation of the server. As such, maxclients cannot be changed once set to a specific amount; not without a server restart.

  5. The Following User Says Thank You to Tally For This Useful Post:

    guiismiti (18th February 2015)

  6. #4
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts
    While coding this, I was under the false impression that I once made that work.
    set logfile 2

  7. #5
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    You could try to make your server 64 slots, then reduce the amount of visible slots towards the getinfo by people query-ing your server
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  8. #6
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    458
    Thanks
    79
    Thanked 122 Times in 101 Posts
    Izno, how to make the players to see a different number? or all other information about the server ??
    in the list of servers.

  9. #7
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    I dont know, i was just proposing a solution
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •