manumanucraft, on 23 November 2014 - 01:17 PM, said:
First:
I don't know how can I save money amount (if I use variables, when I close the program the money clears and I don't want to use HTTP for security reasons.
Use the
fs API. Here's an example:
--# Saving the variable...
local myReallyNeatVariable = 22 --# The variable to be saved.
local file = fs.open("disk/myReallyNeatFile", "w") --# The first parameter is the file to write to, the second is the mode. "w" means write, "r" means read. You can combine these like "wr".
--# fs.open will give you a table that contains functions that allow you to perform operations on the file.
file.writeLine(myReallyNeatVariable) --# Write the variable to the file and add a new line at the end. It's not really necessary here, so you can just use file.write if you want.
file.close() --# We're done, close the file handle.
--# Loading it...
local file = fs.open("disk/myReallyNeatFile", "r")
local myReallyNeatVariable = tonumber(file.readLine()) --# readLine, as expected, reads a line. Since lines are strings, we need to convert it to a number. Luckily, tonumber does this.
file.close()
manumanucraft, on 23 November 2014 - 01:17 PM, said:
Second:
Pay command. It uses RedNet. The account's ID is the ID of a Floppy Disk. I'm thinking about using a max account number Lenght and send in the msg the sender's ID and money (using string.sub())
The problem with floppy disks is that you can easily edit the file that stores the money. Unless you've made sure that the disks can't be modified, there is no secure way to do this.