Forum

> > CS2D > Scripts > When player join remove bots!
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch When player join remove bots!

8 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt When player join remove bots!

M0BSTAZ
User Off Offline

Zitieren
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! cookie

alt Re: When player join remove bots!

DC
Admin Off Offline

Zitieren
First of all: You are overwriting the CS2D Lua API function cs2d lua cmd 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:
1
if player == join then
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 cs2d lua hook 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 cs2d lua hook 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

alt Re: When player join remove bots!

Rainoth
Moderator Off Offline

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

alt Re: When player join remove bots!

Dousea
User Off Offline

Zitieren
user DC is right. "player" is a function, not a variable. Also user DC and user 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

alt Re: When player join remove bots!

M0BSTAZ
User Off Offline

Zitieren
@user DC: @user Rainoth: and actually for @user Dousea: he got the right answer, thnx for your help guys

here some cookies 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..
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht