Hi, I'm trying to revive my old server but I've got some errors that I'm trying to fix and this is one of them.
Error:
Spoiler
1
2
3
4
5
2
3
4
5
LUA ERROR: sys/lua/autorun/shops.LUA:41: attempt to index field '?' (a nil value) -> sys/lua/autorun/shops.LUA:41: in function 'menu_hook' -> [string "menu_hook(1, "Buy Lottery Tickets", nil)"]:1: in main chunk -> sys/lua/menufuncs/menufuncs.lua:98: in function <sys/lua/menufuncs/menufuncs.lua:73> -> in Lua hook 'menu', params: 1, 'Buy Lottery Tickets', 1
Script:
Spoiler
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
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
img = {} menus = { [1] = {x = 43, y = 19, str = "Buy Hats,Angel|500$,Devil|1000$,Remove Hat|0$,"}, [2] = {x = 43, y = 21, str = "Buy Lottery Tickets,Bronze Ticket|10000$,Silver Ticket|25000$,Golden Ticket|50000$"}, [3] = {x = 1, y = 1, str = "Buy Extra Score,25+ Score|2500$,50+ Score|5000$,100+ Score|10000$"} } purchases = { ["Buy Hats"] = { [1] = {price = 500, path = "gfx/shop_clothes_and_guns/angel.png", itemname = "Angel Hat"}, [2] = {price = 1000, path = "gfx/shop_clothes_and_guns/devil.png", itemname = "Devil Hat"}, [3] = {price = 0, path = "gfx/nohat.png", itemname = "Remove Hat"}}, ["Buy Lottery Tickets"] = { [1] = {price = 10000, itemid = 86, itemname = "a Bronze Ticket"}, [2] = {price = 25000, itemid = 54, itemname = "a Silver Ticket"}, [3] = {price = 50000, itemid = 53, itemname = "a Golden Ticket"}}, ["Buy Extra Score"] = { [1] = {price = 25009999, score = 0}, [2] = {price = 50009999, score = 0}, [3] = {price = 10000999, score = 0}} } addhook("movetile","yey") function yey(id,x,y) for k,v in pairs (menus) do if x == v.x and y == v.y then menu(id,v.str) end end end addhook("menu", "menu_hook") function menu_hook(id,t,b) for k,v in pairs (purchases) do if k == t then 				if rp_money[id] >= purchases[k][b].price then 				rp_money[id]=rp_money[id]-purchases[k][b].price if purchases[k][b].path then if img[id] ~= nil then freeimage(img[id]) img[id] = nil end img[id] = image(purchases[k][b].path,10,10,200+id) end if purchases[k][b].itemid then parse("equip "..id.." "..purchases[k][b].itemid) 						 parse("setweapon "..id.." "..purchases[k][b].itemid) 	 end if purchases[k][b].score then parse("setscore "..id.." "..player(id,"score")+purchases[k][b].score) end if purchases[k][b].itemname then msg2(id,"\169255255000[Server]: \169000255000You bought "..purchases[k][b].itemname.." for "..purchases[k][b].price) else msg2(id,"\169255255000[Server]: \169000255000You bought extra score for "..purchases[k][b].price) end else msg2(id,"\169255255000[Server]: \169255000000Not enough money.") end break end end end addhook("join" , "admin") function admin(id) if player(id,"usgn")==1 then if img[id] ~= nil then freeimage(img[id]) img[id] = nil end freeimage(img[id]); img[id] = image("gfx/shop_clothes_and_guns/admin.png",0,0,200+id); end end addhook("leave","leave_hook") function leave_hook(id) if img[id] ~= nil then freeimage(img[id]) img[id] = nil end end
Some stuff you should note: rp_money is declared
This is a shop script for hats and lottery tickets (2 menus)
pls
edited 1×, last 20.02.16 10:34:51 pm