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

Get player name of user

Started by latias1290, 13 December 2016 - 12:21 PM
latias1290 #1
Posted 13 December 2016 - 01:21 PM
Hi, I want to get the name of the player that's using the computer. I know this is not possible using basic CC, so my question is - is there a plugin for that?
Lupus590 #2
Posted 13 December 2016 - 01:48 PM
I don't know of any mods which tell you who has the GUI open, but you can use sensors from different mods to know who is near the sensor (and therefore near the computer)
Edited on 13 December 2016 - 12:49 PM
latias1290 #3
Posted 13 December 2016 - 01:54 PM
I don't know of any mods which tell you who has the GUI open, but you can use sensors from different mods to know who is near the sensor (and therefore near the computer)
That sounds like it will work, but I need this functionality on PDAs.

I've actually tried to make a plugin that does this, but I gave up because I couldn't find any info on how to implement APIs. Could you point me at a tutorial?

(Edit: "point me at one" -> "point me at a tutorial")
Edited on 13 December 2016 - 02:49 PM
Lupus590 #4
Posted 13 December 2016 - 04:29 PM
If you want help making an addon mod for CC then go to this subforum: http://www.computerc...and-discussion/

I would implement a username and password system, there's tutorials for this on the forums: http://www.computerc...tore-passwords/

Another way would be to have a sensor system near where you will be using your PocketComputer and have the PocketComputer communicate with the sensor system to verify the user. This sounds very fiddly and limits the usage of the PocketComputer, so I wouldn't bother.
Edited on 13 December 2016 - 03:29 PM
EveryOS #5
Posted 13 December 2016 - 08:29 PM
CC's code is run serverside. Not gonna happen.
latias1290 #6
Posted 13 December 2016 - 09:10 PM
CC's code is run serverside. Not gonna happen.
So, you're saying that because CC programs run serverside, there is no way for an API to know who has the GUI open? So this is not possible?

Is this an alternative - return the player name who has the PDA in their inventory. This should work, even with program code running serverside. Will this work?
Edited on 13 December 2016 - 08:12 PM
Lupus590 #7
Posted 13 December 2016 - 09:26 PM
The server must be able to know player names, how else will it tell other clients who sent a message via chat?
Anavrins #8
Posted 13 December 2016 - 10:46 PM
CC's code is run serverside. Not gonna happen.
You don't know what you're talking about, OpenComputer runs server-side and it detects which players does an action.
In fact, most mod's core functionalities are server-sided, the client-side only deals with receiving and interpreting data from the server, and other stuff like GUIs.
CC can't do that simply because it hasn't been implemented, honestly it would be pretty easy to do.

Unfortunately there's isn't anything that will make it so you can get the player who pressed a key from something like os.pullEvent("key")
The best you'll be able to get is from a sensor from something like OpenPeripherals that will tell you the proximity of a user, although it won't prevent people to act on the computer over your shoulder.
Edited on 13 December 2016 - 09:47 PM