teleport_creature_here.lua

main 25 lines · 710 bytes Raw
Alex Alex Commit Server upload 18/10/2026 23:38
1function onSay(player, words, param)
2 if player:getGroup():getId() < 3 then
3 return false
4 end
5
6 local creature = Creature(param)
7 if not creature then
8 player:sendCancelMessage("A creature with that name could not be found.")
9 return false
10 end
11
12 local oldPosition = creature:getPosition()
13 local newPosition = creature:getClosestFreePosition(player:getPosition(), false)
14 if newPosition.x == 0 then
15 player:sendCancelMessage("You can not teleport " .. creature:getName() .. ".")
16 return false
17 elseif creature:teleportTo(newPosition) then
18 if not creature:isInGhostMode() then
19 oldPosition:sendMagicEffect(CONST_ME_POFF)
20 newPosition:sendMagicEffect(CONST_ME_TELEPORT)
21 end
22 end
23 return false
24end
25
Top