I need a little help with my code, I am trying to add perks for players like hats, when you press a button a perk appears else if the player has already a perk then freeimage. But when a player leaves or joins my perk dissapears how to fix it? Thanks!
More
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
scale_factor = 1.1 --HOW BIG? sprite = {} function updatePerks(id) for i = 1,#sprite do freeimage(sprite[i]) end 	sprite = {} 	freetimer() end addhook("serveraction","_serveraction") function _serveraction(id,a) 	if a == 1 then 		menu(id,"Choose a Perk,Perk 1|Burning,Perk 2|Green+Blue,Perk 3|White,Perk 4|Red,Perk 5|Blue,Perk 6|Rainbow,Remove Perk") 	end end addhook("menu","_menu") function _menu(id,t,b) 	if t == "Choose a Perk" then 		if b == 1 then 		updatePerks(id) -- Freeimage 			i = #sprite+1 			glow("ptop","gfx/sprites/flare2.bmp",200,id,255,150,000,1,.4,.5) 			glow(i,"gfx/!Infinity!/lua/Perks/crescent.png",100,id,255,100,000,1,1,1.3,nil,-6,255,255,000,2000) 			glow(i,"gfx/!Infinity!/lua/Perks/crescent.png",100,id,255,080,000,1,1,1.3,2000,5,255,200,000,2000) 			timer(200,"parse",'lua "trail('..(1)..','..id..','..(255)..','..(150)..','..(0)..')"',0) 		elseif b == 2 then 		updatePerks(id) 			i = #sprite+1 			glow(i,"gfx/sprites/flare2.bmp",200,id,000,255,000,1,.5,.5,nil,nil,000,000,255,2000) 			glow(i,"gfx/!Infinity!/lua/Perks/crescent.png",100,id,000,255,000,1,.8,1.1,6000,-6,000,000,255,2000) 			glow(i,"gfx/!Infinity!/lua/Perks/crescent.png",100,id,000,255,000,1,.8,1.1,7000,5,000,000,255,2000) 			timer(420,"parse",'lua "trail('..(1)..','..id..','..(0)..','..(0)..','..(255)..')"',0) 			timer(320,"parse",'lua "trail('..(1)..','..id..','..(0)..','..(255)..','..(0)..')"',0) 		elseif b == 3 then 		updatePerks(id) 			i = #sprite+1 			glow(i,"gfx/sprites/flare2.bmp",200,id,255,255,255,1,.5,.5) 			glow(i,"gfx/!Infinity!/lua/Perks/circle.png",100,id,255,255,255,1,.8,1.2,3000,5) 			glow(i,"gfx/!Infinity!/lua/Perks/circle.png",100,id,255,255,255,1,.8,1.2,4000,-5) 			timer(420,"parse",'lua "trail('..(1)..','..id..','..(255)..','..(255)..','..(255)..')"',0) 		elseif b == 4 then 		updatePerks(id) 			i = #sprite+1 			glow(i,"gfx/sprites/flare2.bmp",200,id,255,000,000,1,.4,.5) 			glow(i,"gfx/!Infinity!/lua/Perks/fireball2.png",100,id,255,0,000,1,.8,1.4,3000,5) 			glow(i,"gfx/!Infinity!/lua/Perks/fireball.png",100,id,255,0,000,1,.8,1.4,3000,-8) 			timer(420,"parse",'lua "trail('..(2)..','..id..','..(0)..','..(0)..','..(255)..')"',0) 		elseif b == 5 then 		updatePerks(id) 			i = #sprite+1 			glow(i,"gfx/sprites/flare2.bmp",200,id,000,000,255,1,.4,.5) 			glow(i,"gfx/gui_load.bmp",100,id,0,0,255,1,1,2.3,2000,7) 			timer(420,"parse",'lua "trail('..(1)..','..id..','..(0)..','..(0)..','..(255)..')"',0) 		elseif b == 6 then 		updatePerks(id) 			timer(400,"rainbowtrail",id,0) 			i = #sprite+1 			sprite[i] = image("gfx/sprites/flare2.bmp",0,0,200+id) 			imageblend(sprite[i],1) 			imagealpha(sprite[i],.5) 			imagescale(sprite[i],.4,.4) 			timer(9000,"rainbow2",sprite[i],0) 			i = #sprite+1 			sprite[i] = image("gfx/!Infinity!/lua/Perks/c_circle.png",0,0,100+id) 			imageblend(sprite[i],1) 			imagealpha(sprite[i],1) 			imagescale(sprite[i],1.2,1.2) 			tween_rotateconstantly(sprite[i],5) 			timer(9000,"rainbow",sprite[i],0) 			i = #sprite+1 			sprite[i] = image("gfx/!Infinity!/lua/Perks/circle2.png",0,0,100+id) 			imageblend(sprite[i],1) 			imagealpha(sprite[i],1) 			imagescale(sprite[i],1.0,1.0) 			tween_rotateconstantly(sprite[i],-5) 			timer(9000,"rainbow2",sprite[i],0) 			i = #sprite+1 			sprite[i] = image("gfx/!Infinity!/lua/Perks/circle2.png",0,0,100+id) 			imageblend(sprite[i],1) 			imagealpha(sprite[i],1) 			imagescale(sprite[i],1.2,1.2) 			tween_rotateconstantly(sprite[i],2) 			timer(9000,"rainbow",sprite[i],0) 			timer(4000,"parse",'lua "fade2('..sprite[i]..','..(2000)..')',0) 			i = #sprite+1 			sprite[i] = image("gfx/!Infinity!/lua/Perks/segmented.png",0,0,100+id) 			imageblend(sprite[i],1) 			imagealpha(sprite[i],.5) 			imagescale(sprite[i],1,1) 			tween_rotateconstantly(sprite[i],-10) 			timer(9000,"rainbow3",sprite[i],0) 		elseif b == 7 then 			updatePerks(id) 		end 	end end function glow(i,location,position,id,r,g,b,blend,alpha,scale,fadespeed,rotspeed,cr,cg,cb,cspeed,rot) 	scale = scale * scale_factor 	i = #sprite+1 	sprite[i] = image(location,0,0,position+id) 	imagecolor(sprite[i],r,g,b) 	imageblend(sprite[i],blend) 	imagealpha(sprite[i],alpha) 	imagescale(sprite[i],scale,scale) 	if rot ~= nil then 		imagepos(sprite[i],0,0,rot) 	end 	if fadespeed ~= nil then 		timer(fadespeed*2,"parse",'lua "fade('..sprite[i]..','..(fadespeed)..')',0) 	end 	if rotspeed ~= nil then 		tween_rotateconstantly(sprite[i],rotspeed) 	end 	if cspeed and cr and cb and cg ~= nil then 		timer(cspeed*2,"parse",'lua "color('..sprite[i]..','..(cspeed)..','..(cr)..','..(cg)..','..(cb)..','..(r)..','..(g)..','..(b)..')',0) 	end end function rainbowtrail(id) 	timer(150,"parse",'lua "trail('..(1)..','..id..','..(0)..','..(255)..','..(0)..')"',1) 	timer(300,"parse",'lua "trail('..(1)..','..id..','..(255)..','..(0)..','..(0)..')"',1) 	timer(450,"parse",'lua "trail('..(1)..','..id..','..(0)..','..(0)..','..(255)..')"',1) end function trail(mode,id,r,g,b) 	local x=player(id,"x") 	local y=player(id,"y") 	if x == false then return else 		if mode == 1 then 			parse('effect "flare" '..x..' '..y..' 2 20 '..r..' '..g..' '..b..'') 		elseif mode == 2 then 			parse('effect "fire" '..x..' '..y..' 2 20 '..r..' '..g..' '..b..'') 		elseif mode == 3 then 			parse('effect "smoke" '..x..' '..y..' 15 15 '..r..' '..g..' '..b..'') 		end 	end end function rainbow(i) 	tween_color(i,3000,255,000,000) 	timer(3000,"parse",'lua "tween_color('..i..','..(3000)..','..(000)..','..(255)..','..(000)..')"',1) 	timer(6000,"parse",'lua "tween_color('..i..','..(3000)..','..(000)..','..(000)..','..(255)..')"',1) end function rainbow2(i) 	tween_color(i,3000,000,000,255) 	timer(3000,"parse",'lua "tween_color('..i..','..(3000)..','..(255)..','..(000)..','..(000)..')"',1) 	timer(6000,"parse",'lua "tween_color('..i..','..(3000)..','..(000)..','..(255)..','..(000)..')"',1) end function rainbow3(i) 	tween_color(i,3000,000,255,000) 	timer(3000,"parse",'lua "tween_color('..i..','..(3000)..','..(000)..','..(000)..','..(255)..')"',1) 	timer(6000,"parse",'lua "tween_color('..i..','..(3000)..','..(255)..','..(000)..','..(000)..')"',1) end function fade(i,speed) 	tween_alpha(i,speed,.2) 	timer(speed,"parse",'lua "tween_alpha('..i..','..(speed)..','..(.8)..')"',1) end function fade2(i,speed) 	tween_alpha(i,speed,0) 	timer(speed,"parse",'lua "tween_alpha('..i..','..(speed)..','..(1)..')"',1) end function scale(i,speed,scalesize) 	tween_scale(i,speed,scalesize,scalesize) 	timer(speed,"parse",'lua "tween_scale('..i..','..(speed)..','..(scalesize*1.3)..','..(scalesize*1.3)..')"',1) end function color(i,speed,cr,cg,cb,r,g,b) 	tween_color(i,speed,cr,cg,cb) 	timer(speed,"parse",'lua "tween_color('..i..','..(speed)..','..(r)..','..(g)..','..(b)..')"',1) end addhook("leave","leave") function leave(id) 	updatePerks(0) end addhook("startround","startround") function startround(mode) 	updatePerks(0) end