• 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!

Remove rune (teleport item)

zxzxzx

New Member
Joined
Mar 12, 2011
Messages
334
Reaction score
3
Hello! I need to remove item when I use it

the script:
Code:
local newPos = {
        x = 955,
        y = 1008,
        z = 3
}

local delayInSeconds = 1800

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_POFF)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, FALSE)

function onCastSpell(cid, var)
    do
        doTeleportThing(cid,newPos)
        doSendMagicEffect(newPos,10)
        doCombat(cid, combat, var)
        return true
    end
    return true
end

I'm bad in scripting so I post here

thanks for help ++
 
Why are you using onCastSpell if you want your character to teleport do a different position by clicking an item?

You can just use
Code:
local pos = {
x = 955,
y = 1008,
z = 3
}
function onUse(cid, item, itemEx, fromPosition, toPosition)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
doTeleportThing(cid, pos)
doSendMagicEffect(pos, CONST_ME_ENERGYAREA)
return true
end
 
doRemoveItem(item.uid) would remove the item

This is the TP scroll I was using, I edited it a little from Colandus's version.
Code:
-- By Colandus LEAVE CREDITS

local countdown = 5
local name = "Your Temple"
local cfg = {
   exhausted = 0, -- Time you are exhausted.
   storage = 1337, -- Storage used for "exhaust."
}
local action = {}

local function teleport(p)
local cid, count = unpack(p)
if(isPlayer(cid) == TRUE) then
local cancelled = not action[cid]
local playerPos = getCreaturePosition(cid)
if(not cancelled) then
if(getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE) then
doPlayerSendTextMessage(cid, 21, "Teleport cancelled because of being in a fight!")
cancelled = true
elseif(count > 0) then
doCreatureSay(cid, "Teleporting in " .. count .. " seconds.", TALKTYPE_ORANGE_1)
doSendAnimatedText(playerPos, "Teleport", TEXTCOLOR_RED)
doSendMagicEffect(playerPos, CONST_ME_FIREATTACK)
addEvent(teleport, 1000, {cid, count - 1})
else
doTeleportThing(cid, getPlayerMasterPos(cid))
doPlayerSendTextMessage(cid, 21, "Teleported to the " .. name .. ".")
doSendMagicEffect(playerPos, CONST_ME_ASSASSIN)
doCreatureSetNoMove(cid, 0)

local playerPos = getCreaturePosition(cid)
doSendMagicEffect(playerPos, CONST_ME_FIREATTACK)
doSendMagicEffect(playerPos, CONST_ME_FIREAREA)

action[cid] = false
end
end

if(cancelled) then
doSendAnimatedText(playerPos, "Cancelled", TEXTCOLOR_RED)
doCreatureSetNoMove(cid, 0)
action[cid] = false
end
end
end

function onUse(cid, item, ppos, frompos, item2, topos)
   if(getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE) then
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot use a teleport scroll when you are in a fight.")
     doCreatureSetNoMove(cid, 0)
   elseif(action[cid]) then
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have cancelled the teleport.")
     doCreatureSetNoMove(cid, 0)
     action[cid] = false
     setPlayerStorageValue(cid, cfg.storage, os.time() + cfg.exhausted)
     return TRUE
   elseif(getPlayerStorageValue(cid, cfg.storage) > os.time()) then
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "The power of this scroll is too strong to be executed this fast. You must wait " .. getPlayerStorageValue(cid, cfg.storage) - os.time() .. ' second'  .. ((getPlayerStorageValue(cid, cfg.storage) - os.time()) == 1 and "" or "s") .. " to teleport again.")
   else
     doCreatureSetNoMove(cid, 1)
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Charging scroll. You can not move while this scroll is charging, if you have another scroll you can use it to cancel the teleport. If you get attacked the charge will break.")
     action[cid] = true
     teleport({cid, countdown})
     setPlayerStorageValue(cid, cfg.storage, os.time() + cfg.exhausted)
     doRemoveItem(item.uid)
   end

if(action[cid] == false) then
doSendMagicEffect(frompos, CONST_ME_POFF)
end
return TRUE
end
 
Back
Top