Forum

> > CS2D > Scripts > [REQ] Hud images
Forums overviewCS2D overview Scripts overviewLog in to reply

English [REQ] Hud images

15 replies
To the start Previous 1 Next To the start

old [REQ] Hud images

Xseba360
User Off Offline

Quote
Hello,
Could anyone make a script that:
> When you spawn, there is image on your hud ( gfx/hud/CSS_n.png)
> When you use weapon that doesn't require ammo like knife, chainsaw, portalgun (the ammo bar is invis) it shows another image ( gfx/hud/CSS_k.png )
> When you die, it disappears, so it doesn't stay in hud when you spectate.
> Works on listenserver (from other thread i learned cs2d lua hook startround isnt called when on listenserver)
Both of the images are PNGs and are 640x480
This is gonna be included in mod of mine so if you want i'll put you in the credits...

old Re: [REQ] Hud images

Alistaire
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
-- add all melee stuff in huditms
huditms = {}
huditms[50] = 1
huditms[69] = 1

hud = {}
for i = 1, 32 do hud[i] = 0 end

addhook('spawn', 'AA_spawn')
addhook('select', 'AA_select')

function AA_hud(id, t)
	hud[id] = image('gfx/hud/CSS_'..t..'.png', 320, 240, 2, id)
end

function AA_spawn(id)
	local c = false
	for i = 1, #huditms do
		if huditms[i] == player(id, 'weapontype') then
			AA_hud(id, 'k')
			c = true
			break
		end
	end
	if c == false then
		AA_hud(id, 'n')
	end
end

function AA_select(id, type)
	freeimage(hud[id])
	if huditms[type] == 1 then
		AA_hud(id, 'k')
	else
		AA_hud(id, 'n')
	end
end

EDIT

EDIT 2

I see what you want to do, this should work.
edited 2×, last 03.08.12 07:17:57 pm

old Re: [REQ] Hud images

Xseba360
User Off Offline

Quote
@user Alistaire
EDIT:
That sorta doesnt work either...
I'll upload the images and screenshot how does it look ingame.
https://dl.dropbox.com/u/19656788/cs2d/de_dust2_css_rc2_00000.png
https://dl.dropbox.com/u/19656788/cs2d/de_dust2_css_rc2_00001.png
https://dl.dropbox.com/u/19656788/cs2d/CSS_n.png
https://dl.dropbox.com/u/19656788/cs2d/CSS_k.png
EDIT2:
when i switch back from knife to pistol it's fine but when i switch back it's again like on screenshot 2
edited 2×, last 03.08.12 05:20:10 pm

old Re: [REQ] Hud images

omg
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
hud={}
melee={50,41,69,74,78,85}

addhook("startround","rofl_mao")
function rofl_mao()
	for id=1,32 do
		hud[id]=image("gfx/hud/CSS_n.png",0,1,200+id,id)
	end
end

addhook("select","prized_potato")
function prized_potato(id,weapon)
	freeimage(hud[id])
	for _,match in pairs(melee) do
		if weapon==match then
			hud[id]=image("gfx/hud/CSS_k.png",0,1,200+id,id)
			return
		end
	end
	hud[id]=image("gfx/hud/CSS_n.png",0,1,200+id,id)
end

rofl_mao()
edited 1×, last 04.08.12 06:09:14 pm

old Re: [REQ] Hud images

Alistaire
User Off Offline

Quote
user omg has written
Spoiler >


Your script does this:

- triggers startround once
- on startround everyone gets the same hud
- if someone selects, first the image gets freed
- if the weapon matches a weapon in the table use a melee hud
- then, just add another random image over the melee image (if it's there), making it impossible to free it

Bitchplease.

old Re: [REQ] Hud images

omg
User Off Offline

Quote
r u dumb or something? the function returns if it finds a melee match. u always let urself get corrected by me so easily

old Re: [REQ] Hud images

Alistaire
User Off Offline

Quote
user omg has written
r u dumb or something? the function returns if it finds a melee match. u always let urself get corrected by me so easily


You're wrong on this one.

old Re: [REQ] Hud images

omg
User Off Offline

Quote
how am i wrong? the compiler skips over my returns? bitchplease
edited 1×, last 04.08.12 09:33:24 pm

old Re: [REQ] Hud images

omg
User Off Offline

Quote
oh woops, replace the +200s with +132
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
hud={}
melee={50,41,69,74,78,85}

addhook("startround","rofl_mao")
function rofl_mao()
     for id=1,32 do
          hud[id]=image("gfx/hud/CSS_n.png",0,1,132+id,id)
     end
end

addhook("select","prized_potato")
function prized_potato(id,weapon)
     freeimage(hud[id])
     for _,match in pairs(melee) do
          if weapon==match then
               hud[id]=image("gfx/hud/CSS_k.png",0,1,132+id,id)
               return
          end
     end
     hud[id]=image("gfx/hud/CSS_n.png",0,1,132+id,id)
end

rofl_mao()

old Re: [REQ] Hud images

omg
User Off Offline

Quote
oh. try using alistaires image setup then:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
hud={}
melee={50,41,69,74,78,85}

addhook("startround","rofl_mao")
function rofl_mao()
     for id=1,32 do
          hud[id]=image('gfx/hud/CSS_n.png', 320, 240, 2, id)
     end
end

addhook("select","prized_potato")
function prized_potato(id,weapon)
     freeimage(hud[id])
     for _,match in pairs(melee) do
          if weapon==match then
               hud[id]=image('gfx/hud/CSS_k.png', 320, 240, 2, id)
               return
          end
     end
     hud[id]=image('gfx/hud/CSS_n.png', 320, 240, 2, id)
end

rofl_mao()

old Re: [REQ] Hud images

Alistaire
User Off Offline

Quote
user omg has written
1
[b]hud[id]=image('gfx/hud/CSS_n.png', 320, 240, 2, id)


You really don't get it do you. This line is wrongly placed.

old Re: [REQ] Hud images

omg
User Off Offline

Quote
alistaire, i have no idea what ur talking about. at least clarify if u think im wrong
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview