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

Getting Player + Computer Name

Started by NullSchritt, 16 May 2013 - 02:38 AM
NullSchritt #1
Posted 16 May 2013 - 04:38 AM
Hello, I was wondering how I would go about getting the name of a player who interacted with the computer, and the computer ID, I need to get the player name so that I can submit it to my database, that way it may determine is a certain account is authorized to access certain functions of the program, or certain areas of the game. Thanks!
Smiley43210 #2
Posted 16 May 2013 - 06:26 AM
You cannot get a player name without other peripheral mods unless you ask them to type it in using read().
And to get the computer ID, use os.getComputerID() or os.computerID()
panicmore #3
Posted 16 May 2013 - 07:23 AM
if you want to get player name and have miscperipherals installed use the player detector.
use this code

while true do
  event, user = os.pullEvent("player")
   print("user: " .. user)
end
then just write it to your database file:

while true do
event, user = os.pullEvent("player")
if event == "player" then
  print("user: " .. user)
  myFile = fs.open("database", a)
  myFile.write(user .. "\n")
  myFile.close
end
end
then you can access the database for whatever you want by typing edit database.
NullSchritt #4
Posted 17 May 2013 - 07:40 PM
if you want to get player name and have miscperipherals installed use the player detector.
use this code

while true do
  event, user = os.pullEvent("player")
   print("user: " .. user)
end
then just write it to your database file:

while true do
event, user = os.pullEvent("player")
if event == "player" then
  print("user: " .. user)
  myFile = fs.open("database", a)
  myFile.write(user .. "\n")
  myFile.close
end
end
then you can access the database for whatever you want by typing edit database.
Thanks, where might I find the 1.5.1 compatible version of misc. peripherals?(also my database is mysql, I want to add access control to the stargate dialing program, that I wrote for a plugin on my server(with some help from people here), by sending their name along with the requested gate to dial to my server(I already got that part handled, I just didn't know how to get the name))
1vannn #5
Posted 17 May 2013 - 08:37 PM
It's in the peripherals section of the forums.
http://www.computercraft.info/forums2/index.php?/topic/4587-cc152mc151-miscperipherals-32/
NullSchritt #6
Posted 17 May 2013 - 09:07 PM
It's in the peripherals section of the forums.
http://www.computerc...peripherals-32/
Thanks, I have however decided to use immibis's peripherals (RFID Reader), along with a private list of codes for access control, for now at least, since I already have it installed.