Forum

> > CS2D > Scripts > Some image script
Forums overviewCS2D overview Scripts overviewLog in to reply

English Some image script

5 replies
To the start Previous 1 Next To the start

old Some image script

Masea
Super User Off Offline

Quote
Hi guys, I have problem at lua;

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
addhook("drop","silahdusurud")
function silahdusurud(id,iid,ty,ain,a,m,x,y)
if player(id,"health") > 0 and player(id,"weapontype") ~= 50 and Player[id].droptime == 0 then
Player[id].droptime = 3
Player[id].idrop = image('gfx/csgo/hud/hud_alert.png',320,320,2,id)
imagescale(Player[id].idrop,1.6,1)
parse('hudtxt2 '..id..' 1 "©250000000 Alert! " 290 300 1')
parse('hudtxt2 '..id..' 2 "©255255255 You dropped your '..itemtype(ty,"name")..'. " 350 325 1')
end
end

addhook("second","dropitemyok")
function dropitemyok()
for id = 1, 32 do
if Player[id].droptime > 1 then
Player[id].droptime = Player[id].droptime - 1
elseif Player[id].droptime == 1 then
	Player[id].droptime = Player[id].droptime - 1
	tween_alpha(Player[id].idrop,1000,0)
	parse('hudtxtalphafade "..id.." 1 1000 0')
	parse('hudtxtalphafade "..id.." 2 1000 0')
else
	freeimage(Player[id].idrop)
	Player[id].idrop = nil
end
end
end

The second hook not working, why?

Thanks.

old Re: Some image script

Rainoth
Moderator Off Offline

Quote
I didn't notice anything noticeably wrong but I would advise to tab your code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("second","dropitemyok")
function dropitemyok()
	for id = 1, 32 do
		if Player[id].droptime > 1 then
			Player[id].droptime = Player[id].droptime - 1
		elseif Player[id].droptime == 1 then
    			Player[id].droptime = Player[id].droptime - 1
     			tween_alpha(Player[id].idrop,1000,0)
     			parse('hudtxtalphafade "..id.." 1 1000 0')
     			parse('hudtxtalphafade "..id.." 2 1000 0')
		else
     			freeimage(Player[id].idrop)
     			Player[id].idrop = nil
		end
	end
end
and you might want to use
1
for _,id in pairs (player(0,"tableliving")) do
if you make this stuff happen only for alive players.

old Re: Some image script

Rainoth
Moderator Off Offline

Quote
It doesn't make sense. Unless the problem is in another place that you didn't provide. Also, saying 'It's not working' doesn't help much. Does something specific not work or does the second hook function not execute at all or what? Give us more info, we can't know exactly what is wrong and what is right if you don't tell us .-.

old Re: Some image script

Masea
Super User Off Offline

Quote
I am opened cs2d two times for test this lua, when i dropped a weapon in second window (ID 2), this image and this hudtxt appears but dont going for the remove hudtxts and image. In first window(ID 1), image and hudtxts can remove. My question is; why its working just in ID 1, why not other IDs?
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview