Jump to content




[Please close] Help with my bank program



  • You cannot reply to this topic
5 replies to this topic

#1 manu_03

  • Members
  • 84 posts
  • LocationSpain

Posted 23 November 2014 - 01:17 PM

Hello guys! I'm having a trouble with my bank program.
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.
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())

EDIT: I solved this (I save accounts data in a Disk and I use string.sub()). You can close This.

Edited by manumanucraft, 23 November 2014 - 04:44 PM.


#2 Lignum

  • Members
  • 558 posts

Posted 23 November 2014 - 01:35 PM

View Postmanumanucraft, 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()

View Postmanumanucraft, 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.

#3 manu_03

  • Members
  • 84 posts
  • LocationSpain

Posted 23 November 2014 - 03:03 PM

View PostLignum, on 23 November 2014 - 01:35 PM, said:

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.
I store the money with FS but in a disk connected to the server. I will post my code because I'm having a trouble. Thanks!

#4 manu_03

  • Members
  • 84 posts
  • LocationSpain

Posted 23 November 2014 - 04:42 PM

I'm making a Bank porgram. The server gives responses to clients and save money amount. It works in RedNet. Cards are Floppy Disks.
When I try to pay, it says this:
server:39: attempt to index ? (a nil value)

Server Code and Client Code

#5 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 23 November 2014 - 04:56 PM

It couldn't open. Instead of hardcoding disk/ try using getmountpath
file1 = fs.open(disk.getMountPath(dr)..from,"r")
Not sure if that'll work exactly, otherwise use fs.combine with the getMountPath
file1 = fs.open(fs.combine(disk.getMountPath(dr),from),"r")
Also make sure that the file actually exists by using fs.exists()

Edited by Dragon53535, 23 November 2014 - 04:57 PM.


#6 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 23 November 2014 - 09:09 PM

Threads merged.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users