Author Topic: Auto bot  (Read 3049 times)

0 Members and 1 Guest are viewing this topic.

Offline Dirol [RUS]

  • Major(1)
  • Posts: 5
Auto bot
« on: January 29, 2007, 01:32:56 pm »
Sorry if it was anywhere

Script Name: Auto Bot
Script Description: A simple script that automatically add\deletes bots if there is only a one player on server.
Core Version: 2.5.2

Code: [Select]

//Scropt written by Dirol [RUS]

procedure EndTrain();
begin
    Command ('/kick Boogie Man');
    Command ('/kick Kruger');
    Command ('/kick Sniper');
    Command ('/kick Dutch');
    Command ('/kick Admiral');
    Command ('/kick Terminator');
    Command ('/kick John');
    Command ('/kick Billy');
    Command ('/kick Danko');
    Command ('/kick Poncho');
    Command ('/kick D Dave');
    Command ('/kick Blain');
    Command ('/kick Srg. Mac');
    Command ('/kick Stevie');
    Command ('/kick Roach');
    Command ('/kick Commando');
    Command ('/kick Zombie');
end;

procedure OnJoinTeam(IP, Nickname: string;Team: byte);
begin
  Command('/pm '+inttostr(NameToID(Nickname))+' Say !commands to view a list of available commands');

  if (NumPlayers=1) then
  begin
    if (Team=1) then Command('/addbot2 '+RandomBot);
    if (Team=2) then Command('/addbot1 '+RandomBot);
  end;

  if (NumPlayers-NumBots=2) then
    EndTrain();
  if (NumPlayers=0) then
    EndTrain();

end;

procedure OnLeaveGame(IP, Nickname: string;Team: byte);
begin
  if (NumPlayers=1) then
  begin
    if (Team=1) then Command('/addbot1 '+RandomBot);
    if (Team=2) then Command('/addbot2 '+RandomBot);
  end;

  if (NumPlayers=NumBots) then
    EndTrain();
end;

procedure OnPlayerSpeak(Name,Text: string);
begin
  if (Text='!addbotA') then //some manual manipulations, which are accessible to players
  begin
    Command('/say Random bot has been added to Alpha team. Type !end to remove all bots');
    Command('/addbot1 '+RandomBot);
  end;

  if (Text='!addbotB') then
  begin
    Command('/say Random bot has been added to Bravo team. Type !end to remove all bots');
    Command('/addbot2 '+RandomBot);
  end;
  if (Text='!end') then //player can manually delete all bots, by saying !end
  begin
    Command ('/say '+Name+' has ended training');
    EndTrain();
  end;

end;
« Last Edit: January 29, 2007, 02:18:19 pm by Dirol [RUS] »

Offline cooz

  • Soldier
  • **
  • Posts: 187
  • BANNED
Re: Auto bot
« Reply #1 on: January 29, 2007, 01:43:35 pm »
Code: [Select]
BotBalanceTeams=1
i'll wait for Enesce to answer 8)
Dead man! Dead man walking! We got a dead man walking here! Banned man crawling more like

Offline Dirol [RUS]

  • Major(1)
  • Posts: 5
Re: Auto bot
« Reply #2 on: January 29, 2007, 02:16:49 pm »
rofl

My script has one differ.
My script will auto balance teams by bot only when it only one player.

Offline Frenchie

  • Camper
  • ***
  • Posts: 358
  • SoldatHQ
Re: Auto bot
« Reply #3 on: January 30, 2007, 03:02:40 am »
Cool might try it one day.  :)
Just had a quick look at script, correct me if I'm wrong but (I know it sounds silly) whas happens if theres already a player in the server and the second player joins the same team and quits, will this add a bot to the same team?
Soldat Lobby Avec Players -New Release! - Updated AGAIN!


Offline Dirol [RUS]

  • Major(1)
  • Posts: 5
Re: Auto bot
« Reply #4 on: January 30, 2007, 07:30:58 am »
Yes, it would be like that. I've tested it )

It replenishes the player, which leaved.
The player which left on server always can change his team.
« Last Edit: January 30, 2007, 07:34:31 am by Dirol [RUS] »

Offline Frenchie

  • Camper
  • ***
  • Posts: 358
  • SoldatHQ
Re: Auto bot
« Reply #5 on: January 31, 2007, 12:54:03 am »
Ok just changed it quickly.
Code: [Select]

  if (NumPlayers=1) then
  begin
    if (AlphaPlayers=1) then Command('/addbot2 '+RandomBot);
    if (BravoPlayers=1) then Command('/addbot1 '+RandomBot);
  end;

i think changing your code to this would make it fool proof.
Soldat Lobby Avec Players -New Release! - Updated AGAIN!


Offline Dirol [RUS]

  • Major(1)
  • Posts: 5
Re: Auto bot
« Reply #6 on: January 31, 2007, 05:48:36 am »
Yeah, it will be better a bit. But not a lot.
I think now, how to avoid error, when the 2-nd player not leaves, but get kicked or banned. Cause it is not "OnLeave" event and my script just doesn't being executed at proper times...