Jump to content




Computercraft Virtual Currency

help

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

#21 hilburn

  • Members
  • 153 posts
  • LocationLondon, England

Posted 15 July 2014 - 02:11 PM

By the way, using a PIM to stand on (OpenPeripherals) when you insert your credit card would allow you to verify the user with PIM.inventoryName() as well as allow you to interact directly with the players inventory, allowing him to withdraw "cash" or deposit into his account without the risk entailed with dispensers

#22 pauliuskas05

  • Members
  • 12 posts

Posted 16 July 2014 - 08:42 PM

View PostAlkamlBan, on 11 July 2014 - 09:55 PM, said:

Bank Server Code:
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 pauliuskas05

  • Members
  • 12 posts

Posted 18 July 2014 - 07:35 AM

View PostAlkamlBan, on 11 July 2014 - 09:55 PM, said:

Bank Server Code:
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.
But this isn't secure. Because there is no PIN, so anyone who has your card can access it. :(

#24 AlkamlBan

  • Members
  • 64 posts
  • LocationGreece

Posted 27 July 2014 - 07:09 PM

View Postpauliuskas05, on 18 July 2014 - 07:35 AM, said:

View PostAlkamlBan, on 11 July 2014 - 09:55 PM, said:

Bank Server Code:
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.
But this isn't secure. Because there is no PIN, so anyone who has your card can access it. :(

Yea I know but really I mean why can't we give those hackers something to do?

#25 pauliuskas05

  • Members
  • 12 posts

Posted 28 July 2014 - 07:43 PM

View PostAlkamlBan, on 27 July 2014 - 07:09 PM, said:

View Postpauliuskas05, on 18 July 2014 - 07:35 AM, said:

View PostAlkamlBan, on 11 July 2014 - 09:55 PM, said:

Bank Server Code:
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.
But this isn't secure. Because there is no PIN, so anyone who has your card can access it. :(/>

Yea I know but really I mean why can't we give those hackers something to do?
I could make PINs myself, but I don't know how to use tables and assign them to a Credit Card(ID)...

#26 AlkamlBan

  • Members
  • 64 posts
  • LocationGreece

Posted 30 July 2014 - 01:33 PM

View Postpauliuskas05, on 28 July 2014 - 07:43 PM, said:

View PostAlkamlBan, on 27 July 2014 - 07:09 PM, said:

View Postpauliuskas05, on 18 July 2014 - 07:35 AM, said:

View PostAlkamlBan, on 11 July 2014 - 09:55 PM, said:

Bank Server Code:
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.
But this isn't secure. Because there is no PIN, so anyone who has your card can access it. :(/>

Yea I know but really I mean why can't we give those hackers something to do?
I could make PINs myself, but I don't know how to use tables and assign them to a Credit Card(ID)...

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 pauliuskas05

  • Members
  • 12 posts

Posted 30 July 2014 - 05:25 PM

View PostAlkamlBan, on 30 July 2014 - 01:33 PM, said:

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
Thanks! I will test it later.

#28 AlkamlBan

  • Members
  • 64 posts
  • LocationGreece

Posted 02 August 2014 - 08:40 PM

The reason I didn't put a PIN in the original code is because a PIN need to be added by the user as a result it takes a bit of time to do so. So with that in mind if a server hosts multiple stores for example that use the PIN method if someone is sending a request to the server while someone else is entering the ping the server will not accept it because it will wait for a different kind of message. As a result it will be as if the card isn't valid even though it is. What you can do though is that you set up a "mini-server" under each store where data will be picked up and sent one by one. Maybe each server communicates with each other? Anyway its up to you. But you will basically need to set each request in an order and send them 1 by 1 to the server so that the transactions happen correctly.

#29 Darkitech

  • New Members
  • 1 posts

Posted 18 August 2014 - 02:27 AM

Why not just set up an encryption system at the tellers, if someone tried to change or duplicate the card, they won't know how to I am currently working on one right now..... But the duplication problem I am sorta having troubles stopping.....





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users