Forum

> > CS2D > Scripts > save system is bugged
Forums overviewCS2D overview Scripts overviewLog in to reply

English save system is bugged

5 replies
To the start Previous 1 Next To the start

old save system is bugged

TheBosS_
User Off Offline

Quote
hello guys . .

idk why . . I got problem that does not save anyone money, addons, or licence . ..

here is the save script :

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
function SaveUserStat(id,UsgnID)
	file = io.open("sys/lua/Lua/rp_citylife/"..UsgnID..'.txt', "w+") or io.tmpfile()
	local text = ""
	text = tostring(rp_money[id])
	text = text .." "..rp_license[id]
	if rp_arrest[id]==true then
		text = text .." 1"
	else
		text = text .." 0"
	end
		
	for k, v in ipairs(Addons) do
		text = text .." "..v.FLic[id]
	end
	file:write(text)
	file:close()
end

function LoadUserStat(id,file)
	for line in file:lines() do
		local parses = totable(line)
		local userMoney=tonumber(parses[1])
		if userMoney ~= nil then
			rp_money[id]= userMoney
		end
		if (tonumber(parses[2])~=nil) then
			rp_license[id]=tonumber(parses[2])
		end
		if (tonumber(parses[3]) == 1) then
			rp_arrest[id]=true
			rp_license[id]=0
		end
		
		local counter=3
		for k, v in ipairs(Addons) do
			counter=counter+1
			local LicItem = tonumber(parses[counter])
			if LicItem~=nil then
				v.FLic[id]=LicItem
			else
				v.FLic[id]=0
			end
		end
	end
end

Thanks !

old Re: save system is bugged

TheBosS_
User Off Offline

Quote
user Jynxxx has written
Does the save folder actually exist?


yup . . .

sys/lua/Lua/rp_citylife . . .

all of the id is written . . but it starts again from money 100$

old Re: save system is bugged

Happy eyes
User Off Offline

Quote
user TheBosS_ has written
user miere has written
You not opened file in LoadUserStat function.


how to open it ?


You've only shown us the engine, the saving part. You have to link this with your script to make it work. Link SaveUserStat(id,usgn) with leave cs2d hook, and LoadUserStat(id,file) with join cs2d hook.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview