OTHispano
¿Quieres reaccionar a este mensaje? Regístrate en el foro con unos pocos clics o inicia sesión para continuar.

Ir abajo
[Action] Poner teleport con item 9uylN
"Ryukend"
Miembro
Mensajes Mensajes : 120

[Action] Poner teleport con item Empty [Action] Poner teleport con item

Mar Nov 08, 2011 1:09 pm
Bueno la funcion de este script es crear un teleport por medio de un item, k en este caso es el "2361".
(Bueno alguna ves an jugado armada azteca? en el concurso de sillas?, bueno si lo an echo veran k el god crea unos tps sin comando, sino k usando un item (Esa es la funcion de este script)

Tomen en cuenta k el teleport siempre los llevara a la misma posicion, k sera la k ustedes dejen registrada.
Comensemos, iremos a Data/Action/script/. Y crearan un archivo.lua llamado "portal" y agregaran esto:
Código:

-- Don't load the file if the server doesn't support it
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 -- Making the function smaller =p
local allowedVocations = {2, 6} -- The allowed vocations to create the portal
local clientVersion = 810 -- 800 for 8.0, 792 for 7.92
local timeToRemove = 5 -- Time to remove the portal after it is created. In seconds.
local canUseOnPz = True -- Can it be used in a protection zone? TRUE for yes, FALSE for no
local giveInfightCondition = FALSE -- Should it forbidds the player from logging out while he has a portal? TRUE for yes, FALSE for no
local portalCreationDelay = 0 -- Set(in seconds) the delay time between each created portal. 0 to disable.
 
local condition = 0
if(giveInfightCondition ~= FALSE) then
  condition = createConditionObject(CONDITION_INFIGHT)
  setConditionParam(condition, CONDITION_PARAM_TICKS, (timeToRemove * 1000)+2000)
end
 
-- Functions declared before using them
 
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)
  -- function based on exhausted-function v1.1 by Alreth
  -- <a href="links.php?url=http://otfans.net/showthread.php?t=23607" target="_blank">http://otfans.net/showthread.php?t=23607</a>
  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
--End of functions
 
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 == 1000 and topos.y == 1000 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

En donde dice portalPos = {x=1750, y=1594, z=7}
elseif(town == 2) then
portalPos = {x=1750, y=1594, z=7}
elseif(town == 3) then
portalPos = {x=1750, y=1594, z=7}
Cambien la Ubicacion Very Happy pongan el las 3 lo mismo

luego en Action.xml pondran lo siguiente:
Código:

<action itemid="2361" event="script" value="portal.lua" />

Una Imagen en nuestro Ot Demoition de los portales que se crean al usar el Item:
[Action] Poner teleport con item Sinttulopwl.th


Bueno Si les gusto den +REP si no ni comenten ^^
Volver arriba
Permisos de este foro:
No puedes responder a temas en este foro.