42 posts
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!
379 posts
Location
Hawaii
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()
26 posts
Location
Essex, UK
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.
42 posts
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))
97 posts
Location
Ohio, USA
Posted 17 May 2013 - 08:37 PM
42 posts
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.