English freeimage doesn't work as i want

6 replies
Goto Page
To the start Previous 1 Next To the start
Up
acm
User
Offline Off
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.

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
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
06.01.18 11:17:42 am
Up
Bowlinghead
User
Offline Off
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
Share time limited free games here
06.01.18 11:52:42 am
Up
acm
User
Offline Off
This script for me, i dont want to use this script for public. Whats in 60. line why do you say it?
06.01.18 11:58:13 am
Up
DC
Admin
Offline Off
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.
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
06.01.18 02:26:58 pm
Up
script favor
User
Offline Off
not tested.

Spoiler >
06.01.18 02:34:28 pm
Up
DC
Admin
Offline Off
@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.
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
06.01.18 09:51:15 pm
Up
Rainoth
Moderator
Offline Off
should use something like
Code:
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