The error message was "LUA ERROR: attempt to call a nil value".
It didn't tell what line, I took me hours trying to find the line.
Script
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
----------------------------------- -----TANK MOD v0.1-----BY JELO----- ----------------------------------- --Change damage parse("mp_wpndmg rpglauncher 65") parse("mp_wpndmg knife 0") parse("mp_hud 64") --Set variables function initArray(m) 	local array = {} 	for i = 1, m do 		array[i]=0 	end 	return array end tankrot=initArray(32) tankimg=initArray(32) tankpic=initArray(32) tankatk=initArray(32) uphealth=initArray(32) upspeed=initArray(32) uprate=initArray(32) special=initArray(32) oldx=initArray(32) oldy=initArray(32) points=initArray(32) rect=initArray(32) round=initArray(32) tri=initArray(32) oct=initArray(32) dual=initArray(32) shape=initArray(32) rects=initArray(32) rounds=initArray(32) duals=initArray(32) tris=initArray(32) octs=initArray(32) leave=initArray(32) alpha=initArray(32) dead=initArray(32) hud=initArray(32) bar=initArray(32) --Upgrade menu function tank_upgrade(id) 	menu(id,"Upgrade Tank: 12 Points = Upgrade@b,Tank Health|Level "..uphealth[id].." / 5,Tank Speed|Level "..upspeed[id].." / 5,Firing Speed|Level "..uprate[id].." / 5")	 end function tank_shop(id) 	menu(id,"Tank Shop@b,Rectangle Cannon|"..rect[id]..",Round Cannon|"..round[id]..",Triangle Cannon|"..tri[id]..",Octagon Cannon|"..oct[id]..",Dual Rocket|"..dual[id]) end --Launch rocket on attack addhook("attack","tank_attack") function tank_attack(id) 	--Check if done reloading 	if tankatk[id]==1 then 		--Shoot rocket and reload 		timer(1500-uprate[id]*100,"tank_reload",tostring(id)) 		parse("spawnprojectile "..id.." 47 "..player(id,"x").." "..player(id,"y").." 265 "..player(id,"rot")) 		tankatk[id]=0 	end 	--Remove other weapons 	if player(id,"weapon")~=50 then 		parse("strip "..id.." "..player(id,"weapon")) 		parse("equip "..id.." 50") 		parse("setweapon "..id.." 50") 	end end --Special Attack addhook("attack2","tank_attack2") function tank_attack2(id) 	--Check if done reloading 	if tankatk[id]==1 then 		--Shoot rocket and reload 		if special[id]==1 then 			timer(1500-uprate[id]*100,"tank_reload",tostring(id)) 			parse("spawnprojectile "..id.." 47 "..player(id,"x").." "..player(id,"y").." 265 "..player(id,"rot")-1) 			parse("spawnprojectile "..id.." 47 "..player(id,"x").." "..player(id,"y").." 265 "..player(id,"rot")+1) 			special[id]=0 			dual[id]="2 Points" 			tankatk[id]=0 		end 	end 	--Remove other weapons 	if player(id,"weapon")~=50 then 		parse("strip "..id.." "..player(id,"weapon")) 		parse("equip "..id.." 50") 		parse("setweapon "..id.." 50") 	end end --Reload Rocket function tank_reload(id) 	tankatk[tonumber(id)]=1 end --Upgrade menu on F4, Shop on F3 addhook("serveraction","tank_serveraction") function tank_serveraction(id,action) 	if action==2 then 		--Open menu 		tank_shop(id) 	elseif action==3 then 		--Open menu 		tank_upgrade(id) 	end end --Upgrade menu functions addhook("menu","tank_menu") function tank_menu(id,menu,sel) 	if (menu=="Upgrade Tank: 12 Points = Upgrade") then 		if (sel==1) then 			if points[id]>=12 and uphealth[id]<5 then 				points[id]=points[id]-12 				uphealth[id]=uphealth[id]+1 				msg2(id,"©000255000You have upgraded your tank!") 				parse("setmaxhealth "..id.." "..(100+uphealth[id]*10)) 			elseif points[id]<12 then 				msg2(id,"©255000000You need 15 points to upgrade your tank!") 			else 				msg2(id,"©255000000It is already fully upgraded!") 			end 		elseif (sel==2) then 			if points[id]>=12 and upspeed[id]<5 then 				points[id]=points[id]-12 				upspeed[id]=upspeed[id]+1 				msg2(id,"©000255000You have upgraded your tank!") 				parse("speedmod "..id.." "..(-20+upspeed[id])) 			elseif points[id]<12 then 				msg2(id,"©255000000You need 15 points to upgrade your tank!") 			else 				msg2(id,"©255000000It is already fully upgraded!") 			end 		elseif (sel==3) then 			if points[id]>=12 and uprate[id]<5 then 				points[id]=points[id]-12 				uprate[id]=uprate[id]+1 				msg2(id,"©000255000You have upgraded your tank!") 			elseif points[id]<15 then 				msg2(id,"©255000000You need 15 points to upgrade your tank!") 			else 				msg2(id,"©255000000It is already fully upgraded!") 			end 		end 	elseif (menu=="Tank Shop") then 		if (sel==1) then 			if rect[id]=="Inactive" then 				if shape[id]==1 then 					round[id]="Inactive" 				elseif shape[id]==2 then 					tri[id]="Inactive" 				elseif shape[id]==3 then 					oct[id]="Inactive" 				end 				rect[id]="Active" 				shape[id]=0 				msg2(id,"©000255000You have changed your tank!") 			end 		elseif (sel==2) then 			if round[id]=="Inactive" then 				if shape[id]==0 then 					rect[id]="Inactive" 				elseif shape[id]==2 then 					tri[id]="Inactive" 				elseif shape[id]==3 then 					oct[id]="Inactive" 				end 				round[id]="Active" 				shape[id]=1 				msg2(id,"©000255000You have changed your tank!") 			elseif round[id]=="7 Points" then 				if points[id]>=7 then 					if shape[id]==0 then 						rect[id]="Inactive" 					elseif shape[id]==2 then 						tri[id]="Inactive" 					elseif shape[id]==3 then 						oct[id]="Inactive" 					end 					points[id]=points[id]-7 					round[id]="Active" 					shape[id]=1 					msg2(id,"©000255000You have changed your tank!") 				else 					msg2(id,"©255000000You need 7 points buy this tank!") 				end 			end 		elseif (sel==3) then 			if tri[id]=="Inactive" then 				if shape[id]==0 then 					rect[id]="Inactive" 				elseif shape[id]==1 then 					round[id]="Inactive" 				elseif shape[id]==3 then 					oct[id]="Inactive" 				end 				tri[id]="Active" 				shape[id]=2 				msg2(id,"©000255000You have changed your tank!") 			elseif tri[id]=="7 Points" then 				if points[id]>=7 then 					if shape[id]==0 then 						rect[id]="Inactive" 					elseif shape[id]==1 then 						round[id]="Inactive" 					elseif shape[id]==3 then 						oct[id]="Inactive" 					end 					points[id]=points[id]-7 					tri[id]="Active" 					shape[id]=2 					msg2(id,"©000255000You have changed your tank!") 				else 					msg2(id,"©255000000You need 7 points buy this tank!") 				end 			end 		elseif (sel==4) then 			if oct[id]=="Inactive" then 				if shape[id]==0 then 					rect[id]="Inactive" 				elseif shape[id]==1 then 					round[id]="Inactive" 				elseif shape[id]==2 then 					tri[id]="Inactive" 				end 				oct[id]="Active" 				shape[id]=3 				msg2(id,"©000255000You have changed your tank!") 			elseif oct[id]=="7 Points" then 				if points[id]>=7 then 					if shape[id]==0 then 						rect[id]="Inactive" 					elseif shape[id]==1 then 						round[id]="Inactive" 					elseif shape[id]==2 then 						tri[id]="Inactive" 					end 					points[id]=points[id]-7 					oct[id]="Active" 					shape[id]=3 					msg2(id,"©000255000You have changed your tank!") 				else 					msg2(id,"©255000000You need 7 points buy this tank!") 				end 			end 		elseif (sel==5) then 			if dual[id]=="2 Points" then 				if points[id]>=2 then 					points[id]=points[id]-2 					dual[id]="Ready" 					special[id]=1 					msg2(id,"©000255000Right-Click to launch the dual rocket!") 				else 					msg2(id,"©255000000You need 2 points buy the dual rocket!") 				end 			elseif dual[id]=="Ready" then 				msg2(id,"©000255000Right-Click to launch the dual rocket!") 			end 		end 	end end --Every 5 frames addhook("ms100","tank_always") function tank_always() 	--Get player IDs 	local playerlist=player(0,"table") 	for _,id in pairs(playerlist) do 		local x 		local y 		if player(id,"exists") then 			x=player(id,"x") 			y=player(id,"y") 		else 			x=-640 			y=-640 		end 		--Draw tank base 		freeimage(tankimg[id]) 		if player(id,"team")==1 and player(id,"health")>0 then 			--Red if T 			tankimg[id]=image("gfx/JeloTanks/tbase.png",0,0,1) 		elseif player(id,"team")>=2 and player(id,"health")>0 then 			--Blue if CT 			tankimg[id]=image("gfx/JeloTanks/ctbase.png",0,0,1) 		end 		imagepos(tankimg[id],x,y,tankrot[id]) 		--Draw tank cannon 		freeimage(tankpic[id]) 		if player(id,"team")==1 and player(id,"health")>0 then 			--Red it T 			tankpic[id]=image("gfx/JeloTanks/tcannon_"..shape[id]..".png",0,0,1) 		elseif player(id,"team")>=2 and player(id,"health")>0 then 			--Blue if CT 			tankpic[id]=image("gfx/JeloTanks/ctcannon_"..shape[id]..".png",0,0,1) 		end 		imagepos(tankpic[id],x,y,player(id,"rot")) 		--Remove other weapons 		if player(id,"weapon")~=50 then 			parse("strip "..id.." "..player(id,"weapon")) 			parse("equip "..id.." 50") 			parse("setweapon "..id.." 50") 		end 		--Calculate base rotation 		if (oldx[id]>x and oldy[id]==y) or (oldx[id]<x and oldy[id]==y) then 			tankrot[id]=90 		elseif (oldx[id]==x and oldy[id]>y) or (oldx[id]==x and oldy[id]<y) then 			tankrot[id]=0 		elseif (oldx[id]<x and oldy[id]<y) or (oldx[id]>x and oldy[id]>y) then 			tankrot[id]=135 		elseif (oldx[id]>x and oldy[id]<y) or (oldx[id]<x and oldy[id]>y) then 			tankrot[id]=45 		end 		oldx[id]=x 		oldy[id]=y 		--Remove images at death 		if dead[id]==1 then 			imagealpha(tankimg[id],0) 			imagealpha(tankpic[id],0) 			freeimage(tankimg[id]) 			freeimage(tankpic[id]) 		end 		 	end 	--Remove images when leaving 	for i=1,32 do 		if player(i,"exists") then 			alpha[i]=1 		else 			alpha[i]=0 		end 		imagealpha(tankimg[i],alpha[i]) 		imagealpha(tankpic[i],alpha[i]) 	end 	--Check if living 	local playerlist=player(0,"tableliving") 	for _,pd in pairs(playerlist) do 		dead[pd]=0 	end end --HUD images addhook("hit","tank_hit") function tank_hit(id) 	freeimage(bar[id]) 	bar[id]=image("gfx/JeloTanks/inbar.png",0,0,2,id) 	imagecolor(bar[id],math.min(0,((player(id,"maxhealth")*(255/player(id,"maxhealth")))-(player(id,"health")*(255/player(id,"maxhealth"))))),math.max(255,(player(id,"health")*(255/player(id,"maxhealth")))),0) 	imagealpha(bar[id],0.5) 	imagescale(bar[id],player(id,"health")/player(id,"maxhealth"),1) 	imagepos(bar[id],320-((player(id,"maxhealth")-player(id,"health"))*(318/player(id,"maxhealth"))),454,0) end --Check kill addhook("kill","tank_kill") function tank_kill(id,killer,victim) 	dead[victim]=0 	--Check if suicide 	if id~=victim then 		--Give tank points 		points[id]=points[id]+1 		parse('hudtxt2 '..id..' 1 "©255255255Tank Points: '..points[id]..'" 5 410 0') 	end end --Remove images when dead addhook("die","tank_die") function tank_die(id) 	dead[id]=1 end --Values set on spawn addhook("spawn","tank_spawn") function tank_spawn(id) 	dead[id]=0 	tankatk[id]=1 	tankrot[id]=math.random(0,3)*45 	parse("setmaxhealth "..id.." "..(100+uphealth[id]*10)) 	parse("speedmod "..id.." "..(-20+upspeed[id])) 	--HUD images 	freeimage(bar[id]) 	bar[id]=image("gfx/JeloTanks/inbar.png",0,0,2,id) 	imagecolor(bar[id],math.min(0,((player(id,"maxhealth")*(255/player(id,"maxhealth")))-(player(id,"health")*(255/player(id,"maxhealth"))))),math.max(255,(player(id,"health")*(255/player(id,"maxhealth")))),0) 	imagealpha(bar[id],0.5) 	imagescale(bar[id],player(id,"health")/player(id,"maxhealth"),1) 	imagepos(bar[id],320-((player(id,"maxhealth")-player(id,"health"))*(318/player(id,"maxhealth"))),454,0) end --No dropping addhook("drop","tank_drop") function tank_drop(id,x,y) 	return 1 end --No buying addhook("buy","tank_buy") function tank_drop(id,x,y) 	return 1 end --No collecting addhook("walkover","tank_walkover") function tank_walkover(id,iid,type) 	--Collect medikits, money, etc. 	if (type>=61 and type<=68) then 		return 0 	--Collect flags 	elseif (type>=70 and type<=71) then 		return 0 	end 	--Don't collect other weapons 	return 1 end addhook("join","tank_join") function tank_join(id) 	--HUD images 	freeimage(hud[id]) 	hud[id]=image("gfx/JeloTanks/bar.png",0,0,2,id) 	imagealpha(hud[id],0.8) 	imagepos(hud[id],320,454,0) 	freeimage(bar[id]) 	--IT'S ALIVE!!! MUHAHAHAHAHA!!!!! 	alpha[id]=1 	--Load data 	tank_load(id) end --Player leaves server addhook("leave","tank_leave") function tank_leave(id) 	alpha[id]=0 	--Save data 	tank_save(id) end --Save data function tank_save(id) 	if rect[id]=="Active" then rects[id]=0 else rects[id]=1 end 	if round[id]=="Active" then rounds[id]=0 elseif round[id]=="Inactive" then rounds[id]=1 else rounds[id]=2 end 	if tri[id]=="Active" then tris[id]=0 elseif tri[id]=="Inactive" then tris[id]=1 else tris[id]=2 end 	if oct[id]=="Active" then octs[id]=0 elseif oct[id]=="Inactive" then octs[id]=1 else octs[id]=2 end 	if duals[id]=="Ready" then duals[id]=0 else duals[id]=1 end 	if (player(id,"exists")) and (player(id,"usgn")>0) then 		f=assert(io.open("sys/lua/JeloTanks/Save Data/"..player(id,"usgn")..".sav","w")) 		f:write(uphealth[id].." "..upspeed[id].." "..uprate[id].." "..points[id].." "..rects[id].." "..rounds[id].." "..tris[id].." "..octs[id].." "..duals[id].." "..special[id].." "..shape[id]) 		f:close() 	end end function ToTable(t,match) 	local cmd = {} 	if not match then 		match = "[^%s]+" 	else 		match = "[^"..match.."]+" 	end 	for word in string.gmatch(t,match) do 		table.insert(cmd,word) 	end 	return cmd end --Load data function tank_load(id) 	local linya 	if (player(id,"usgn")>0) then 		f=io.open("sys/lua/JeloTanks/Save Data/"..player(id,"usgn")..".sav","r") 		if (f~=nil) then 			for line in f:lines() do 				linya=ToTable(line) 				uphealth[id]=tonumber(linya[1]) 				upspeed[id]=tonumber(linya[2]) 				uprate[id]=tonumber(linya[3]) 				points[id]=tonumber(linya[4]) 				rects[id]=tonumber(linya[5]) 				rounds[id]=tonumber(linya[6]) 				tris[id]=tonumber(linya[7]) 				octs[id]=tonumber(linya[8]) 				duals[id]=tonumber(linya[9]) 				special[id]=tonumber(linya[10]) 				shape[id]=tonumber(linya[11]) 				if rects[id]==0 then 					rect[id]="Active" 				else 					rect[id]="Inactive" 				end 				if rounds[id]==0 then 					round[id]="Active" 				elseif rounds[id]==1 then 					round[id]="Inactive" 				else 					round[id]="7 Points" 				end 				if tris[id]==0 then 					tri[id]="Active" 				elseif tris[id]==1 then 					tri[id]="Inactive" 				else 					tri[id]="7 Points" 				end 				if octs[id]==0 then 					oct[id]="Active" 				elseif octs[id]==1 then 					oct[id]="Inactive" 				else 					oct[id]="7 Points" 				end 				if duals[id]==0 then 					dual[id]="Ready" 				else 					dual[id]="2 Points" 				end 				if uphealth[id]==nil then 					uphealth[id]=0 				end 				if upspeed[id]==nil then 					upspeed[id]=0 				end 				if uprate[id]==nil then 					uprate[id]=0 				end 				if points[id]==nil then 					points[id]=0 				end 				if rect[id]==nil then 					rect[id]="Active" 				end 				if round[id]==nil then 					round[id]="7 Points" 				end 				if tri[id]==nil then 					tri[id]="7 Points" 				end 				if oct[id]==nil then 					oct[id]="7 Points" 				end 				if dual[id]==nil then 					dual[id]="2 Points" 				end 				if special[id]==nil then 					special[id]=0 				end 				if shape[id]==nil then 					shape[id]=0 				end 				break 			end 			f:close() 		end 	end 	--HUD text 	parse('hudtxt2 '..id..' 1 "©255255255Tank Points: '..points[id]..'" 5 410 0') 	parse('hudtxt2 '..id..' 2 "©000255255[F3] Tank Shop | [F4] Upgrade Tank" 5 423 0') 	parse('hudtxt2 '..id..' 3 "©255255000Script by OEM/Jelo" 519 410 0') 	parse('hudtxt2 '..id..' 4 "©255255000(USGN=70513)" 543 423 0') end