Official Soldat Forums

Server Talk => Scripting Releases => Topic started by: DorkeyDear on June 13, 2007, 11:43:31 am

Title: Lonesome Self Fixer
Post by: DorkeyDear on June 13, 2007, 11:43:31 am
Script Name: Lonesome Self Fixer
Script Description: If you join with nobody else in the server, a random bot will join and entertain you until somebody else joins. If you leave, the bot gets kicked, so he won't wonder around in the server. Script works with both teamed and teamless gamestyles.
Original Author: Curt (DorkeyDear)
Core Version: 2.6.1
Code:
Code: [Select]
var
  Slot: byte;

procedure AddBot(Team: byte);
var
  i: byte;
begin
  Sleep(10);
  Slot := 0;
  i := 1;
  while (Slot = 0) and (i <= 32) do if GetPlayerStat(i,'Active') = false then Slot := i else i := i + 1;
  if (GameStyle = 0) or (GameStyle = 1) or (GameStyle = 4) then Command('/addbot ' + RandomBot) else Command('/addbot' + InttoStr(Team) + ' ' + RandomBot);
  BotChat(Slot,'Welcome! Sense there is nobody else here, so I''ll entertain you for a little while.');
end;

procedure OnJoinTeam(ID, Team: byte);
var
  BotTeam: byte;
begin
  if Team = 1 then BotTeam := 2 else BotTeam := 1;
  if GetPlayerStat(ID,'Human') = true then Case NumPlayers of
    1: if Slot = 0 then ThreadFunc([BotTeam],'AddBot');
    3: if (GetPlayerStat(Slot,'Human') = false) and (Slot <> 0) then KickPlayer(Slot);
  end;
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
  if (GetPlayerStat(ID,'Human') = true) and (NumPlayers = 2) and (Slot = 0) then ThreadFunc([Team],'AddBot');
  if (GetPlayerStat(ID,'Human') = true) and (GetPlayerStat(Slot,'Human') = false) and (Slot <> 0) then KickPlayer(Slot);
  if ID = Slot then Slot := 0;
end;
Note: The ThreadFunc procedure is sometimes buggy and the script may not always add the bot. It is usually buggy when it has a lot of stress (being called many times in small amount of time), and sense it is only called when your by your lonesome self, this shouldn't occur as often as other scripts.
Title: Re: Lonesome Self Fixer
Post by: kornsick on June 13, 2007, 12:01:41 pm
Um.. it says: "[Error] (60:1): Identifier Expected"
I used Soldat Script Combiner with template.
Title: Re: Lonesome Self Fixer
Post by: DorkeyDear on June 13, 2007, 02:11:02 pm
I tried to combine this with the template and it just says "Line #25 -> end;"
I'll check if its my error....

I manually combined a template with this script and it doesn't crash, and seems to work perfectly fine.
Title: Re: Lonesome Self Fixer
Post by: mxyzptlk on June 13, 2007, 02:25:45 pm
So, when someone else joins, the bot is autokicked, as well?
Title: Re: Lonesome Self Fixer
Post by: mikembm on June 13, 2007, 02:34:34 pm
I tried to combine this with the template and it just says "Line #25 -> end;"
I'll check if its my error....

I manually combined a template with this script and it doesn't crash, and seems to work perfectly fine.

Oops. I wasn't anticipating people not starting a "case" statement on a new line.
Updated to fix that bug.
Title: Re: Lonesome Self Fixer
Post by: DorkeyDear on June 13, 2007, 02:44:02 pm
So, when someone else joins, the bot is autokicked, as well?
Yes. Also, if there are 2 humans, and 1 of them leaves, the bot will be added.
Title: Re: Lonesome Self Fixer
Post by: kornsick on June 14, 2007, 11:37:12 am
I combined it manually and it works... thank you.
Title: Re: Lonesome Self Fixer
Post by: DorkeyDear on June 14, 2007, 07:22:09 pm
This still should work in 2.6.2, but sense there is a new feature to the Command function (having a result), I'll be posting the 2.6.2 update here (to save a few lines of unneeded code). Sense its not out yet (at least I don't believe it is), I'll just post it, instead of editing my first post. I'll edit it (if i remember) when 2.6.2 comes out.
Code: [Select]
var
  Slot: byte;

procedure AddBot(Team: byte);
begin
  Sleep(10);
  if (GameStyle = 0) or (GameStyle = 1) or (GameStyle = 4) then Slot := Command('/addbot ' + RandomBot) else Slot := Command('/addbot' + InttoStr(Team) + ' ' + RandomBot);
  BotChat(Slot,'Welcome! Sense there is nobody else here, so I''ll entertain you for a little while.');
end;

procedure OnJoinTeam(ID, Team: byte);
var
  BotTeam: byte;
begin
  if Team = 1 then BotTeam := 2 else BotTeam := 1;
  if GetPlayerStat(ID,'Human') = true then Case NumPlayers of
    1: if Slot = 0 then ThreadFunc([BotTeam],'AddBot');
    3: if (GetPlayerStat(Slot,'Human') = false) and (Slot <> 0) then KickPlayer(Slot);
  end;
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
  if (GetPlayerStat(ID,'Human') = true) and (NumPlayers = 2) and (Slot = 0) then ThreadFunc([Team],'AddBot');
  if (GetPlayerStat(ID,'Human') = true) and (GetPlayerStat(Slot,'Human') = false) and (Slot <> 0) then KickPlayer(Slot);
  if ID = Slot then Slot := 0;
end;
Title: Re: Lonesome Self Fixer
Post by: Martino on July 22, 2007, 02:12:56 am
I think that same function is in server.ini. It's called botbalance but I' m not sure if it kicks bots too.
Title: Re: Lonesome Self Fixer
Post by: Iq Unlimited on July 22, 2007, 02:18:11 am
This is perhaps the saddest code I have ever seen. If your alone in a server then you have no friends xD.

I think that same function is in server.ini. It's called botbalance but I' m not sure if it kicks bots too.
Yes it is basically the same, and yes it does kick the bots.
Title: Re: Lonesome Self Fixer
Post by: DorkeyDear on July 23, 2007, 11:29:05 am
oh, i never saw that there b4 :P now what a pointless script i have just made. i think its buggy too, lol
Title: Re: Lonesome Self Fixer
Post by: zyxstand on July 24, 2007, 11:02:39 am
wot?  There's a botbalance function?  haha i never knew that!
Sry DD... I hate when that happens...
Title: Re: Lonesome Self Fixer
Post by: noerrorsfound on July 26, 2007, 10:48:10 am
This is perhaps the saddest code I have ever seen. If your alone in a server then you have no friends xD.
That isn't true at all. Sometimes the servers with the lowest pings (ping depends on distance between you and the server as well as connection) are empty, and instead of going into a server you know you'll lag in, it's better to go to one with a lower ping and stay for a while to see if someone else joins. Sadly, many people don't do this because being in a server by yourself is boring, and people usually won't join right away.
Title: Re: Lonesome Self Fixer
Post by: Dizzy So 1337 on August 02, 2007, 12:56:59 am
wot?  There's a botbalance function?  haha i never knew that!
Sry DD... I hate when that happens...

FFS!  When did this happen?

I set botbalanceteams=1 in server.ini on my TM server.  Nothing happened.  Help?

ALSO: for the original scriptwriter, hey, maybe there's still gold in your script.  Could you make it so that it adds one bot, you kill him, and it adds 2, you kill them, it adds 3... etc... resets when you die, and you play it for high score.  Or something... anyways, just tryin to cheer u up.
Title: Re: Lonesome Self Fixer
Post by: DorkeyDear on August 02, 2007, 07:15:05 pm
for the original scriptwriter, hey, maybe there's still gold in your script.  Could you make it so that it adds one bot, you kill him, and it adds 2, you kill them, it adds 3... etc... resets when you die, and you play it for high score.  Or something... anyways, just tryin to cheer u up.
Possible... Could make a whole single-player server just on this.. lol, or multiplayer, except it should be very limited to # of people, sense max players is 32 and bots are sometimes kind of easy to kill, so once 2 people hits 10 bots, that means there are only 9 bot slots left for the third player, if the first 2 don't get any more wins... lol..
I would but.. who would actually use it? (I have doubts that people are using my scripts (excluding this 1, sense im pretty sure its buggy, but maybe if I actually see a demand for the script to work :P that might make me work on it.. lol)) plus I have like 100 other things to finish up first.
Title: Re: Lonesome Self Fixer
Post by: Dizzy So 1337 on August 02, 2007, 07:59:18 pm
FFS!  When did this happen?

I set botbalanceteams=1 in server.ini on my TM server.  Nothing happened.  Help?


Help please?
Title: Re: Lonesome Self Fixer
Post by: 1221995 on August 04, 2007, 06:18:53 am
I Like the script. it looks good.
Title: Re: Lonesome Self Fixer
Post by: DorkeyDear on August 04, 2007, 11:09:32 am
I Like the script. it looks good.
I think its bugged. I remember getting it to work before when I made this, but somethign must not be right because I remember like a week ago, I tried putting this onto a server, and the bot joined, then got kicked :P was weird... hopefully ill try to redo this script to make it work.
Title: Re: Lonesome Self Fixer
Post by: nuclearrambo on August 10, 2007, 07:14:08 am
this script has a lot of errors and bugs. plz check it up
Title: Re: Lonesome Self Fixer
Post by: DorkeyDear on August 10, 2007, 12:26:24 pm
i think its buggy too
i know, i've been too lazy to fix.