guys,I'm in need of your help, I have an error with these codes, someone who can help me with these mistakes?, I can not find the error.
Hats code error 

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
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
hattable = {
{name = "Devil", path = "gfx/hat/devil.png"},
{name = "Skull", path = "gfx/hat/skull.png"},
}
currenthat = {}
hatimg = {}
function callmenu(id,page)
local pages = math.ceil(#hattable/7)
local output = "Hat Menu Page "..page
local p = pages * 7
for a = p-6, p do
if hattable[a] then
if (hattable[a].name and hattable[a].path) then
if a ~= currenthat[id] then
output = output..","..hattable[a].name
else
output = output..",("..hattable[a].name
end
else
output = output..","
end
else
output = output..","
end
end
if page == 1 then
if currenthat[id] ~= 0 then
output = output..",No hat"
else
output = output..",(No hat"
end
else
output = output..",Back Page |Page "..page-1
end
if page == pages then
if currenthat[id] ~= 0 then
output = output..",No hat"
else
output = output..",(No hat"
end
else
output = output..",Back Page |Page "..page+1
end
menu(id,output)
end
addhook("menu","hat_menu")
function hat_menu(id,title,button)
if string.sub(title,1,14) == "Hat Menu Page " then
local page = tonumber(string.sub(title,15))
local pages = math.ceil(#hattable/7)
if button >= 1 and button <= 7 then
local pr7 = (page - 1) * 7
local rsel = pr7 + button
if currenthat[id] ~= rsel then
if hatimg[id] then
freeimage(hatimg[id])
end
currenthat[id] = rsel
hatimg[id] = image(hattable[rsel].path,1,1,200+id)
end
elseif button == 8 then
if page == 1 then
if hatimg[id] then
freeimage(hatimg[id])
end
hatimg[id] = nil
currenthat[id] = 0
else
callmenu(id,page-1)
end
elseif button == 9 then
if page == pages then
if hatimg[id] then
freeimage(hatimg[id])
end
hatimg[id] = nil
currenthat[id] = 0
else
callmenu(id,page+1)
end
end
end
end
addhook("die","hat_die")
function hat_die(victim)
if hatimg[victim] then
freeimage(hatimg[victim])
end
hatimg[victim] = nil
end
addhook("spawn","hat_spawn")
function hat_spawn(id)
if currenthat[id] > 0 then
hatimg[id] = image(hattable[currenthat[id]].path,1,1,200+id)
end
end
addhook("leave","savedata")
function savedata(id)
if player(id,"usgn") > 0 then
local f = assert(io.open("sys/lua/hats tiky/saves/"..player(id,"usgn")..".txt","w"))
f:write(currenthat[id])
f:close()
end
if hatimg[id] then
freeimage(hatimg[id])
end
hatimg[id] = nil
currenthat[id] = nil
end
addhook("join","loaddata")
function loaddata(id)
local loaded = false
if player(id,"usgn") > 0 then
local f = io.open("sys/lua/hats tiky/saves/"..player(id,"usgn")..".txt","r")
if f ~= nil then
for line in f:lines() do
currenthat[id] = tonumber(line)
break
end
loaded = true
f:close()
end
end
if not loaded then
currenthat[id] = 0
end
end
Save points error 

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
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
function initArray(m)
local array = {}
for i = 1, m do
array[i]=0
end
return array
end
level=initArray(32)
exp=initArray(32)
asd=initArray(32)
function string.split(text,b)
local cmd = {}
if b then
b = b
else
b = "%s"
end
b = "[^"..b.."]+"
for o in string.gmatch(text,b) do
table.insert(cmd,o)
end
return cmd
end
addhook("ms100","ms_hud")
function ms_hud()
for id = 1,32 do
if (player(id,"exists")) then
asd[id]=5000000000000*level[id]+5000000000000
parse('hudtxt2 '..id..' 1 "©255255000Points©255255255: '..exp[id]..' " 7 140')
end
end
end
addhook("objectkill","objectkill")
function objectkill(id,player)
if exp[player] < asd[player] then
exp[player]=exp[player]+1
end
end
addhook("kill","ms_kill")
function ms_kill(id)
if exp[id] < asd[id] then
exp[id]=exp[id]+1
end
end
function point_update(id)
end
addhook("leave","save_leave")
function save_leave(id)
if (player(id,"usgn")>0) then
local file = (io.open("sys/lua/save/"..player(id,"usgn")..".txt","w+"))
file:write(exp[id].." "..level[id])
file:close()
end
end
addhook("die","save_die")
function save_die(id)
if (player(id,"usgn")>0) then
io.output(io.open("sys/lua/save/"..player(id,"usgn")..".txt","w+"))
io.write(exp[id].." "..level[id])
io.close()
end
end
addhook("join","save_join")
function save_join(id)
if (player(id,"usgn")>0) then
if not file_exists("sys/lua/save/"..player(id,"usgn")..".txt") then
io.output(io.open("sys/lua/save/"..player(id,"usgn")..".txt","w+"))
io.write("0 0") -- start from 0 xp and level 0 -- change accordingly
io.close()
end
for line in io.lines("sys/lua/save/"..player(id,"usgn")..".txt") do
line = line:split()
local ms_exp = tonumber(line[1])
local ms_level = tonumber(line[2])
level[id]=ms_level
exp[id]=ms_exp
end
end
end
function file_exists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end

I need to correct these codes, thanks to all
hats and save points error
1 
Offline