Forum

> > CS2D > Scripts > How to make multiple freeimage?
Forums overviewCS2D overview Scripts overviewLog in to reply

English How to make multiple freeimage?

1 reply
To the start Previous 1 Next To the start

old How to make multiple freeimage?

Rhaast
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
-- Hook
addhook("sel","wepsel")
-- Function
function wepsel(id,it,m)
	if player(id,"weapon")==50 then
		id1=image("gfx/xdk6gta/fist.bmp",600,73,2)
	else
		freeimage(id1)
	end
	if player(id,"weapon")==4 then
		id2=image("gfx/xdk6gta/pistol.bmp",600,73,2)
	else
		freeimage(id2)
	end
	if player(id,"weapon")==23 then
		id3=image("gfx/xdk6gta/uzi.bmp",600,73,2)
	else
		freeimage(id3)
	end
	if player(id,"weapon")==11 then
		id4=image("gfx/xdk6gta/shotgun.bmp",600,73,2)
	else
		freeimage(id4)
	end
end

Wow i ran out of ideas in description . So guys can you help me how to make a multiple freeimage?

old Re: How to make multiple freeimage?

VADemon
User Off Offline

Quote
Save image IDs to a table whenever you create them:
1
2
3
4
myimages = {} -- creates a new table and deletes /myimages/ if it was already an existing table
myimages.group1 = {
-- [1] = id1, [2] = id2 etc
}

Because if you do so, you can free all images from one group by going through all of them:
1
2
3
4
5
6
7
function freemyimages(groupname)
   if myimages[groupname] then -- check if this group exists
      for i = 1, #myimages[groupname] do
         freeimage(myimages[groupname][i])
      end
   end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview