Files

> > CS2D > Lua Scripts > ¥Weeds¥ Advanced Bot Team Balance v1.4
Files overviewCS2D overviewLua Scripts overview

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

24 comments4 kb, 532 Downloads

old ¥Weeds¥ Advanced Bot Team Balance v1.4

RichNagel
User Off Offline

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)
edited 7×, last 04.01.13 09:58:21 am
Approved by GeoB99

Download Download

4 kb, 532 Downloads

Comments

24 comments
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

old

RichNagel
User Off Offline

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

old

varik
User Off Offline

nice lua script
I like it!

old

RichNagel
User Off Offline

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

old

Blunt
User Off Offline

cool script :d
I like it!

old

Infinite Rain
Reviewer Off Offline

Nice!
Keep it up!
I like it!

old

Crazy Game
BANNED Off Offline

Mafia KAK
I like it!

old

IPC CS2D
User Off Offline

usefull, i need this!
I like it!

old

RichNagel
User Off Offline

Just updated the script (currently version 1.1) with the extremely minor changes that I refered to below.

old

sheeL
User Playing CS2D

@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
I like it!

old

Jynxxx
User Off Offline

@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.

old

Yates
Reviewer Off Offline

@user sheeL: Are you BR or something? - That is basically stealing.

old

RichNagel
User Off Offline

Man, this is all 'greek' to me LOL!

old edit x2

sheeL
User Playing CS2D

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
I like it!
edited 2×, last 21.12.12 06:23:53 pm

old

RichNagel
User Off Offline

@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.

old

Jynxxx
User Off Offline

Shortened down that hideous parse function.

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

old

RichNagel
User Off Offline

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