Forum

> > CS2D > Scripts > First and second zombies
Forums overviewCS2D overview Scripts overviewLog in to reply

English First and second zombies

3 replies
To the start Previous 1 Next To the start

old First and second zombies

Baloon
GAME BANNED Off Offline

Quote
Hello there, it's me again.

I just want whenever round starts, all zombies will be survivors, first and second zombie will be chosen randomly from survivor team.

My code doesn't works as well as I imagine, would someone fix it?
Spoiler >

I am currently off right now, or maybe this code works?
Spoiler >

Difference from code 1 and code 2 are on line 11 and 17.

Cheers.

old Re: First and second zombies

Bowlinghead
User Off Offline

Quote
survivors isnt a table but you treat it as one.
survivors is just a number so you cant do survivors[1].
I would do it like this. There is no need to iterate every player
1
2
local survivors = player(0,"team2")
local target = survivors[math.random(1,#survivors)]
Untested Code >
edited 5×, last 21.08.16 02:58:25 pm

old Re: First and second zombies

Dousea
User Off Offline

Quote
Work on it with my full-logical brain. It may work.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function bvs.start()
	for _, id in ipairs(player(0, "tableliving")) do
		parse("makect " .. id)
	end
	
	local survivors = player(0, "team2")
	
	for rep = 1, 2 do
		local index = math.random(#survivors)
		
		timer(default.settings["Zombie Time"] * 1000, "parse", "maket " .. survivors[index])
		msg(default.colors["red"] .. (rep == 1 and "First" or "Second") .. " zombie is " .. player(survivors[index], "name"))
		
		survivors[index] = nil
	end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview