Forum

> > CS2D > Scripts > freeimage doesn't work as i want
Forums overviewCS2D overview Scripts overviewLog in to reply

English freeimage doesn't work as i want

6 replies
To the start Previous 1 Next To the start

old freeimage doesn't work as i want

acm
User Off Offline

Quote
Hi everyone, i make this script. Script is working but it doesn't work as i want.

I want when I choose ninja, the image shouldn't be removed yet when I choose "yay", the other "yay" images should be removed. Please help guys, thank you for your support.

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
addhook("spawn","spawn_hook")
function spawn_hook(id)
parse("equip 1 84")
end

addhook("serveraction","serveraction_hook")
function serveraction_hook(id,act)
if act == 1 then
menu(id,"MAIN MENU,ORK|CLASS,NINJA|CLASS,YAYLAR|Menu,KILICLAR|Menu,ASALAR|Menu,HANCERLER|Menu")
end
end

addhook("menu","menu_hook")
function menu_hook(id,title,button)
if (title == "MAIN MENU") then
if button == 1 then
freeimage(id)
id=image("gfx/ork.PNG",3,0,1+200)
end
if button == 2 then
freeimage(id)
id=image("gfx/ninja.PNG",3,0,1+200)
return 1
end
if button == 3 then
menu(id,"Yay Menu,Aura,Monster Eye,Crimson Web")
end
if button == 4 then
menu(id,"Kilic Menu,Aura,Monster Eye,Crimson Web")
end
if button == 5 then
menu(id,"Asa Menu,Aura,Monster Eye,Crimson Web")
end
if button == 6 then
menu(id,"Hancer Menu,Aura,Monster Eye,Crimson Web")
end
end
if title == "Yay Menu" then
if button == 1 then
menu(id,"Aura Yaylar,AURA|C,AURA|B,AURA|A,AURA|S,AURA|R,AURA|SR")
end
end
if title == "Aura Yaylar" then
if button == 1 then
image("gfx/aura.PNG",3,0,1+200)
end
if button == 2 then
image("gfx/aura2.PNG",3,0,1+200)
end
if button == 3 then
image("gfx/aura3.PNG",3,0,1+200)
end
if button == 4 then
image("gfx/aura4.PNG",3,0,1+200)
end
if button == 5 then
image("gfx/aura5.PNG",3,0,1+200)
end
if button == 6 then
image("gfx/aura6.PNG",3,0,1+200)
end
end
end
edited 2×, last 06.01.18 11:16:27 am

old Re: freeimage doesn't work as i want

Bowlinghead
User Off Offline

Quote
You probably use image for the first time.

The id in which you save it (and what the fuck is about line 60?!) would be for every player the same and therefore there is only 1 guy with a fancy hat

old Re: freeimage doesn't work as i want

DC
Admin Off Offline

Quote
To clarify this a bit more:

You always have to save the return value of cs2d lua cmd image. That return value is the ID you have to use with cs2d lua cmd freeimage and all other images commands.

If you use cs2d lua cmd freeimage with player IDs it will not work properly. It always expects image IDs.

old Re: freeimage doesn't work as i want

script favor
User Off Offline

Quote
not tested.

Spoiler >

old Re: freeimage doesn't work as i want

DC
Admin Off Offline

Quote
@user script favor: That's no solution. If you code compiles (which I'm not sure about) it will just declare and add the same functions 32 times...

Also you're using i for many different things. As loop variable, as function parameter, as return value of image. This will lead to horrible bugs and problems.

old Re: freeimage doesn't work as i want

Rainoth
Moderator Off Offline

Quote
should use something like
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
private = {}

addhook("spawn","_spawn")
function _spawn(id)
	if id == 1 then
		parse("setarmor 1 206")
	end
end

addhook("menu","_menu")
function _menu(id,t,b)
	if t == "MAIN MENU" then
		if b == 1 then
			private[#private+1] = image("gfx/ork.PNG",3,0,1+200)
		end
	end
end

So you're gonna be using the 'private' table to store your images. Do mind that you've got no safety features to prevent others from accessing your menus so others can pretty much set you up with a bunch of images.
Also, somewhere along those lines you can include
freeimage
to free these images.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview