hi guys!
i need some help.
when player joins on server, then remove one bot!
and when player left the game then add one bot!
1
LUA ERROR (ai_onspawn): bots/Standard AI.lua:66: attempt to perform arithmetic on a nil
and this.
1
Freezing bots to stop Lua error msg flood! Use 'bot_freeze 0' to unfreeze bots!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
parse("bot_add_t")
	parse("bot_add_t")
	parse("bot_add_t")
	parse("bot_add_t")
	parse("bot_add_t")
	parse("bot_add_t")
	parse("bot_add_t")
	parse("bot_add_t")
addhook("join","player")
function player()
if player == join then
	parse("remove_bot_t")
	end
end
Thanks! DC Admin Offline
First of all: You are overwriting the CS2D Lua API function player with your own player function. You shouldn't do that because it will lead to a lot of problems (it also causes the error you get I guess). Choose another name for your function.
Secondly:
That line does not make any sense at all. "player" is a function, "join" is not even defined in this context. So why do you compare them for equality? Makes no sense and will always be false (the stuff in the condition will never be executed).
Try this for the join hook function:
1
2
3
4
5
6
addhook("join","playerJoin")
function playerJoin(id)
	if not player(id,"bot") then
		parse("remove_bot_t")
	end
end
Not tested. Also I'm not sure if join is triggered for bots as well. You can remove this condition if it is not triggered for bots. 1× editiert, zuletzt 17.02.14 13:36:08
@ DC: hi man
Admin/Mod Kommentar
Dude.. please don't post random shit which is totally unnecessary and unrelated (Hi btw...) 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
parse("bot_add_t")
parse("bot_add_t")
addhook("join","player")
function player(id)
	if not player(id,"bot") then
		parse("remove_bot_t")
	end
end
addhook("leave","addbot")
function addbot(id)
	if not player(id,"bot") then
		parse("add_bot_t")
	end
end
Not sure if it'll work. Your mistake was that you were using "player" which is a cs2d function to get stuff about players and not actually some check if a person is a player.
EDIT : Ninja'd... DC is right. "player" is a function, not a variable. Also DC and Rainoth, there's no command in CS2D "remove_bot_t", it is "bot_remove_t". This is the right one, I think.
1
2
3
4
5
6
7
8
9
10
11
12
13
addhook("join", "joinhook")
function joinhook (id)
	if (not player(id, "bot")) then
		parse("bot_remove_t")
	end
end
addhook("leave", "leavehook")
function leavehook (id)
	if (not player(id, "bot")) then
		parse("bot_add_t")
	end
end
1× editiert, zuletzt 17.02.14 13:42:50
@ DC & @ Rainoth & @ Dousea:
Join hook will not be triggered if the one who is joining is a bot. @ DC: @ Rainoth: and actually for @ Dousea: he got the right answer, thnx for your help guys
here some it well before i eating it but anyway thank for your helping me thnx again!
EDIT: How about this, when player join on ct then bot remove in ct team then when player join on t team and bot remove from t team..
I give you a lot of cookies!
Thnx.. DC Admin Offline