Forum

> > CS2D > Scripts > Saving script
Forums overviewCS2D overview Scripts overviewLog in to reply

English Saving script

1 reply
To the start Previous 1 Next To the start

old Saving script

_Lima_
User Off Offline

Quote
Hi, I need some help. How to make a rank, score, reputation saved in 1 file. And how to fix a bug when a player enters the server but stops loading and exits, then his reputation is saved as 0 (Need 20).

Spoiler >

old Re: Saving script

Cebra
User Off Offline

Quote
i assume that your arrays are global arrays, otherwise there is your bug.

to save several vars in one file:

1
2
3
4
-- untested code
local file = [to be inserted]
file:write (Rank[id].." "..player(id,"score").." "..Reputation[id])
file:close()

then you load them with:

1
2
3
4
5
6
-- untested code
local file = [to be inserted]
Rank[id] = file:read("*n")
parse("setscore "..id.." "..file:read("*n"))
Reputation[id] = file:read("*n")
file:close()

this will also reduce the amount of functions (there are too many)

edit: it looks like the
end
in line 9,22,34 & 57 have to move a few line down. (look here)

does you code run without throwing errors? 0o
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview