Forum

> > CS2D > Scripts > Save Error
Forums overviewCS2D overview Scripts overviewLog in to reply

English Save Error

3 replies
To the start Previous 1 Next To the start

old Save Error

_Vava_
User Off Offline

Quote
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
function _join	
local usgn = player(id,"usgn")
	if (usgn > 0) then
		msg2(id,'\169255255255Your U.S.G.N. ID: '..usgn..'@C')
		f = io.open('sys/lua/ZombieCrown/saves/'..usgn..'.txt','r')
		local line
		if not f then
			line = {1,0,50,10,0,0,0}
			msg2(id,"\169255000000Failed to load!@C")
		else
			line = f:read("*a"):split()
			msg2(id,"\169000000255Load!@C")
		end
		level[id] = tonumber(line[1]) or 1 -- Same as above reasoning (prevents errors)
		exp[id] = tonumber(line[2]) or 0
		ap[id] = tonumber(line[3]) or 50
		point[id]=tonumber(line[4]) or 10
		hp[id]=tonumber(line[5]) or 0
		armor[id]=tonumber(line[6]) or 0
		deadly[id]=tonumber(line[7]) or 0
	else
		msg2(id,"\169255000000No USGN found!@C")
		level[id]=1
		exp[id]=0
		ap[id]=50
		point[id]=10
		hp[id]=0
		armor[id]=0
		deadly[id]=0
	end
end

LUA Error: Attempt to call method 'split' (a nil value)
Line=11

old Re: Save Error

Waldin
User Off Offline

Quote
hehe add a string.split function
1
2
3
4
5
6
7
function string:split(sep)
	local words = {}
	for word in self:gmatch(sep~=nil and "[^"..tostring(sep).."]+" or "[^%s]+") do
		words[#words+1] = word
	end
	return words
end

also...
1
function _join

use _join(id) ?

old Re: Save Error

Baloon
GAME BANNED Off Offline

Quote
The name is actually wrong, you should rename it to "Load Userdata Error", the thing is join hook is actually used on Load, not Save.
Spoiler >
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview