• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Recharge for tp how i can add recharge for tp

Nerevr back

Member
Joined
Nov 7, 2014
Messages
269
Reaction score
7
i have tp and want player can use it 2x and then remove but i don't know how to edite
Code:
--Script by Sonical
local config = {
fromPosition = {x = 4487, y = 9954, z = 11}, -- top left cornor of the playground
     toPosition = {x = 5511, y = 6652, z = 11}, -- bottom right cornor of the playground
     }
local newpos = {x=3321, y=33254, z=7} --New position
function onUse(cid, item, frompos, item2, topos)
if not isInRange(getPlayerPosition(cid), config.fromPosition, config.toPosition) then
     return doPlayerSendCancel(cid, "You can't use this items in event.")
end
if (exhaustion.check(cid, 17724)) then
        doPlayerSendCancel(cid, "You will be able to use event teleport in  "..tostring(exhaustion.get(cid, 17724)).." seconds.")
        return true
    end
    local inFight = hasCondition(cid, CONDITION_INFIGHT)
     if not inFight then
      doSendMagicEffect(getPlayerPosition(cid), 2)
      doTeleportThing(cid,newpos)
      doSendMagicEffect(newpos,10)
      exhaustion.set(cid, 17724, 80)
      doRemoveItem(item.uid, 1)
     
else
doPlayerSendTextMessage(cid,25,"You could not use this teleport Now You or You have battel!")
end
return 1
end
 
Replace doRemoveItem(item.uid, 1) with this
Code:
doItemSetAttribute(item.uid, "aid", getItemAttribute(item.uid, "aid") ~= nil and getItemAttribute(item.uid, "aid") + 100 or 100)
if getItemAttribute(item.uid, "aid") == 200 then
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "The item is used 2x and is now removed.")
     doRemoveItem(item.uid, 1)
end
 
Code:
doItemSetAttribute(item.uid, "aid", getItemAttribute(item.uid, "aid") ~= nil and getItemAttribute(item.uid, "aid") + 100 or 100)
doItemSetAttribute(item.uid, "description",  "It has "..(getItemAttribute(item.uid, "description") ~= nil and ((500-getItemAttribute(item.uid, "aid")) /100) or 4).." charge"..(getItemAttribute(item.uid, "aid") == 400 and "" or "s").." left.")
if getItemAttribute(item.uid, "aid") == 500 then
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "The item is used 5x and is now removed.")
     doRemoveItem(item.uid, 1)
end
 
Do you mean with a globalevent? Should the tp be removed later?
Code:
local config = {
     toPos = {x = 92, y = 119, z = 7},
     tpPos = {x = 100, y = 219, z = 7}
}

function doRemoveTeleport()
     doRemoveItem(getTileItemById(config.tpPos, 1484).uid, 1)
     doBroadcastMessage("The teleport is removed.")
     return true
end

function doCreateTeleportx()
     local tp = doCreateTeleport(1387, config.toPos, config.tpPos)
     doItemSetAttribute(tp, "aid", 6096)
     doBroadcastMessage("The teleport is created.")
     return true
end

function onThink(interval, lastExecution)
     doBroadcastMessage("The teleport will be created in 20 seconds!")
     addEvent(doCreateTeleportx, 20 * 1000)
     addEvent(doRemoveTeleport, 60 * 1000)
     return true
end
Set the interval to 30 min in globalevents.xml
 
Do you mean with a globalevent? Should the tp be removed later?
Code:
local config = {
     toPos = {x = 92, y = 119, z = 7},
     tpPos = {x = 100, y = 219, z = 7}
}

function doRemoveTeleport()
     doRemoveItem(getTileItemById(config.tpPos, 1484).uid, 1)
     doBroadcastMessage("The teleport is removed.")
     return true
end

function doCreateTeleportx()
     local tp = doCreateTeleport(1387, config.toPos, config.tpPos)
     doItemSetAttribute(tp, "aid", 6096)
     doBroadcastMessage("The teleport is created.")
     return true
end

function onThink(interval, lastExecution)
     doBroadcastMessage("The teleport will be created in 20 seconds!")
     addEvent(doCreateTeleportx, 20 * 1000)
     addEvent(doRemoveTeleport, 60 * 1000)
     return true
end
Set the interva to 30 min in globalevents.xml
i want it without tppos i just need very 30 min appear tp in temple with action id 9900 and want it appear in 2 postion
 
Code:
local positions = {
     {x = 92, y = 119, z = 7},
     {x = 100, y = 219, z = 7}
}

function doRemoveTeleport()
     for pos = 1, #positions do
         doRemoveItem(getTileItemById(positions[pos], 9739).uid, 1)
     end
     doBroadcastMessage("The teleports are removed.")
     return true
end

function doCreateTeleportx()
     for pos = 1, #positions do
         local tp = doCreateItem(9739, 1, positions[pos])
         doItemSetAttribute(tp, "aid", 9900)
     end
     doBroadcastMessage("The teleports are created.")
     return true
end

function onThink(interval, lastExecution)
     doBroadcastMessage("The teleports will be created in 20 seconds!")
     addEvent(doCreateTeleportx, 20 * 1000)
     addEvent(doRemoveTeleport, 60 * 1000)
     return true
end
 
Back
Top