Forum

> > CS2D > General > script load/save usgn
Forums overviewCS2D overviewGeneral overviewLog in to reply

English script load/save usgn

No replies
To the start Previous 1 Next To the start

old closed script load/save usgn

Mr_God
User Off Offline

Quote
hi all
the script is error
help me to fix script

attempt to call glotbal 'totable' (a nil value)
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
function load(id)
	usgn = player(id,"usgn")
		if (usgn > 0) then
			local usgn = player(id, "usgn")
			files = io.open("sys/lua/scelldata/"..usgn..".txt","r")
			if(files~=nil) then
				msg2(id,"©000255000Your save file found!@C")
				msg2(id,"©160160255Your U.S.G.N ID: "..usgn.."@C")
				parse('hudtxt2 '..id..' 7 "©000255000Login as: '..usgn..'" 40 415')
				for line in io.lines("sys/lua/scelldata/"..usgn..".txt","r") do
				local parses = totable(line)
				if (tonumber(parses[1])>0) then
				yourmon[id] = tonumber(parses[1])
				license[id] = tonumber(parses[2])
			break
			end
		end
		else
			msg2(id,"©255000000Failed to load save!@C")
			msg2(id,"©255000000Please check your U.S.G.N account settings!@C")
			parse('hudtxt2 '..id..' 7 "©255000000Failed to Load Save" 40 415')
		end
	end
end

addhook("leave","save")
function save(id)
	if (player(id, "usgn") > 0) then
		save_data = license[id].." "..yourmon[id]
		file = assert(io.open("sys/lua/scelldata/"..usgn..".txt","w"))
		file:write(save_data)
		file:close()
		msg2(id,'©000255001Save Data Successfull!@C')
		else
			msg2(id,"©255000000Failed to Save!@C")
	end
end

Admin/mod comment

use the Lua scripting thread! /DC
To the start Previous 1 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview