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

Solved teleport potion

kilirt

New Member
Joined
May 11, 2009
Messages
223
Reaction score
2
hello, i've a problem with my script i try make 10 charge on my teleport scroll/potion but when i use it the charge down to 9 but when i use again stay at 9

Lua:
function countDown(number, pos, effect, msgonend, effectonend)
  local n = number
       for i = 1, number do
           addEvent(doSendAnimatedText,i* 1000, pos, n > 1 and n.."" or msgonend .."", n < 6 and TEXTCOLOR_RED or TEXTCOLOR_GREEN)
           addEvent(doSendMagicEffect,i* 1000, pos, n > 1 and effect or effectonend )
 
              n = n -1
       end
      n = number
return true
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
					doItemSetAttribute(item.uid, 'charges', 10)
				if getItemAttribute(item.uid, 'charges') == 1 then
					doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
					doRemoveItem(item.uid, 1)
				else
					doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
					doItemSetAttribute(item.uid, 'charges', getItemAttribute(item.uid, 'charges')-1)		
					doItemSetAttribute(item.uid, 'description', 'This item has '.. getItemAttribute(item.uid, 'charges') ..' charges left.')
				end
                if  (getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE) then
	doPlayerSendCancel(cid, "You Can't Teleport In Battle.")
	doSendMagicEffect(getPlayerPosition(cid), 2)
else doCreatureSetNoMove(cid, 1)
    countDown(10, getThingPos(cid), 5, "Warped!", 2)
    doCreatureSetNoMove(cid, 1)
    addEvent(doTeleportThing,10000,cid,getTownTemplePosition(getPlayerTown(cid)),FALSE)
    addEvent(doCreatureSetNoMove,10000,cid, 0) 
    addEvent(doSendMagicEffect,10004,getTownTemplePosition(getPlayerTown(cid)), 10)
    doItemSetAttribute(item.uid, 'charges', getItemAttribute(item.uid, 'charges')-1)
    end
return true
end

Sorry for my bad english,
i'm french
 
Lua:
local function teleportPlayer(cid, n, pos, topos, effect, msgonend, effectonend)
	if not isCreature(cid) then
		return
	end
	if n == 0 then
		doSendMagicEffect(pos, CONST_ME_POFF)
		doTeleportThing(cid, topos, true)
		doSendMagicEffect(topos, CONST_ME_TELEPORT)
		doCreatureSetNoMove(cid, false)
	else
		doSendAnimatedText(pos, n > 1 and n or msgonend, n < 6 and TEXTCOLOR_RED or TEXTCOLOR_GREEN)
		doSendMagicEffect(pos, n > 1 and effect or effectonend)
		addEvent(teleportPlayer, 1000, cid, n-1, pos, topos, effect, msgonend, effectonend)
	end
end

local charges = 10
local countDown = 2
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getCreatureCondition(cid, CONDITION_INFIGHT) then
		doPlayerSendCancel(cid, "You Can't Teleport In Battle.")
		doSendMagicEffect(getPlayerPosition(cid), 2)
		return true
	end
	local attr = getItemAttribute(item.uid, 'charges')
	if not attr then
		doItemSetAttribute(item.uid, 'charges', charges)
		doItemSetAttribute(item.uid, 'description', 'This item has '.. charges ..' charges left.')
		attr = charges
	else
		attr = attr - 1
	end
	doCreatureSetNoMove(cid, true)
	doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
	doItemSetAttribute(item.uid, 'charges', attr)		
	doItemSetAttribute(item.uid, 'description', 'This item has '.. attr ..' charges left.')
	teleportPlayer(cid, countDown, getPlayerPosition(cid), getPlayerMasterPos(cid), 5, 'Warped', 2)
	if attr == 0 then
		doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
		doRemoveItem(item.uid, 1)
	end
	return true
end
 
Back
Top