#21
Posted 15 July 2014 - 02:11 PM
#22
Posted 16 July 2014 - 08:42 PM
AlkamlBan, on 11 July 2014 - 09:55 PM, said:
rednet.open("right")
cards = {{1, 1000}, {2, 550}}
while true do
senderId, ID = rednet.receive("id")
for i = 1, #cards do
if cards[i][1] == ID then
rednet.send(22, "yes", "answer")
senderId, amount = rednet.receive("pay")
if cards[i][2] >= amount then
rednet.send(22, "done", "transaction")
cards[i][2] = cards[i][2] - amount
else
rednet.send(22, "nope", "transaction")
end
else
rednet.send(22, "noCustomer", "transaction")
end
end
end
Well, this code is very good, but is there a way to load bank accounts from file ?
Because I need a way to edit and create accounts easily. With program or just using edit...
Edited by pauliuskas05, 17 July 2014 - 09:05 AM.
#23
Posted 18 July 2014 - 07:35 AM
AlkamlBan, on 11 July 2014 - 09:55 PM, said:
rednet.open("right")
cards = {{1, 1000}, {2, 550}}
while true do
senderId, ID = rednet.receive("id")
for i = 1, #cards do
if cards[i][1] == ID then
rednet.send(22, "yes", "answer")
senderId, amount = rednet.receive("pay")
if cards[i][2] >= amount then
rednet.send(22, "done", "transaction")
cards[i][2] = cards[i][2] - amount
else
rednet.send(22, "nope", "transaction")
end
else
rednet.send(22, "noCustomer", "transaction")
end
end
end
And here is the code for the counter of the store:
diskID = disk.getID("bottom")
amount = 100
rednet.open("right")
rednet.send(23, diskID, "id")
repeat
senderId, message = rednet.receive("answer")
until senderId == 23
if message == "yes" then
rednet.send(23, amount, "pay")
senderId, message = rednet.receive("transaction")
if senderId == 23 and message == "done" then
print("Transaction Complete!")
elseif senderId == 23 and message == "nope" then
print("Transaction Failed: Not enough money")
else
print("No such customer")
end
end
This is how it works:
1)The computer in the store sends a mesage to the bank server containing the cards ID.
2)The server checks in its table to see if the first number of the tables inside the table match the ID
3)If they do the server sends a message to the computer telling it to send it the amount
4)The computer checks the amount and sees if the second number inside the table the ID was found is bigger or equal to the amount
5)If it is it subtracts the amount from the money in the bank and sends a message to the computer saying that the transaction has been completed.
#24
Posted 27 July 2014 - 07:09 PM
pauliuskas05, on 18 July 2014 - 07:35 AM, said:
AlkamlBan, on 11 July 2014 - 09:55 PM, said:
rednet.open("right")
cards = {{1, 1000}, {2, 550}}
while true do
senderId, ID = rednet.receive("id")
for i = 1, #cards do
if cards[i][1] == ID then
rednet.send(22, "yes", "answer")
senderId, amount = rednet.receive("pay")
if cards[i][2] >= amount then
rednet.send(22, "done", "transaction")
cards[i][2] = cards[i][2] - amount
else
rednet.send(22, "nope", "transaction")
end
else
rednet.send(22, "noCustomer", "transaction")
end
end
end
And here is the code for the counter of the store:
diskID = disk.getID("bottom")
amount = 100
rednet.open("right")
rednet.send(23, diskID, "id")
repeat
senderId, message = rednet.receive("answer")
until senderId == 23
if message == "yes" then
rednet.send(23, amount, "pay")
senderId, message = rednet.receive("transaction")
if senderId == 23 and message == "done" then
print("Transaction Complete!")
elseif senderId == 23 and message == "nope" then
print("Transaction Failed: Not enough money")
else
print("No such customer")
end
end
This is how it works:
1)The computer in the store sends a mesage to the bank server containing the cards ID.
2)The server checks in its table to see if the first number of the tables inside the table match the ID
3)If they do the server sends a message to the computer telling it to send it the amount
4)The computer checks the amount and sees if the second number inside the table the ID was found is bigger or equal to the amount
5)If it is it subtracts the amount from the money in the bank and sends a message to the computer saying that the transaction has been completed.
Yea I know but really I mean why can't we give those hackers something to do?
#25
Posted 28 July 2014 - 07:43 PM
AlkamlBan, on 27 July 2014 - 07:09 PM, said:
pauliuskas05, on 18 July 2014 - 07:35 AM, said:
AlkamlBan, on 11 July 2014 - 09:55 PM, said:
rednet.open("right")
cards = {{1, 1000}, {2, 550}}
while true do
senderId, ID = rednet.receive("id")
for i = 1, #cards do
if cards[i][1] == ID then
rednet.send(22, "yes", "answer")
senderId, amount = rednet.receive("pay")
if cards[i][2] >= amount then
rednet.send(22, "done", "transaction")
cards[i][2] = cards[i][2] - amount
else
rednet.send(22, "nope", "transaction")
end
else
rednet.send(22, "noCustomer", "transaction")
end
end
end
And here is the code for the counter of the store:
diskID = disk.getID("bottom")
amount = 100
rednet.open("right")
rednet.send(23, diskID, "id")
repeat
senderId, message = rednet.receive("answer")
until senderId == 23
if message == "yes" then
rednet.send(23, amount, "pay")
senderId, message = rednet.receive("transaction")
if senderId == 23 and message == "done" then
print("Transaction Complete!")
elseif senderId == 23 and message == "nope" then
print("Transaction Failed: Not enough money")
else
print("No such customer")
end
end
This is how it works:
1)The computer in the store sends a mesage to the bank server containing the cards ID.
2)The server checks in its table to see if the first number of the tables inside the table match the ID
3)If they do the server sends a message to the computer telling it to send it the amount
4)The computer checks the amount and sees if the second number inside the table the ID was found is bigger or equal to the amount
5)If it is it subtracts the amount from the money in the bank and sends a message to the computer saying that the transaction has been completed.
Yea I know but really I mean why can't we give those hackers something to do?
#26
Posted 30 July 2014 - 01:33 PM
pauliuskas05, on 28 July 2014 - 07:43 PM, said:
AlkamlBan, on 27 July 2014 - 07:09 PM, said:
pauliuskas05, on 18 July 2014 - 07:35 AM, said:
AlkamlBan, on 11 July 2014 - 09:55 PM, said:
rednet.open("right")
cards = {{1, 1000}, {2, 550}}
while true do
senderId, ID = rednet.receive("id")
for i = 1, #cards do
if cards[i][1] == ID then
rednet.send(22, "yes", "answer")
senderId, amount = rednet.receive("pay")
if cards[i][2] >= amount then
rednet.send(22, "done", "transaction")
cards[i][2] = cards[i][2] - amount
else
rednet.send(22, "nope", "transaction")
end
else
rednet.send(22, "noCustomer", "transaction")
end
end
end
And here is the code for the counter of the store:
diskID = disk.getID("bottom")
amount = 100
rednet.open("right")
rednet.send(23, diskID, "id")
repeat
senderId, message = rednet.receive("answer")
until senderId == 23
if message == "yes" then
rednet.send(23, amount, "pay")
senderId, message = rednet.receive("transaction")
if senderId == 23 and message == "done" then
print("Transaction Complete!")
elseif senderId == 23 and message == "nope" then
print("Transaction Failed: Not enough money")
else
print("No such customer")
end
end
This is how it works:
1)The computer in the store sends a mesage to the bank server containing the cards ID.
2)The server checks in its table to see if the first number of the tables inside the table match the ID
3)If they do the server sends a message to the computer telling it to send it the amount
4)The computer checks the amount and sees if the second number inside the table the ID was found is bigger or equal to the amount
5)If it is it subtracts the amount from the money in the bank and sends a message to the computer saying that the transaction has been completed.
Yea I know but really I mean why can't we give those hackers something to do?
PIN isn't hard to make just go to the server and at the table add for each an extra string (PIN) inside each table (eg {1, 1000, "1234"}). The you need to modify the counter code to take a string and send it along with the rest of thi information to the bank server (make sure the bank server receives it). Finally and an if statement in the bank server before the if cards[i][2] >= amount etc etc stating the following:
if cards[i][3] == <variable in which the ping from the counter is> then <if cards[i][2] >= amount in here> else rednet.send(id, "nope") <you may need to modify this> end
#27
Posted 30 July 2014 - 05:25 PM
AlkamlBan, on 30 July 2014 - 01:33 PM, said:
if cards[i][3] == <variable in which the ping from the counter is> then <if cards[i][2] >= amount in here> else rednet.send(id, "nope") <you may need to modify this> end
#28
Posted 02 August 2014 - 08:40 PM
#29
Posted 18 August 2014 - 02:27 AM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











