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

AddEvent

GarQet

Own3d!
Joined
Feb 10, 2009
Messages
1,381
Solutions
14
Reaction score
81
Hello Otlanders!
I have a small problem with addEvent.
I want create special ring who:
- change our maxhealth and maxmana;
- send magic effect to us every 3 seconds (Yellow Fireworks).

Currently, my script looks like this:
Code:
local config = {
        un_equip        = 6300, -- Item ID of the UN-Equipped ring.
        equip           = 6301,  -- Item ID of the Equipped ring.
}

function onDeEquip(cid, item, slot)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your Transform Ring has been expired!")
	setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)-350)
	setCreatureMaxMana(cid, getCreatureMaxMana(cid)-700)
	doTransformItem(item.uid, config.un_equip)
        return true
end

function onEquip(cid, item, slot)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Transform ring change your Max Health and your Max Mana!\nYour power will be shown by special Effect! Yellow Fireworks!")
	setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+350)
	setCreatureMaxMana(cid, getCreatureMaxMana(cid)+700)
        doTransformItem(item.uid, config.equip)
        doDecayItem(item.uid)
        return true
end

I don't know how addEvent.
He must send magic effect on us only if we get equiped ring.
Event stoped if we get unequiped ring.

Who can help me?
Please.

//Sorry for my english.
 
PHP:
local config = {
        un_equip        = 6300, -- Item ID of the UN-Equipped ring.
        equip           = 6301,  -- Item ID of the Equipped ring.
}

_FWEVENT = {}
function fireworks(cid)
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORK_YELLOW)
	_FWEVENT[getPlayerGUID(cid)] = addEvent(fireworks, 3000, cid)
end

function onDeEquip(cid, item, slot)
	stopEvent(_FWEVENT[getPlayerGUID(cid)])
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your Transform Ring has been expired!")
	setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)-350)
	setCreatureMaxMana(cid, getCreatureMaxMana(cid)-700)
	doTransformItem(item.uid, config.un_equip)
        return true
end

function onEquip(cid, item, slot)
	fireworks(cid)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Transform ring change your Max Health and your Max Mana!\nYour power will be shown by special Effect! Yellow Fireworks!")
	setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+350)
	setCreatureMaxMana(cid, getCreatureMaxMana(cid)+700)
        doTransformItem(item.uid, config.equip)
        doDecayItem(item.uid)
        return true
end

Rep++!
 
After
Code:
	stopEvent(_FWEVENT[getPlayerGUID(cid)])
Add
Code:
	_FWEVENT[getPlayerGUID(cid)] = nil
To avoid memory leak :/
 
Back
Top