Forum

> > CS2D > General > [LUA] Problem with images
Forums overviewCS2D overviewGeneral overviewLog in to reply

English [LUA] Problem with images

2 replies
To the start Previous 1 Next To the start

old [LUA] Problem with images

Holloweye
User Off Offline

Quote
Basicly the code add blood sprites on the ground.

Everything worked fine until I added the remove + fade functions. Before the sprites lay on the ground so it worked. But now they only appear sometimes or not at all. I can't find any problems with it so I thought you guys could help me out here.

Code:
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
local day = 0

----------------------------------------------
-- HIT Sprite                               --
----------------------------------------------
addhook("hit","cs_hit")
function cs_hit(id,source,weapon,hpdmg,apdmg)
	if(source > 0) then
		if(player(id,"team") == 1 and player(source,"team") == 2) then
			x1 = player(id,"x")
			y1 = player(id,"y")
			x2 = player(source,"x")
			y2 = player(source,"y")

			--ANGLE
			angle = 90 + math.atan2(y2 - y1, x2 - x1) * 180 / math.pi
			distance = 0
			time = 0
			weapimg = ""

			if(weapon == 1 or weapon == 2 or weapon == 3 or weapon == 4 or weapon == 5 or weapon == 6 or weapon == 20 or weapon == 21 or weapon == 22 or weapon == 23 or weapon == 24 or weapon == 39 or weapon == 40) then
				weapimg = "Small.bmp"
				distance = 2
				time = 7000
			end
			if(weapon == 10 or weapon == 11) then
				weapimg = "Huge.bmp"
				distance = 5
				time = 20000
			end
			if(weapon == 30 or weapon == 31 or weapon == 32 or weapon == 33 or weapon == 34 or weapon == 38) then
				weapimg = "Medium.bmp"
				distance = 5
				time = 10000
			end
			if(weapon == 35 or weapon == 36 or weapon == 37) then
				weapimg = "Big.bmp"
				distance = 5
				time = 15000
			end
			if(weapon == 50) then
				weapimg = "Tiny.bmp"
				distance = 5
				time = 7000
			end

			x1 = x1 + (math.cos(angle*(math.pi/180)) * distance)
			y1 = y1 + (math.sin(angle*(math.pi/180)) * distance)

			if(time > 0) then
				img=image("gfx/HolloweyesSprites/"..weapimg,x1,y1,0)
				imagepos(img,x1,y1,angle)
				timer(time,"fade1",day.."-"..img)
			end
		end
	end
end


----------------------------------------------
-- REMOVE TIMERS                            --
----------------------------------------------
addhook("endround","cs_endround")
function cs_endround(mode)
	day = day + 1
end

----------------------------------------------
-- FADE FUNCTIONS + REMOVE                  --
----------------------------------------------
function fade1(p)
	pos = string.find(p,"-")
	if(tonumber(string.sub(p,0,pos-1)) == day)then
		imagealpha( tonumber(string.sub(p,pos+1)) ,0.5)
	end
	timer(300,"removeIMG",p)
end

function removeIMG(p)
	pos = string.find(p,"-")
	if(tonumber(string.sub(p,0,pos-1)) == day)then
		freeimage( tonumber(string.sub(p,pos+1)) )
	end
end

Thanks
edited 3×, last 27.04.10 08:12:56 pm
To the start Previous 1 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview