Forum

> > CS2D > Scripts > projectile freeimage
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch projectile freeimage

4 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt projectile freeimage

En-Kay
User Off Offline

Zitieren
Ok so this script creates an image on projectile impact which is removed after 450ms,but the problem is when another projectile explodes at the same time,only one image is removed.

here is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
impact = {}

addhook("projectile","arcane")
function arcane (id,weapon,x,y)

	if (weapon==48) then
		impact[id] = image("gfx/sprites/wave.bmp" ,x,y,1)
		imageblend (impact[id],1)
		imagecolor (impact[id],75,75,255)
		tween_scale (impact[id],450,5.0,5.0)
		timer(450,"removeimpact")

		function removeimpact()
		freeimage (impact[id])
		end
	end
end

alt Re: projectile freeimage

Alistaire
User Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
impact = {}
impact.init = 0

addhook("projectile","arcane")
function arcane (id,weapon,x,y)
	function removeimpact(i)
		freeimage (impact[i])
		impact[i] = nil
	end
	if (weapon==48) then
		impact.init = impact.init + 1
		local img = impact.init
		impact[img] = image( "gfx/sprites/wave.bmp", x, y, 1 )
		  imageblend( impact[img], 1 )
		  imagecolor( impact[img], 75, 75, 255 )
		  tween_scale( impact[img], 450, 5.0, 5.0 )
		timer(450, "removeimpact", img)
	end
end

alt Re: projectile freeimage

En-Kay
User Off Offline

Zitieren
This error pops out:

1
LUA ERROR: sys/lua/core/core.lua:31: bad argument #1 to 'freeimage' (number expected, got nil)

alt Re: projectile freeimage

En-Kay
User Off Offline

Zitieren
Ok guys i've fixed it. Just added :

1
freeimage (impact[tonumber(id)])

Anyway, thanks for your help. Appreciate it.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht