Guest User

tp

a guest
Jul 2nd, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.89 KB | None | 0 0
  1. local event=require("event")
  2.  
  3. local component = require("component")
  4. local debug = component.debug
  5.  
  6.  
  7. --chat msg, uuid, name "chat_message"_
  8.  
  9. while true do
  10.   local ev, _ , name, msg = event.pull("chat_message")
  11.  
  12.   if msg:sub(1,3) == "tp " then
  13.     local n1, n2 = string.match(msg, "tp%s([^%s]+)%s([^%s]+)")
  14.     print(n1,n2)
  15.     if n1 == nil then
  16.       n2 = string.match(msg, "tp%s([^%s]+)")
  17.       n1 = name
  18.     end
  19.  
  20.     if n1 ~= nil and n2 ~= nil then
  21.  
  22. --    print(tostring(n1),tostring(n2))
  23.       local p1 = debug.getPlayer(n1)
  24.       local p2 = debug.getPlayer(n2)
  25.       local players = debug.getPlayers()
  26.       local f1, f2 = false, false
  27.  
  28.       for i, v in ipairs(players) do
  29.         if v == n1 then f1 = true end
  30.         if v == n2 then f2 = true end
  31.       end
  32.  
  33.       if f1 and f2 then
  34.         local posX, posY, posZ = p2.getPosition()
  35.         p1.setPosition(posX, posY, posZ)
  36.       end
  37.     end
  38.   end
  39. end
Advertisement
Add Comment
Please, Sign In to add comment