Forum

> > CS2D > Scripts > Kill Player Hud
Forums overviewCS2D overview Scripts overviewLog in to reply

English Kill Player Hud

3 replies
To the start Previous 1 Next To the start

old Kill Player Hud

alex72super
User Off Offline

Quote
Hello everyone,

I tryed to do a script:

When you kill a zombie(a player) it ads one more level to the hud text on your screen.

By searching on the forum i got this far:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
lvl = {}

addhook("objectkill","hi")
function hi(od,id)
     if object(od,"player") == 1 then
          msg("You have leveled up!")
          lvl[id]=lvl[id]+1
     end
end

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

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

Then i tryed to change it to a player not an object(a zombie controlled by the computer).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
lvl = {}

addhook("Killplayer","hi")
function hi(od,id)
     if player(od,"player") =>1 then
          msg("You have leveled up!")
          lvl[id]=lvl[id]+1
     end
end

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

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

But then: LUA ERROR: sys/lua/autorun/hudtxt.lua:5: 'then' expected near '='

old Re: Kill Player Hud

Rainoth
Moderator Off Offline

Quote
That seems like my code.
Anyways.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
lvl = {}

addhook("kill","hi")
function hi(k) -- kiler ID
     if player(k,"team") ==2 then -- if killer is CT (not zombie)
          msg("You have leveled up!")
          lvl[k]=lvl[k]+1 -- add level
     end
end

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

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