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
function zp_player_sv(p)
	if (player(p,"usgn") > 0) then
		f = assert(io.open(zp_dir..'data/'..player(p,"usgn")..'.txt','w'))
		f:write(set_player_val(p,1)..'\n'..set_player_val(p,2))
		f:close()
	end
end
function zp_player_ld(p)
	local usgn = player(p,"usgn")
	if (usgn > 0) then
		zp_msg2(p,3,'Your U.S.G.N. ID: '..usgn..'@C')
		zp_hudtxt2(p,3,2,'Logged in: #'..usgn,5,410,0)
		f = io.open(zp_dir..'data/'..usgn..'.txt','r')
		if (f ~= nil) then
			zp_msg2(p,2,'Your Save File Found!@C')
			local i = 0
			local s = 0
			local c = 0
			for line in f:lines() do
				i = i + 1
				if (i < 3) then set_player_stata(p,i,tonumber(line)) end
			end
			while set_player_val(p,1) >= c and s < zp_lvl_max do
				s = s + 1
				c = c +zp_lvl_ratio * s
			end
			if (s > zp_lvl_max) then i = zp_lvl_max end
			set_player_stata(p,3,s)
			set_player_stata(p,4,c)
			f:close()
		else
			zp_msg2(p,4,'Failed To Load Save!@C')
		end
	else
		zp_msg2(p,4,'Please check your U.S.G.N. account settings!@C')
		zp_hudtxt2(p,3,4,'Logged to login!',5,410,0)
	end
	
	if (set_player_val(p,1) == nil or set_player_val(p,1) < 1 or usgn < 1) then
		zp_player_reset(p)
	end
end