[Supporting] Spawning bots in SND

Topic created · 6 Posts · 159 Views
  • sorry for opening a forum post and i feel dumb asking this because it's probably common sense and i tried a bunch of work arounds but i'm trying to see, how do you only spawn 2 bots via gsc in SND and not make it spawn 2 more every round?

    i tried multiple ways. heres one example of a check I tried to do:

    botCount = 0;
    foreach (player in level.players)
    {
       if (isDefined(player.pers["isBot"]) && player.pers["isBot"])
       {
             botCount++;
       }
    }
    if (botClient < 2)
    {
         level thread handleBot();
    }
    
  • @mikey another method could be using a DVAR since they don't reset like normal variables.

    level.botsSpawned = getDvarIntDefault( "botsSpawned", 0 );
    if( !level.botsSpawned )
    {
        setDvar( "botsSpawned", 1 );
        level.botsSpawned = getDvarIntDefault( "botsSpawned", 0 );
        thread handleBot();
    }
    

    but then the DVAR would need to be reset at the end of the game

    level waittill( "game_ended" );
    setDvar( "botsSpawned", 0 );
    
  • @Cahz does game_ended get called on SND round switch or actual endgame? and also, how would i set after endgame if the GSC resets every round? a for loop?

  • @mikey Consider:

    level waittill("game_ended");
    

    Followed by a check to see if it was the last round:

    waslastround()
    
  • you can do a check for last round? if so, this helps so much. thank you!

  • This post is deleted!
Log in to reply