disabling bots when theres a certain amount of players?

Hi,

im using guard_spawner_devices, and i have a playermap, and a @editables storing the Guard spawners

basically i want to disable guardspawners when there are more than real players

i want to use an if statement like

total players = amount of players
if total players = 3 or more disable guardspawner
elif total players = 4 or more disable guardspawner2
elif total players = 5 or more disable guardspawner3
elif total players = 6 or more disable guardspawner4
else guardspawner, guardspawner2, guardspawner3, guardspawner4 = enable

not sure how to actually code this, having a hard time going from python3 to verse
a better way is probably a for or while loop to do it,

only want it for 4 bots
gone with 4 separate if statements keeps it as individual events which i kind of like.
not if below is correct or what im missing
my attempt so far at this:

@editable
var Guards : []guard_spawner_device = array{}

var TotalPlayers : PlayerMap.Length

if (TotalPlayers := >3):
Guards[0].disable()
else: Guards[0].enable()

if (TotalPlayers := >4):
Guards[2].disable()
else: Guards[2].enable()

if (TotalPlayers := >5):
Guards[3].disable()
else: Guards[3].enable()

if (TotalPlayers := >6):
Guards[4].disable()
else: Guards[4].enable()

Hi People,

for some reason i couldnt target specific devices in the @editables array,
can for loop through it but couldnt choose a specific device tried a bunch of different ways but couldnt get it to work,

i did get it to work if i labeled each device in its own @editable.
the below code got it to work, but its the long way, if someone can reply a better coded way.

below code works:
\\\\\\\\\\\\\\\\\\\\\\\\\\\//////////////////////////////////////////////////

@editable
var Guards0 : []guard_spawner_device = array{}
@editable
var Guards1 : []guard_spawner_device = array{}
@editable
var Guards2 : []guard_spawner_device = array{}
@editable
var Guards3 : []guard_spawner_device = array{}

BotBalance() : void=
    AmountPlayers := GetPlayspace().GetPlayers()
    var TotalPlayers : int = PlayerMap.Length
    
    for (Guard0 : Guards0):
        if (TotalPlayers > 3):
            Guard0.Disable()
        else Guard0.Enable()
    
    for (Guard1 : Guards1):
        if (TotalPlayers > 4):
            Guard1.Disable()
        else Guard1.Enable()
    
    for (Guard2 : Guards2):
        if (TotalPlayers > 5):
            Guard2.Disable()
        else Guard2.Enable()
    
    for (Guard3 : Guards3):
        if (TotalPlayers > 6):
            Guard3.Disable()
        else Guard3.Enable()
1 Like