ItsMods

Full Version: Spawning Bots
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hey hoe..

I have a server running and want bots to be spawned if there are less then 4Players...

something like:

Code:
If players.on.server = 3 spawn.Bots= 3
if players.on.server = 2 spawn.Bots=4
if players.on.server = 6 spawn.Bots= 0

Kinda like this... Tried it myself, kopied parts from other mods (PTK - "Level.Metistesting = True;" and the "addTestClient();" thingy )

Anybody an idea how to do it ?

Tried it like this:
on init()
Code:
level.Bots_Number = 3;
Just to get a maximum of bots

and at OnPlayerspawned()
Code:
    for(i=0;i<level.Bots_Number;i++)
        AddTestClient();
under the
Code:
self endon("disconnect");
Ummm nobody ?
Ummm be patient.
Well you can look into "jugernaut mod", was released with modtool like tutorial. Copy the part to "limited jug player" or wath else is called, edit it changing juger with botz and reverse it (more players less botz)....
C++ Code
  1. addBots()
  2. {
  3. botNum = 0;
  4. players = level.players.size;
  5. teams = [];
  6. teams[0] = "allies";
  7. teams[1] = "axis";
  8.  
  9. if( players <= 3 )
  10. botNum = 4;
  11.  
  12. if( players == 4 )
  13. botNum = 3;
  14.  
  15. if( players == 5 )
  16. botNum = 2;
  17.  
  18. for( i = 0; i < botNum; i++ )
  19. {
  20. wait 2;
  21. bot = AddTestClient();
  22. bot.pers[ "isBot" ] = true;
  23. bot thread maps\mp\gametypes\_bot::bot_spawn_think( teams[ randomInt( 2 ) ] );
  24. }
  25. }


?
Thank you... But where do i have to call it ?

onplayerconnect/ spawned or on init with level thread addbots();
(08-27-2011, 22:34)prisma Wrote: [ -> ]Thank you... But where do i have to call it ?

onplayerconnect/ spawned or on init with level thread addbots();

add

level thread addBots(); to init()
(08-27-2011, 10:52)iAegle Wrote: [ -> ]
C++ Code
  1. addBots()
  2. {
  3. botNum = 0;
  4. players = level.players.size;
  5. teams = [];
  6. teams[0] = "allies";
  7. teams[1] = "axis";
  8.  
  9. if( players <= 3 )
  10. botNum = 4;
  11.  
  12. if( players == 4 )
  13. botNum = 3;
  14.  
  15. if( players == 5 )
  16. botNum = 2;
  17.  
  18. for( i = 0; i < botNum; i++ )
  19. {
  20. wait 2;
  21. bot = AddTestClient();
  22. bot.pers[ "isBot" ] = true;
  23. bot thread maps\mp\gametypes\_bot::bot_spawn_think( teams[ randomInt( 2 ) ] );
  24. }
  25. }


?

Nothing happens... When i add this to the _rank.gsc :/
no error message but no bots too.
U need to add a Loop, to check always i think.

Something like that?:

C++ Code
  1. addBots()
  2. {
  3. for( ; ; )
  4. {
  5. botNum = 0;
  6. players = level.players.size;
  7. teams = [];
  8. teams[0] = "allies";
  9. teams[1] = "axis";
  10.  
  11. if( players <= 3 )
  12. botNum = 4;
  13.  
  14. if( players == 4 )
  15. botNum = 3;
  16.  
  17. if( players == 5 )
  18. botNum = 2;
  19.  
  20. for( i = 0; i < botNum; i++ )
  21. {
  22. wait 2;
  23. bot = AddTestClient();
  24. bot.pers[ "isBot" ] = true;
  25. bot thread maps\mp\gametypes\_bot::bot_spawn_think( teams[ randomInt( 2 ) ] );
  26. }
  27. wait 0.01;}
  28. }
Have you thread it?
Pages: 1 2