Official Soldat Forums

Server Talk => Scripting Releases => Topic started by: Dirol [RUS] on January 29, 2007, 01:32:56 pm

Title: Auto bot
Post by: Dirol [RUS] 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;
Title: Re: Auto bot
Post by: cooz on January 29, 2007, 01:43:35 pm
Code: [Select]
BotBalanceTeams=1
i'll wait for Enesce to answer 8)
Title: Re: Auto bot
Post by: Dirol [RUS] 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.
Title: Re: Auto bot
Post by: Frenchie 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?
Title: Re: Auto bot
Post by: Dirol [RUS] 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.
Title: Re: Auto bot
Post by: Frenchie 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.
Title: Re: Auto bot
Post by: Dirol [RUS] 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...