Forum

> > CS2D > Scripts > Bot join script
Forums overviewCS2D overview Scripts overviewLog in to reply

English Bot join script

8 replies
To the start Previous 1 Next To the start

old Bot join script

Godofwar
User Off Offline

Quote
Can someone make a script where whenever a human joins the bot count gets deducted and whenever the player leaves bot will automatically join.

old Re: Bot join script

DannyDeth
User Off Offline

Quote
Agh, would you please LEARN a thing or two before asking questions? These things are easy, you should be able to do this using your thumbs and someone else's nose in a couple of seconds.

old Re: Bot join script

MikuAuahDark
User Off Offline

Quote
looks hard!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
bots = {}
addhook("join","count")
function count(id)
	if bots>0 then
		parse("kick "..bots[#bots)])
	end
	if player(id,"bot") then
		table.insert(bots,id)
	end
end

addhook("leave","add")
function add(id)
	if player(id,"bot") then
		table.remove(bots,#bots)
	else
		parse("bot_add")
	end
end
untested
edited 1×, last 26.02.12 11:12:07 am

old Re: Bot join script

EngiN33R
Moderator Off Offline

Quote
@user MikuAuahDark: You're trying to compare table to a number. It won't work.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
mbots = 4
bots = {}

for i=1,mbots do
	parse("bot_add")
	table.insert(bots,player(0,"table")[#player(0,"table")])
end

function countplayers()
	local c=0
	for _,i in pairs(player(0,"table")) do
		if not player(i,"bot") then
			c=c+1
		end
	end
	return c
end

addhook("join","checkbots")
function checkbots()
	if bots>0 then
		parse("kick "..bots[#bots])
	end
end

addhook("leave","checkbots2")
function checkbots2()
	local ply=countplayers()
	if ply<mbots then
		parse("bot_add")
	end
end

I think this should work.

old Re: Bot join script

MostAfa
User Off Offline

Quote
You can try this one too..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
bots = 1

addhook('ms100','bot_ms100')
function bot_ms100()
humans = 0
bot_count = 0
	for i = 1,32, 1 do
		if (player(i,'exists')) and (player(i,'bot') == false) then
			humans = humans + 1
		end
	end
	
	for l = 1,32, 1 do
		if (player(l,'exists')) and (player(l,'bot') == true) then
			bot_count = bot_count + 1
		end
	end
		
	if (humans < 2) and (bot_count < bots) then
		for j = 1,bots, 1 do
			parse('bot_add')
		end
	end

	if (humans >= 2) then 
	parse('bot_remove')
	end 
end

old Re: Bot join script

Apache uwu
User Off Offline

Quote
Something like this?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
addhook("leave","_leave")
addhook("log","_log")

function _log(text)
	if string.sub(text,1,22)=="recv join attempt... (" then
		parse("bot_remove")
	end
end

function _leave(id)
	for i=1,game("sv_maxplayers")-#player(0,"table")+1 do
		timer(100,"parse","bot_add")
	end
end

for i=1,game("sv_maxplayers")-#player(0,"table") do
	parse("bot_add")
end

old Re: Bot join script

Suprise
BANNED Off Offline

Quote
I tested it and When i put 15 bot and player join the game then all bot removed!
settings: bots = 15
edited 1×, last 27.02.12 06:11:54 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview