Ola XTibianos, venho aqui postar um código que cria um Teleport com magia estilo Ragnarök.
O destino do TP vai ser o temple do player que o criou.
Avisando desde já que esse TP Script não é meu, e sim de outro usuario (veja os créditos no final do post).
Começando...
Crie um arquivo chamado Portal.lua na pasta "data/actions/scripts/", nele coloque essas sintaxes:
if(getTileItemByType == nil or getPlayerGUID == nil or doCreateTeleport == nil) then
error("Your server does not have support for this script!")
return
end
local getStore = getPlayerStorageValue
local allowedVocations = {2, 6} -- Vocações que podem criar o Portal.
local clientVersion = 810 -- 800 para cliente 8.0, 792 para cliente 7.92
local timeToRemove = 10 -- Tempo que o portal irá desaparecer, em segundos.
local canUseOnPz = FALSE -- Pode ser usado em Protection Zone? FALSE para não, TRUE para sim.
local giveInfightCondition = FALSE -- FALSE para que o char não consiga criar o portal em batalha, TRUE para que consiga.
local portalCreationDelay = 0 -- Tempo para que o portal apareça depois de ter usado a magia.
local condition = 0
if(giveInfightCondition ~= FALSE) then
condition = createConditionObject(CONDITION_INFIGHT)
setConditionParam(condition, CONDITION_PARAM_TICKS, (timeToRemove * 1000)+2000)
end
-- Funções
local function getPlayerLookPos(cid)
local playerPos = getCreaturePosition(cid)
local lookDir = getPlayerLookDir(cid)
if(lookDir == NORTH) then
playerPos.y = playerPos.y-1
elseif(lookDir == SOUTH) then
playerPos.y = playerPos.y+1
elseif(lookDir == WEST) then
playerPos.x = playerPos.x-1
elseif(lookDir == EAST) then
playerPos.x = playerPos.x+1
end
return playerPos
end
local function removePortal(params)
local remItem = getTileItemByType(params.pos, ITEM_TYPE_TELEPORT)
if(remItem.actionid == params.store and getGlobalStorageValue(params.store) == 1) then
doRemoveItem(remItem.uid)
doSendMagicEffect(params.pos, CONST_ME_POFF)
setGlobalStorageValue(params.store, 0)
end
end
local function canCreatePortal(cid)
if(portalCreationDelay == 0) then
return true
end
local newExhaust = os.time()
local oldExhaust = getPlayerStorageValue(cid, 65000)
if(oldExhaust == nil or oldExhaust < 0) then
oldExhaust = 0
end
local diffTime = os.difftime(newExhaust, oldExhaust)
if(diffTime >= portalCreationDelay or diffTime < 0) then
setPlayerStorageValue(cid, 65000, newExhaust)
return true
end
return false
end
function onUse(cid, item, frompos, item2, topos)
local portalPos = {x=getStore(cid, 8997), y=getStore(cid, 8998), z=getStore(cid, 8999)}
local playerPos = getCreaturePosition(cid)
local storage = 9000 + getPlayerGUID(cid)
if(portalPos.x < 0 or portalPos.y < 0 or portalPos.z < 0)then
local town = getPlayerTown(cid)
if(town == 1) then
portalPos = {x=100, y=100, z=7}
elseif(town == 2) then
portalPos = {x=452, y=338, z=6}
elseif(town == 3) then
portalPos = {x=796, y=1025, z=8}
--Add many towns as you wish.
end
end
local useFromPos = {x=frompos.x, y=frompos.y, z=frompos.z}
if(useFromPos.x == 65535) then
useFromPos = {x=playerPos.x, y=playerPos.y, z=playerPos.z}
end
if(topos.x == 65535 or (topos.x == 31 and topos.y == 31 and topos.z == 7)) then
return FALSE
end
if(portalPos.x == topos.x and portalPos.y == topos.y and portalPos.z == topos.z) then
doPlayerSendCancel(cid, "You cannot create a portal in the same place you are going to!")
return TRUE
end
if(canUseOnPz == FALSE and (getTilePzInfo(topos) == TRUE or getTilePzInfo(useFromPos) == TRUE)) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE)
return TRUE
end
if(isInArray(allowedVocations, getPlayerVocation(cid)) == TRUE or getPlayerAccess(cid) ~= 0) then
if(canCreatePortal(cid) or getPlayerAccess(cid) ~= 0) then
if(getGlobalStorageValue(storage) ~= 1) then
local addPos = {x=topos.x, y=topos.y, z=topos.z}
if(clientVersion < 800) then
addPos = getPlayerLookPos(cid)
end
local portal = doCreateTeleport(1387, portalPos, addPos)
doSetItemActionId(portal, storage)
if(clientVersion < 810) then
doSendMagicEffect(addPos, CONST_ME_ENERGYAREA)
else
doSendMagicEffect(addPos, CONST_ME_TELEPORT)
end
if(doSendDistanceShoot ~= nil) then
doSendDistanceShoot(playerPos, addPos, CONST_ANI_ENERGY)
end
doSendMagicEffect(playerPos, CONST_ME_MAGIC_GREEN)
setGlobalStorageValue(storage, 1)
local params = {pid=cid, store=storage, pos=addPos}
addEvent(removePortal, timeToRemove * 1000, params)
if(giveInfightCondition == TRUE) then
doTargetCombatCondition(0, cid, condition, CONST_ME_NONE)
end
else
doSendMagicEffect(playerPos, CONST_ME_POFF)
doPlayerSendCancel(cid, "You already have a portal.")
end
else
doSendMagicEffect(playerPos, CONST_ME_POFF)
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
end
else
doSendMagicEffect(playerPos, CONST_ME_POFF)
doPlayerSendCancel(cid, "You do not have the required vocation.")
end
return TRUE
end
Agora no Actions.xml adicione essa linha:
<action itemid="2361" script="portal.lua"/>
Vá para a pasta "data/movements/scripts/" e crie um arquivo chamado removeportal.lua com essas sintaxes:
function onStepOut(cid, item, pos) local storage = 9000 + getPlayerGUID(cid) if(isPlayer(cid) == TRUE) then if(item.actionid == storage and getGlobalStorageValue(storage) == 1) then doRemoveItem(item.uid) doSendMagicEffect(pos, CONST_ME_TELEPORT) setGlobalStorageValue(storage, 0) end end return TRUE end
No arquivo movements.xml adicione:
<movevent event="StepOut" itemid="1387" script="removeportal.lua" />
Após isso vá para a pasta "data/talkactions/scripts/" e crie um arquivo chamado setportal.lua, nele adicione isso:
local allowedVocs = {2, 6}
local allowOnPz = FALSE
function onSay(cid, words, param)
local pos = getPlayerPosition(cid)
if(isInArray(allowedVocs, getPlayerVocation(cid)) == TRUE or getPlayerAccess(cid) ~= 0) then
if(getTilePzInfo(pos) == FALSE or allowOnPz == TRUE) then
setPlayerStorageValue(cid, 8997, pos.x)
setPlayerStorageValue(cid, 8998, pos.y)
setPlayerStorageValue(cid, 8999, pos.z)
doSendMagicEffect(pos, CONST_ME_MAGIC_BLUE)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have set a new position for your portals.")
else
doSendMagicEffect(pos, CONST_ME_POFF)
doPlayerSendCancel(cid, "You cannot set a portal position here.")
return FALSE
end
else
doSendMagicEffect(pos, CONST_ME_POFF)
doPlayerSendCancel(cid, "You do not have the required vocation.")
return FALSE
end
return TRUE
end
No arquivo talkactions.xml adicione isso:
<talkaction words="alana vis" script="setportal.lua" />
Pronto, agora é só testa, espero que tenham gostado ![]()

Créditos: Pedro B.























