This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
camurro9's profile picture

authentiction

Started by camurro9, 21 September 2012 - 12:49 PM
camurro9 #1
Posted 21 September 2012 - 02:49 PM
okay, so I have a computer thats running as a bank server now, and it needs to ensure that only authorised computers can do stuff.
so, there's a script in there that does:


checkID, message = rednet.receive()

now I have a file on the server at "\ids" that is just a list of authorised computer ids, like:
278
295
445
end

and now here's my code for seeing if the communicating computer is on the list:


local function auth()
authID = fs.open("\ids", "r")
while true do
IDA = authID.readLine()
if IDA == checkID then
return true
elseif IDA == "end" then
return false
end
end
end
if auth then
--whatever happens when its permitted.
else
--access denied.
end



And I keep getting access denied. This is the first time I've tried using return. help please!
Pinkishu #2
Posted 21 September 2012 - 02:53 PM
checkID is a number
IDA is a string

so either tonumber IDA or tostring checkID
camurro9 #3
Posted 21 September 2012 - 03:14 PM
Thank you very much! :)/>/>

I'll try it now.

EDIT;

it worked, thanks a bundle :D/>/>