Forum

> > CS2D > Scripts > Needed Hunger Games Script
Forums overviewCS2D overview Scripts overviewLog in to reply

English Needed Hunger Games Script

4 replies
To the start Previous 1 Next To the start

old Needed Hunger Games Script

G3x
User Off Offline

Quote
Hello dear cs2d community recently ive made a hunger games map but im in need of a script if anyone has spare time to create one for me


im just looking for a free for all, once you die you end up in spectators script

thank you in advanced

old Re: Needed Hunger Games Script

Cebra
User Off Offline

Quote
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
addhook("join","hgjoin")
addhook("leave","hgleave")
addhook("die","hgdie")
addhook("endround","hgend")
addhook("team","hgteam")
addhook("spawn","hgspawn")

function initArray(m)
	local array={}
	for i=1, m do
		array[i]=0
	end
	return array
end

dead=initArray(32)
cht=initArray(32)
chs=initArray(32)
stat=initArray(32)
	
function hgjoin(id)
stat[id]=1
end

function hgleave(id)
	rd[id]=0
	cht[id]=0
end

function hgdie(vid,kid)
	parse("makespec "..vid)
	dead[vid]=1
	if #player(0,"tableliving")==1 then
		parse("sv_restart 5")
	end
end

function hgend()
	for i=1, 32 do
		dead[i]=0
		if cht[i]==1 then
			parse("maket "..i)
		elseif cht[i]==2 then
			parse("makect "..i)
		end
	end
end

function hgteam(id)
if dead[id]==1 then
	return 1
end
end

function hgspawn(id)
if stat[id]==1 then
	cht[id]=player(id,"team")
	chs[id]=player(id,"skin")
	stat[id]=2
end
end

tested, but long time ago
pls report bugs

old Re: Needed Hunger Games Script

GeoB99
Moderator Off Offline

Quote
The user Cebra's code core works as it is intended however there's something that causes C Stack Overflow in a loop when the cs2d lua hook endround hook is called and its function. The line of code (line 39) that causes it is this:
1
for i=1, 32 do
When the hgend function is triggered, the loop itself iterates through all existing players however its argument is invalid for this case. The correct way would just by using cs2d lua cmd player and assign in the bracket parameter the table to iterate all the players in a server.
The Code >

Now it should work properly without issues. Please, post any issue in case if it still persists somehow.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview