I want to make my bank system for my server, but I got problem when making bank network.
When server tries write a file, it got an error like fil = nil. I can't solve the problem, so please help me!
There's the code:
local com = require("component")
local ev = require("event")
local fs = require("filesystem")
local net = com.modem
net.open(15)
print("Opened Net. Waiting for commands")
while true do
local _,_,from,port,_,message,nick,balance = ev.pull("modem_message")
if message == "getInfo" then
if fs.exists("bankAccounts/"..nick) then
local fil = io.open("bankAccounts/"..nick,"r")
bal = fil:read(1000)
fil:close()
net.send(from,15,nick,bal)
else
net.send(from,15,"no info")
end
end
if message == "setInfo" then
local fil = io.open("bankAccounts/"..nick,"wb")
fil:write(balance)
fil:close()
net.send(from,15,"done it")
end
end
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
I want to make my bank system for my server, but I got problem when making bank network.
When server tries write a file, it got an error like fil = nil. I can't solve the problem, so please help me!
There's the code:
Link to post
Share on other sites