English ¥Weeds¥ Advanced Bot Team Balance v1.4 icon

24 comments
21.12.12 03:18:51 pm
like 11 like it!
4 kb, 141 Downloads
RichNagel
User
Offline Off
Advanced Bot Team Balance v1.4

This Lua script for Counter-Strike 2D will automatically add or remove bots to a server in order to maintain a specified number of total players (bots plus humans) within the game.

Settings can be changed (and the script can be enabled or disabled) by issuing simple console commands on a "listen" server (when starting a new game), as well as on a dedicated server via RCon.

Spoiler >
(Click Spoiler for complete readme and usage instructions, also included in the ZIP)
imageimageimageimageimage
edited 7×, last 04.01.13 09:58:21 am
ok This file has been reviewed and approved by Fraizeraust (16.06.16 10:17:30 am)

Comments

24 comments
Goto Page
To the start Previous 1 2 Next To the start

Log in!

You need to log in to be able to write comments!Log in
23.12.12 05:14:33 pm
Up
RichNagel
User
Offline Off
Disreguard my comment below... I'm well on my way to adding config file support


(EDIT) Configuration file support added!

(EDIT 2) v1.4: A few changes here and there (see "Spoiler").
edited 4×, last 02.01.13 02:33:25 pm
23.12.12 02:01:49 pm
like I like it!
Up
varik
User
Offline Off
nice lua script
23.12.12 05:18:13 am
Up
RichNagel
User
Offline Off
Folks,

One thing that I've recently discovered is that CS2D flushes all of the variables in a Lua script when the map cycles on a listen or dedicated server. This resets the main team balancing variable to 5 (the default "bot_balance = 5" line included in the Lua script).

Now, being that the 'bot team balance' can be configured via commands (listen server, as well as RCon for a dedicated server) in the console ("bot_balance 6" etc...), it would be SUPER if there was some way to save it to a config file, and then read the variable from the config file after the map cycles (and the Lua script is re-executed).

Anyhow, could anyone give any pointers on how to:

1 - Open a config file: e.g.

Open the filename "AdvancedBotTeamBalance.cfg" (which would be located in the same directory as the "AdvancedBotTeamBalance.lua" script).

2 - Read a line from the config file (in this case, there would be only one line to store the team balance number... BUT, POSSIBLY two lines; a second for if the team balancing routine is enabled or disabled): e.g.

bot_balance = 4
bot_balance_enabled = 1

3 - Read the "4" from the top line, and then pass it on to the Lua script's variable (as well as the "1" and also pass it on as another Lua script variable).

...and ALSO, WRITE to the config file if/when any of the settings have been changed in-game (listen server, or via RCon).

I've read a LOT from this site -> http://www.lua.org/manual/5.1/manual.html , and I THINK it probably would have something to do with using the "io.open", "io.read", "io.write" commands, etc... but it's WAY over my understanding of Lua coding (unless I could see a simple and an easy-to-understand code example).
edited 3×, last 23.12.12 05:30:57 am
23.12.12 01:56:28 am
like I like it!
Up
Blunt
User
Offline Off
cool script :d
22.12.12 05:53:10 pm
like I like it!
Up
Infinite Rain
Reviewer
Offline Off
Nice!
Keep it up!
22.12.12 11:11:22 am
like I like it!
Up
Crazy Game
BANNED
Offline Off
Mafia KAK
22.12.12 08:16:26 am
like I like it!
Up
IPC CS2D
User
Offline Off
usefull, i need this!
21.12.12 07:46:55 pm
like I like it!
Up
Big Bang Mafia
User
Offline Off
Not bad! 5/5.
21.12.12 07:04:28 pm
Up
RichNagel
User
Offline Off
Just updated the script (currently version 1.1) with the extremely minor changes that I refered to below.
21.12.12 06:51:51 pm
like I like it!
Up
sheeL
User
Offline Off
@user Jynxxx: works, if you think your code so special, why not upload it?, I will not discuss

@user RichNagel: good script man... 5/5
21.12.12 06:34:08 pm
Up
Jynxxx
User
Offline Off
@user sheeL: And yes you copied my method. While changing 3-5 things without my permission. Also your code will not work, deal with it.
21.12.12 06:23:23 pm
like I like it!
Up
sheeL
User
Offline Off
21.12.12 06:06:30 pm
Up
Yates
Reviewer
Offline Off
@user sheeL: Are you BR or something? - That is basically stealing.
21.12.12 05:57:50 pm
Up
RichNagel
User
Offline Off
Man, this is all 'greek' to me LOL!
21.12.12 05:53:36 pm
like I like it!
Up
sheeL
User
Offline Off
@user Jynxxx: stop being stupid
i edited to console command
21.12.12 05:33:58 pm
Up
Jynxxx
User
Offline Off
@user sheeL: your a fucking idiot. I made the code and you just change one little thing. Are you seriously that retarded?


BR? HUEHUEHEUHEUHEUEHUEHEUHEUE
21.12.12 05:07:43 pm
like I like it!
Up
sheeL
User
Offline Off
Code:
1
2
3
4
5
6
7
8
9
10
11
addhook("parse","OnCommand")
addhook("rcon","OnCommand")

function OnCommand(param)
local avg = param:sub(13,14)
     if param == "bot_balance "..avg then
          msg(string.format("©255255255Bot balance has been changed to "..avg))
          botbalance=avg
          return 1
     end
end
edited 2×, last 21.12.12 06:23:53 pm
21.12.12 05:01:39 pm
Up
RichNagel
User
Offline Off
@Jynxxx,

But that is using the "say" command, correct? The first experimental version of the script that I created I was using the "say" command.

But, later decided to use console commands to control the script.
21.12.12 04:57:19 pm
Up
Jynxxx
User
Offline Off
Shortened down that hideous parse function.

Code:
1
2
3
4
5
6
7
8
9
10
11
_balance = 0

addhook("say","_say")
function _say(id,text)
     local botbalance = text:sub(13,14)
     if text == "bot_balance "..botbalance then
          msg("©255255255Bot balance has been change to "..botbalance.."!@C")
          _balance = botbalance
          return 1
     end
end
21.12.12 04:52:13 pm
Up
RichNagel
User
Offline Off
Glad ya'll liked it

As a newbie to CS2D, this was a little feature that I wished that the game had. So... after a little 'crash course' in Lua scripting (and a LOT of cussing LOL!), this is what I came up with

P.S. Look for a slightly updated version later today (will still have the same version number though, 1.0):

I discovered later that it probably would be better to make the 'server join message' ONLY be displayed to the current player that is actually joining the game (verses having that message printed on the screen to ALL of the players on the server when another player joins the game).

Also, I'm gonna add a little clarification about human spectators in the game when the script is running:

Spectators are NOT counted in the 'total players' count... which is by design (and how I prefered it), but I need to clarify that.
To the start Previous 1 2 Next To the start