# AI multiplier

## Recommended Posts

Is it possible that, if there are players on the server (4 or more) then the AI would be 2x more than the players. Is there a good way to make a script about it?

##### Share on other sites

Definitely possible, how are the AI created?

• 1

##### Share on other sites

I create as one team at a time.

Most are like this

SP_Missions_Squad_Members = 3 + (random 3 + 4);
for "_x" from 0 to (SP_Missions_Squad_Members) do .....

and without

for "_x" from 0 to (random 5 + 7) do ......

i like this style more, because easier to control things.

##### Share on other sites

You could do something like this:

```_multiplier = if (count allPlayers >= 4) then {2} else {1};
// You could make a mathematical equation instead of just an if statement

SP_Missions_Squad_Members = (3 + (floor random 3 + 4)) * _multiplier;
// random results in a decimal value instead of an integer, which is wonky to use in a loop so it is rounded

for "_x" from 0 to SP_Missions_Squad_Members do ....```

There are many ways to achieve what you want, but this snippet uses the number of in-game players at the moment the script runs to increase the amount of spawned enemies.

• 2

##### Share on other sites

Thank you. That script is working.