mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-10-14 14:44:55 +02:00
Full Distribution
This commit is contained in:
24
data/talkactions/scripts/teleport_creature_here.lua
Normal file
24
data/talkactions/scripts/teleport_creature_here.lua
Normal file
@@ -0,0 +1,24 @@
|
||||
function onSay(player, words, param)
|
||||
if not player:getGroup():getAccess() then
|
||||
return true
|
||||
end
|
||||
|
||||
local creature = Creature(param)
|
||||
if not creature then
|
||||
player:sendCancelMessage("A creature with that name could not be found.")
|
||||
return false
|
||||
end
|
||||
|
||||
local oldPosition = creature:getPosition()
|
||||
local newPosition = creature:getClosestFreePosition(player:getPosition(), false)
|
||||
if newPosition.x == 0 then
|
||||
player:sendCancelMessage("You can not teleport " .. creature:getName() .. ".")
|
||||
return false
|
||||
elseif creature:teleportTo(newPosition) then
|
||||
if not creature:isInGhostMode() then
|
||||
oldPosition:sendMagicEffect(CONST_ME_POFF)
|
||||
newPosition:sendMagicEffect(CONST_ME_TELEPORT)
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
Reference in New Issue
Block a user