Advertisement
MigasRocha

CHATGPT Online Player List

Apr 19th, 2024
719
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 0 0
  1. -- Open the peripheral connected to the Advanced Computer
  2. local playerDetector = peripheral.wrap("side_of_player_detector")  -- Replace "side_of_player_detector" with the actual side of the Player Detector
  3.  
  4. -- Function to get online players
  5. local function getOnlinePlayers()
  6.     local onlinePlayers = playerDetector.getOnlinePlayers()
  7.     return onlinePlayers
  8. end
  9.  
  10. -- Function to display online players on the terminal
  11. local function displayOnlinePlayers()
  12.     local onlinePlayers = getOnlinePlayers()
  13.     term.clear()  -- Clear the terminal screen
  14.     print("Online Players:")
  15.     for _, player in ipairs(onlinePlayers) do
  16.         print("- " .. player)
  17.     end
  18. end
  19.  
  20. -- Main loop to continuously display online players
  21. while true do
  22.     displayOnlinePlayers()
  23.     os.sleep(5)  -- Refresh every 5 seconds (adjust as needed)
  24. end
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement