position.lua

main 35 lines · 1 KB Raw
Alex Alex Commit Server upload 18/10/2026 23:38
1-- /pos -> shows your current position
2-- /pos x, y, z -> teleports there (gamemaster and above)
3function onSay(player, words, param)
4 local position = player:getPosition()
5 if param == "" or not player:getGroup():getAccess() then
6 player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Your current position is: " .. position.x .. ", " .. position.y .. ", " .. position.z .. ".")
7 return false
8 end
9
10 local coords = {}
11 for value in param:gmatch("%d+") do
12 coords[#coords + 1] = tonumber(value)
13 end
14
15 if #coords ~= 3 then
16 player:sendCancelMessage("Usage: /pos x, y, z")
17 return false
18 end
19
20 local destination = Position(coords[1], coords[2], coords[3])
21 if not Tile(destination) then
22 player:sendCancelMessage("There is no tile at " .. coords[1] .. ", " .. coords[2] .. ", " .. coords[3] .. ".")
23 return false
24 end
25
26 if not player:isInGhostMode() then
27 position:sendMagicEffect(CONST_ME_TELEPORT)
28 end
29 player:teleportTo(destination)
30 if not player:isInGhostMode() then
31 destination:sendMagicEffect(CONST_ME_TELEPORT)
32 end
33 return false
34end
35
Top