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

Multi Login IDs

Started by TsubasaLegend97, 18 May 2016 - 10:31 AM
TsubasaLegend97 #1
Posted 18 May 2016 - 12:31 PM
Hi, I'm looking at creating a server and managing my staff using cc, I want to have a 'central admin terminal' that the admin staff can use to profirm tasks, rather than giving them access to cheat-codes, this will be done by linking the terminal to command blocks, i can lock a terminal so thst only a player with the password can open it, but i want to separate each staff member and give them an individual login number, how can i do this? and how can i hide what they are typing with a symbol e.g: *
Thanks in advance
The Higher Realm #2
Posted 18 May 2016 - 03:27 PM
1. You want to use a command computer because computers are very easy to "hack".
2. password = read("*") –Makes a * when you type
3. I would need to see your code but I would say using an if statement to check the username and give each username a level so if there level is say 10 they have access to everything. And if there level is 2 they only have access to some things, but you should be able to put if username == "person1" then [stuff] elseif username == "person2" then [more stuff] end. It depends how secure you want it to be.
4. Remember computer craft computers are very hackable. People can easy place a disk drive next to it and take over the whole thing so I would recommend making an in game server with a computer that sends encrypted username and passwords and that can get pretty complex.
Edited on 18 May 2016 - 01:27 PM
KingofGamesYami #3
Posted 18 May 2016 - 04:12 PM
Since you have a command computer, why not directly check the identity of the closest player?

local allowedPlayers = {
  ["KingofGamesYami"] = true,
  ["TsubasaLegend97"] = true,
}
local ok, result = commands.exec( "tp @p ~ ~ ~" )
local player = result[ 1 ]:match( "Teleported (.+) to" )
if allowedPlayers[ player ] then
  --#unlock
else
  --#don't unlock
end

Heck, while you're at it, you could recheck the position of the player (relative to the computer) and if they move 10 blocks away they're logged out automatically.
Edited on 18 May 2016 - 02:14 PM
Bomb Bloke #4
Posted 18 May 2016 - 05:37 PM
A few distinctions which're important to keep in mind:

A Command Computer can only be directly accessed by OPs in creative (meaning that if your staff could use one, they wouldn't need one for their usual tasks). You can give indirect - and rather more importantly controlled - access by hooking up an Advanced Monitor and rigging the startup script to take input from that. Command Computers are also immune to disk drive shenanigans.

Command Blocks can be controlled via a regular computer, meaning you don't have to create any "external monitor" setups for your staff to use them. Catch is anyone with a redstone torch and physical access to the blocks can also use them, and if you enable the CC config option which lets you wrap them as peripherals, then anyone who can get near a command block will be able to reprogram it and do pretty much whatever they like!

Command Computers can get text output from commands which provide it (allowing tricks like the one Yami posted above). ComputerCraft can't get text output from regular Command Blocks - only redstone output.

If you wanted to get the name of the closest player to a Command Computer though, the "xp" command would probably be a better bet than "tp". Personally, I'd build a solid bedrock chamber with a redstone button outside on the wall next to the computer on the inside; when the button is pressed, check player positions, and if a staff member is closest to the computer then teleport them into the sealed chamber where the access monitor is.

And if they're not a staff member, perhaps have some fun with them. Teleport them up a hundred blocks or so, perhaps. Above a pool of water. Maybe.

If you're not familiar with coding (eg if little to none of what I've said above makes sense to you, or more to the point, you've no idea how to research any context you're missing without help), then this project sounds like a recipe for disaster - either you can trust your staff, in which case you should straight-up give them OP access, or you can't, in which case one slip-up in your logic and you'll give full power to someone who shouldn't have it.
Lyqyd #5
Posted 18 May 2016 - 05:52 PM
The best combination of options (in my opinion) is to use a second computer to access the command computer. You'd hook up the two computers via network cable encased in bedrock, and activate the peripheral interface of the user-facing computer. The command computer would host nsh with a local program that watches for a peripheral disconnect event and shuts down if it sees one. The user-facing computer's startup runs nsh in client mode connecting to the command computer. The command computer's remote answering program is configured to be an authorization program that then runs the admin console when successfully connected.
TsubasaLegend97 #6
Posted 18 May 2016 - 06:30 PM
Thanks for all the tips guys, im currently out and about but i will post what code im running so far when i get home
TsubasaLegend97 #7
Posted 18 May 2016 - 09:53 PM
os.pullEvent = os.pullEventRaw
term.setCursorPos(15, 15)

local idnumber = ""

if idnumber ~= "ag310397" do
term.write("Enter I.D Number> ")
idnumber = read()
print("I.D Authorised…Please Wait")
os.sleep( 5 )
term.clear()
term.setCursorPos(18, 5)
print("Enter A Command")
term.setCursorPos(18, 6)
os.pullEvent
TsubasaLegend97 #8
Posted 18 May 2016 - 09:54 PM
function getPass(checkPass)
local pass = ""

term.write("Enter I.D Code> ")
pass = read()
if pass ~= checkPass then
print(" Unrecognized I.D! > ")
os.sleep(2)
os.reboot()
else
print("I.D Authorised")
end
end

print("Online")
getPass("AZG")