Forum

> > CS2D > Scripts > NPC kill hud
Forums overviewCS2D overview Scripts overviewLog in to reply

English NPC kill hud

4 replies
To the start Previous 1 Next To the start

old NPC kill hud

Dovahkin
User Off Offline

Quote
I need help on the NPC kill hud.

Whenever you kill a NPC the hud will turn into Kills : 1.
NPC type must be a Soldier.

You'll be surely credited :).

old Re: NPC kill hud

Rainoth
Moderator 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
tbl = {}

addhook("objectkill","hi")
function hi(oid,id)
	for _,npcid in pairs(object(0,"table")) do
		if oid == 30 and object(npcid,"typename")=="Soldier" then
			tbl[id]=tbl[id]+1
		end
	end
end

addhook("second","ih")
function ih()
	for _,id in ipairs(player(0,"table")) do
		parse("hudtxt2 "..id.." 0 'Soldier Kills: "..tbl[id].."' 99 99 0")
	end
end

addhook("join","_join")
function _join(id)
	tbl[id]=0
end

Untested.

old Re: NPC kill hud

Dovahkin
User Off Offline

Quote
Doesn't work at all. Even the hudtxt2 is absolute fail.

Edit! :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
addhook("objectkill","obj")
function obj(id)
		xp[id] = xp[id]+1
		ipi(id)
		if xp[id] >=10 then
			xp[id]=0
			lvl[id] = lvl[id]+1
			msg2(id,"©128128064You leveled up!@C")
			lvls(id)
		end
		if lvl[id] >=2 then
			stats[id] = stats[id]+1
			stas(id)
		end
		if stats[id] >=2 then
		stas1(id)
		msg2(id,"©064000064You're now a Newbie!@C")
		parse('hudtxt2 '..id..' 7 "©128064000Status : Newbie" 13 360')
		end
end
This one works but it doesn't add the Experience bar the normal way. Whenever I kill 5 npc's it gives 1 experience only. I want it to be 1 npc kill = 1 experience.

old Re: NPC kill hud

Rainoth
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
tbl = {}

addhook("objectkill","hi")
function hi(od,id)
	if object(od,"player") == 5 then
		msg("hue")
		tbl[id]=tbl[id]+1
	end
end

addhook("second","ih")
function ih()
     for _,id in ipairs(player(0,"table")) do
          parse('hudtxt2 '..id..' 0 "Soldier Kills: '..tbl[id]..'" 99 99 0')
     end
end

addhook("join","_join")
function _join(id)
     tbl[id]=0
end
Works. Tested.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview