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
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
savestr={}
function readfile(filelocation, linenum)
saveline=1
for line in io.lines(filelocation) do
savestr[saveline]=line
saveline=saveline+1
end
return savestr[linenum]
end
addhook("join" ,"playerjoin")
function playerjoin(id)
if player(id,"usgn") ~= 0 then
savedpoints = readfile("sys/lua/autorun/savefile/"..player(id,"usgn")..".txt", 1)-1+1
points[id] = savedpoints
msg2(id,"\169000255000Your points was succesfully loaded")
end
addhook("leave","saveleave")
function saveleave(id)
if player(id,"usgn") ~= 0 then
local c = points[id]
ppoints = io.open("sys/lua/autorun/savefile/"..player(id,"usgn")..".txt", "w")
ppoints:write(""..c.."")
ppoints:close()
end
end
However, It worked! but the only problem I faced is that when a usgn user join the server and he didn't save before, the script will not work well and some bugs will appear.
So... I want to know how to make the load system work ONLY if the player usgn exists at the savefile in the first place?
edited 1×, last 08.08.22 01:43:29 pm