Advertisement
Dragon2fly

Minecraft AP Chatbox AFK notify +

Mar 30th, 2023
658
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.74 KB | None | 0 0
  1. local chatBox = peripheral.find("chatBox")
  2. local playerName = "<YOUR PLAYER NAME HERE>"
  3. local enabled = false
  4.  
  5. -- Sets what side a redstone signal is required to enable/disable
  6. while true do
  7.   local signal = redstone.getInput("right")
  8.  
  9.   if signal and not enabled then
  10.     enabled = true
  11.     print("Enabled")
  12.   elseif not signal and enabled then
  13.     enabled = false
  14.     print("Disabled")
  15.   end
  16.  
  17.   if enabled then
  18.     local event, player, message = os.pullEvent("chat")
  19.     local username = string.match(player, "%[(.-)%]")
  20.     if username and string.find(message, playerName) then
  21.       chatBox.sendMessageToPlayer(username, "YOUR MESSAGE HERE")
  22.     end
  23.   end
  24.  
  25.   os.sleep(0.1)  -- Wait for a short time before checking again
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement