Forum

> > CS2D > Scripts > Nemesis Script
Forums overviewCS2D overview Scripts overviewLog in to reply

English Nemesis Script

9 replies
To the start Previous 1 Next To the start

old Nemesis Script

francis007
BANNED Off Offline

Quote
Hey everyone!

I have a zombie script and i have some bugs. It's a script where Nemesis have a own skin/hat... Can someone tell what i forgot to add?

Bug:
- If a player is the Nemesis and there is a restartround then the player have still the skin/hat but he is CT.

I hope someone can help me. Thanks for reading!

old Re: Nemesis Script

Mora
User Off Offline

Quote
Uhm. Maybe you forgot to set a special value to nil or another which requires to freeimage:
1
2
3
4
5
6
7
8
9
function _rr()
	for _,id in pairs(player(0,"table")) do
		if (your_value==number_which_equals_to_allow_script_continue) then
			freeimage(your_image)
			your_image=nil
		end
	end
end
addhook("restartround","_rr")

old Re: Nemesis Script

francis007
BANNED Off Offline

Quote
Here is the script:

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
nemesis_cnt = {}
hatid = {}

addhook("join","cntzero")
function cntzero(id)
nemesis_cnt[id] = 0
hatid[id]=nil
end

addhook("startround","fakfrancis")
function fakfrancis()
for id = 1,32 do
if player(id,"exists") then
freeimage(hatid[id])
nemesis_cnt[id] = 0
end
end
end

addhook("spawn","cntzeros")
function cntzeros(id)
if nemesis_cnt[id] == 1 then
if hatid[id] ~= nil then freeimage(hatid[id]) end
hatid[id]=image("gfx/zombieplague/zombieboss.png",1,1,200+id)
end
end

function zp_nemesis_form()
	local ct_nem = zp_ct_table()
	if (zp_ct_cnt() > 0) then
		zp_snd(math.random(9,10))
		zp_nemesis_id = ct_nem[math.random(1,zp_ct_cnt())]
		local n = zp_nemesis_id
		zp_p_class[n] = -1
		zp_msg(8,player(n,'name')..' is Zombie Boss!@C')
		nemesis_cnt[n] = 1
		hatid[n]=image("gfx/zombieplague/zombieboss.png",1,1,200+n)
		local x = player(n,'x')
		local y = player(n,'y')
		parse('maket '..n)
		parse('spawnplayer '..n..' '..x..' '..y)
		zp_player_hud(n)
		if (zp_hud_flashlight > 0) then	imagealpha(p_light[n],0) end
	end
end

Maybe someone can do it?

old Re: Nemesis Script

Rainoth
Moderator Off Offline

Quote
@user francis007: Only nemesis has the hat? If so, move line 22 to be under line 23.

Here's how it works now.
If nemesis then remove hat
give hat

After moving line 22 to be under 23.
Remove hat
if nemesis then give hat

old Re: Nemesis Script

Mora
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
function _rr()
	for _,id in pairs(player(0,"table")) do
		if hatid[id] then
       		freeimage(hatid[id])
		hatid[id]=nil
		nemesis_cnt[id]=0
		end
	end
end
addhook("restartround","_rr")

and that
1
2
3
4
5
6
7
8
9
addhook("spawn","cntzeros")
function cntzeros(id)
	if nemesis_cnt[id] == 1 then
		if hatid[id] ~= nil then
		freeimage(hatid[id]) 
		end
	hatid[id]=image("gfx/zombieplague/zombieboss.png",1,1,200+id)
	end
end

as you can see whatever if your hatid[id] is nil or not you still add the image..:
1
2
3
4
5
6
7
8
9
addhook("spawn","cntzeros")
function cntzeros(id)
	if nemesis_cnt[id] == 1 then
		if hatid[id] then
		freeimage(hatid[id]) 
		hatid[id]=image("gfx/zombieplague/zombieboss.png",1,1,200+id)
		end
	end
end

old Re: Nemesis Script

francis007
BANNED Off Offline

Quote
I have it!

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
nemesis_cnt = {}
hatid = {}

addhook("join","cntzero")
function cntzero(id)
nemesis_cnt[id] = 0
hatid[id]=nil
end

addhook("endround","_rr")
function _rr()
     for _,id in pairs(player(0,"table")) do
          if hatid[id] then
                 freeimage(hatid[id])
          hatid[id]=nil
          nemesis_cnt[id]=0
          end
     end
end

addhook("spawn","cntzeros")
function cntzeros(id)
     if nemesis_cnt[id] == 1 then
          if hatid[id] ~= nil then
          freeimage(hatid[id]) 
          end
     hatid[id]=image("gfx/zombieplague/zombieboss.png",1,1,200+id)
     end
end

Can someone make that the hat will wiggle if the player wiggles?

old Re: Nemesis Script

Masea
Super User Off Offline

Quote
Quote
• x<=0: do not rotate with player
• x=1: rotate img with player
• x=2: rotate and wiggle img with player
• y<=0: only draw if not covered by fog of war
• y>0: draw always


1
hatid[id]=image("gfx/zombieplague/zombieboss.png",2,1,200+id)

old Re: Nemesis Script

francis007
BANNED Off Offline

Quote
Thank you all!

EDIT: I need again help and i hope someone can do it.

What i want: If the nemesis left the server and if there are still zombies (Players) in the server then a other zombie (Player) will be the new nemesis and not a CT. Thank you if you can do that!

Script:
1
2
3
4
5
6
7
8
9
10
11
12
function zp_leave(p)
	zp_player_reset(p)
	if (zp_nemesis_id == p) then
		zp_nemesis_id = 0
		zp_on_tip = 0
		zp_nemesis_sec = 30
		nemesis_cnt[p] = 0
		zp_p_class[p] = zp_p_last_class[p]
		freeimage(hatid[p])
		zp_msg(4,'Zombie Boss Left The Server - New Zombie boss will be selected in '..zp_nemesis_sec..' seconds!')
	end
end
edited 1×, last 13.12.16 03:04:39 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview