I have a Remove Hat script but since I don't know how to put it on 2 scripts: Well, I have a Menu, the Menu contains 2 more Menus, and the first one says, Hat 1 and the second Hat 2, Well, I want to know how to put the remove hat function to each one, If I press Remove Hat on Hat 1, the first Hat removes, and then on Hat 2, the second hat removes and when I removes one, I can wear another hat but I can't remove again (example: I wear a 1 Hat, I press Remove, ok, it's works. I put 2 Hats, It removes one, and when I press Remove again but on the 2nd Hat Menu, It doesn't remove). Here is my code:
Forum
CS2D Scripts Remove HatsRemove Hats
13 Antworten 1
I have a Remove Hat script but since I don't know how to put it on 2 scripts: Well, I have a Menu, the Menu contains 2 more Menus, and the first one says, Hat 1 and the second Hat 2, Well, I want to know how to put the remove hat function to each one, If I press Remove Hat on Hat 1, the first Hat removes, and then on Hat 2, the second hat removes and when I removes one, I can wear another hat but I can't remove again (example: I wear a 1 Hat, I press Remove, ok, it's works. I put 2 Hats, It removes one, and when I press Remove again but on the 2nd Hat Menu, It doesn't remove). Here is my code:
1
2
3
4
2
3
4
if button == 9 then freeimage(hat[id]) hat[id] = nil end
1
2
3
4
2
3
4
if button >= 1 and button <= 8 then 	freeimage(hat[id]) 	hat[id] = nil end
And I think, the second hook menu part which contains all the button checks must be changed with this code below:
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
addhook("menu","menuaction") function menuaction(id, m, b) if m == "Select A Hat 1" then if b == 1 then -- Devil freeimage(hat[id]) hat[id] = nil hat[id] = image("gfx/iran-town/Angel.png",1,1,200+id) end 	-- And so on...
If any issue or error still occurs, post them here.
1
2
3
4
5
6
7
2
3
4
5
6
7
addhook("menu","menuaction") function menuaction(id, m, b) if m == "Select A Hat 1" then if b == 1 then -- Devil if (hat[id]) then freeimage(hat[id]) end hat[id] = image("gfx/iran-town/Angel.png",1,1,200+id) end
I don't know,this must work
1× editiert, zuletzt 19.11.15 22:35:33
And I'm meaning that the 1st Menu (Hat 1) need to have a Remove function to the hats that are inside there, And on (Hat 2) the same thing, but only on Hat 2 Menu.
If you aren't understanding me: On Hat 1 I wear a Hat, Well, I click on remove hat button, and then the Hat that I chose on Hat 1 will remove. The same thing will occur on Hat 2 but just the hat of Hat 2 will remove
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
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
hat={} for id 1,32 do 	hat[id] = nil end addhook("menu","_2menuaction") function _2menuaction(id,m,b) if m=="Select A Hat 2" then if b==1 then --Angel if hat[id] then freeimage(hat[id]) end -- end if b==2 then --Devil hat[id]=image("gfx/iran-town/Devil.png",1,1,200+id) end if b==3 then --Pirate hat[id]=image("gfx/iran-town/Pirate.png",1,1,200+id) end if b==4 then --Santa hat[id]=image("gfx/iran-town/Santa.png",1,1,200+id) end if b==5 then --Police hat[id]=image("gfx/iran-town/Police.png",1,1,200+id) end if b==6 then --Pumpkin hat[id]=image("gfx/iran-town/Pumpkin.png",1,1,200+id) end if b==7 then --Gandalf hat[id]=image("gfx/iran-town/Gandalf.png",1,1,200+id) end if b==8 then --Spear hat[id]=image("gfx/iran-town/Spear.png",1,1,200+id) end end end
try to use it
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
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
hat = {} for i = 1, 32 do 	hat[i] = {} end addhook("menu","_menu") function _menu(id,t,b) 	if t=="Player Menu 1/3" then 		if b==1 then 			menu(id,"Hats,Hat 1,Hat 2") 		end 	elseif t=="Hats" then 		if b==1 then 			menu(id,"Select A Hat 1,Angel|Hat,Devil|Hat,Pirate|Hat,Santa|Hat,Police|Hat,Pumpkin|Hat,Gandalf|Hat,Remove Hat|X,Next Page |>>") 		elseif b==2 then 			menu(id,"Select A Hat 2,Angel|Hat,Devil|Hat,Pirate|Hat,Santa|Hat,Police|Hat,Pumpkin|Hat,Gandalf|Hat,Remove Hat|X,Next Page |>>") 		end 	elseif m=="Select A Hat 1" then 		if b==1 then 			if hat[id][1] then freeimage(hat[id][1]) end 			hat[id][1]=image("gfx/iran-town/Angel.png",1,1,200+id) 		elseif b==2 then 			if hat[id][1] then freeimage(hat[id][1]) end 			hat[id][1]=image("gfx/iran-town/Devil.png",1,1,200+id) 		elseif b==3 then 			if hat[id][1] then freeimage(hat[id][1]) end 			hat[id][1]=image("gfx/iran-town/Pirate.png",1,1,200+id) 		elseif b==4 then 			if hat[id][1] then freeimage(hat[id][1]) end 			hat[id][1]=image("gfx/iran-town/Santa.png",1,1,200+id) 		elseif b==5 then 			if hat[id][1] then freeimage(hat[id][1]) end 			hat[id][1]=image("gfx/iran-town/Police.png",1,1,200+id) 		elseif b==6 then 			if hat[id][1] then freeimage(hat[id][1]) end 			hat[id][1]=image("gfx/iran-town/Pumpkin.png",1,1,200+id) 		elseif b==7 then 			if hat[id][1] then freeimage(hat[id][1]) end 			hat[id][1]=image("gfx/iran-town/Gandalf.png",1,1,200+id) 		elseif b==8 then --Remove hat 			if hat[id][1] then freeimage(hat[id][1]) end 			hat[id][1] = nil 		end 	elseif m=="Select A Hat 2" then 		if b==1 then 			if hat[id][2] then freeimage(hat[id][2]) end 			hat[id][2]=image("gfx/iran-town/Angel.png",1,1,200+id) 		elseif b==2 then 			if hat[id][2] then freeimage(hat[id][2]) end 			hat[id][2]=image("gfx/iran-town/Devil.png",1,1,200+id) 		elseif b==3 then 			if hat[id][2] then freeimage(hat[id][2]) end 			hat[id][2]=image("gfx/iran-town/Pirate.png",1,1,200+id) 		elseif b==4 then 			if hat[id][2] then freeimage(hat[id][2]) end 			hat[id][2]=image("gfx/iran-town/Santa.png",1,1,200+id) 		elseif b==5 then 			if hat[id][2] then freeimage(hat[id][2]) end 			hat[id][2]=image("gfx/iran-town/Police.png",1,1,200+id) 		elseif b==6 then 			if hat[id][2] then freeimage(hat[id][2]) end 			hat[id][2]=image("gfx/iran-town/Pumpkin.png",1,1,200+id) 		elseif b==7 then 			if hat[id][2] then freeimage(hat[id][2]) end 			hat[id][2]=image("gfx/iran-town/Gandalf.png",1,1,200+id) 		elseif b==8 then --Remove hat 			if hat[id][2] then freeimage(hat[id][2]) end 			hat[id][2] = nil 		end 	end end -- Extra addhook("leave","clearimage") function clearimage(id) 	for a = 1, 2 do 		if hat[id][a] then freeimage(hat[id][a]) 		hat[id][a] = nil 	end end
1× editiert, zuletzt 20.11.15 07:28:06
1