• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Extra EXP if item onEquip

Ates.tr

Im back
Joined
Nov 11, 2007
Messages
1,046
Reaction score
2
Location
Sweden
-- Im sure this will not work, could anyone tell me how to fix this?


Code:
function onEquip(cid, item, slot)

local time = 1000*60*10 -- After 10 mins will the item remove.
local id = 1000 -- Remember to put the id of item.
local msg = "Double Experience"
local msglost = "The amulet its destroyed"
local msg30 = "You have to be level 30 or higher"

if item.itemid == id then
if getPlayerLevel(cid) >= 30 then
         doCreatureSay(cid, msg, TALKTYPE_ORANGE_1)
         setPlayerExtraExpRate(cid, 2)
		 doRemoveItem(cid, id, msglost, time)
elseif item.itemid == id then
if getPlayerLevel(cid) <= 30 then
         doCreatureSay(cid, msg30, TALKTYPE_ORANGE_1)
         end
     return FALSE
end
end
 
Use "addEvent" to remove a item after certain time...

Try this.. (this will destroy the amulet in 10 minutes)

Code:
[COLOR="Blue"]function onEquip(cid, item, slot)

local timeToRemove = [COLOR="DarkGreen"]10[/COLOR] -- in minutes
local itemID = [COLOR="DarkGreen"]ITEMID_HERE[/COLOR]
local msg = [COLOR="DarkGreen"]"Double Experience"[/COLOR]
local msg30 = [COLOR="DarkGreen"]"You have to be level 30 or higher"[/COLOR]

if item.itemid == itemID and getPlayerLevel(cid) >= [COLOR="DarkGreen"]30[/COLOR] then
	doCreatureSay(cid, [COLOR="DarkGreen"]msg[/COLOR], TALKTYPE_ORANGE_1)
	setPlayerExtraExpRate(cid, [COLOR="DarkGreen"]2[/COLOR])
	addEvent([COLOR="DarkGreen"]doDestroyAmulet[/COLOR], ([COLOR="DarkGreen"]1000*60*timeToRemove[/COLOR]))

else
	doCreatureSay(cid, [COLOR="DarkGreen"]msg30[/COLOR], TALKTYPE_ORANGE_1)

	end
end

function [COLOR="DarkGreen"]doDestroyAmulet()[/COLOR]

local msgLost = [COLOR="DarkGreen"]"The amulet its destroyed"[/COLOR]

	doRemoveItem(item.uid, 1)
	doCreatureSay(cid, [COLOR="DarkGreen"]msgLost[/COLOR], TALKTYPE_ORANGE_1)
end

function onDeEquip(cid, item, slot)

	setPlayerExtraExpRate(cid, [COLOR="DarkGreen"]0[/COLOR])
end[/COLOR]

But if you want that the amulet is destroyed 10 minutes later only if the amulet this one equipped then...

Code:
[COLOR="Blue"]function onEquip(cid, item, slot)

local timeToRemove = [COLOR="DarkGreen"]10[/COLOR] -- in minutes
local itemID = [COLOR="DarkGreen"]ITEMID_HERE[/COLOR]
local msg = [COLOR="DarkGreen"]"Double Experience"[/COLOR]
local msg30 = [COLOR="DarkGreen"]"You have to be level 30 or higher"[/COLOR]

if item.itemid == [COLOR="DarkGreen"]itemID[/COLOR] and getPlayerLevel(cid) >= [COLOR="DarkGreen"]30[/COLOR] then
	doCreatureSay(cid, [COLOR="DarkGreen"]msg[/COLOR], TALKTYPE_ORANGE_1)
	setPlayerExtraExpRate(cid, [COLOR="DarkGreen"]2[/COLOR])
	addEvent(doDestroyAmulet, ([COLOR="DarkGreen"]1000*60*timeToRemove[/COLOR]))

else
	doCreatureSay(cid, [COLOR="DarkGreen"]msg30[/COLOR], TALKTYPE_ORANGE_1)

	end
end

function [COLOR="DarkGreen"]doDestroyAmulet()[/COLOR]

local msgLost = [COLOR="DarkGreen"]"The amulet its destroyed"[/COLOR]

if getPlayerSlotItem(cid, [COLOR="DarkGreen"]2[/COLOR]) == [COLOR="DarkGreen"]ITEMID_HERE[/COLOR] then

	doRemoveItem(item.uid, 1)
	doCreatureSay(cid, [COLOR="DarkGreen"]msgLost[/COLOR], TALKTYPE_ORANGE_1)

else
		return [COLOR="DarkGreen"]FALSE[/COLOR]
	end
end

function onDeEquip(cid, item, slot)

	setPlayerExtraExpRate(cid, [COLOR="DarkGreen"]0[/COLOR])
end[/COLOR]
 
Last edited:
@darkhaos

The problem is, if he will take it off after 9 minutes 50 seconds, wait 15 seconds he has next 10 minutes until removing amulet, that's why me solution is the best one (of course I have alternative solution, but this one is enough good).
 
Darkhaos = Best ;) thansk man really thank ful... could you make me a inq script ? :S no one working for me the released

Edit: Could you tell me why use function onDestorRing ()... ?
 
What exactly doesn't work?:> I think the better way is to put duration on item (items.xml), and functions doRemoveItem has less arguments ;p

yeh, but just a small problem :P ~ i tried doing it before ~, but looks like there is a problem in latest tfs when you try use script="anything" + function="onEquip" ...
the duration from items.xml just get fucked, never removed the item ~

btw those scripts sucksssss, too bad.

one of those...
if the player DeEquip the item before the 10 minutes the item will not be removed ~loool~ pls >_>
the other...
if the player DeEquip the item to save "duration" but he will be fucked btw >_^...

in both scripts

what about if the player logout before the event is executed >_^ ?
beeerp useless scripts


Try this one
PHP:
local timeToRemove = 10 --Minutes ~
local itemID = ITEMID_HERE
local msg = "Double Experience"
local msg30 = "You have to be level 30 or higher"
local msgLost = "The amulet has been destroyed"

--Do no edit if you dont know what it does ~
local Interval = 1 --interval to check the time, minutes.
local Slot = 2

function CheckItemTime(x)
    local Item = getPlayerSlotItem(x.cid, Slot)
    if Item.itemid == itemID then
        if Item.actionid > 1000 then
            addEvent(CheckItemTime, Interval * 60 * 1000, {cid=x.cid})
            doSetItemActionId(Item.uid, Item.actionid - 1)
            doSetItemSpecialDescription(Item.uid, "It have energy for "..(Item.actionid - 1) - 1000 .." minutes left.")
        else
            setPlayerExtraExpRate(x.cid, 0)
            doCreatureSay(x.cid, msgLost, TALKTYPE_ORANGE_1)
            doRemoveItem(Item.uid)
        end    
    end
end

function onEquip(cid, item, slot)
    if item.actionid == 0 then
        doSetItemActionId(item.uid, timeToRemove + 1000)
    end
    if item.itemid == itemID and getPlayerLevel(cid) >= 30 then
        doCreatureSay(cid, msg, TALKTYPE_ORANGE_1)
        setPlayerExtraExpRate(cid, 2)
        addEvent(CheckRingTime, Interval * 60 * 1000, {cid=cid})
    else
        doCreatureSay(cid, msg30, TALKTYPE_ORANGE_1)
    end
end

function onDeEquip(cid, item, slot)
    setPlayerExtraExpRate(cid, 0)
end
 
yeh, but just a small problem :P ~ i tried doing it before ~, but looks like there is a problem in latest tfs when you try use script="anything" + function="onEquip" ...
the duration from items.xml just get fucked, never removed the item ~

btw those scripts sucksssss, too bad.

one of those...
if the player DeEquip the item before the 10 minutes the item will not be removed ~loool~ pls >_>
the other...
if the player DeEquip the item to save "duration" but he will be fucked btw >_^...

in both scripts

what about if the player logout before the event is executed >_^ ?
beeerp useless scripts


Try this one
PHP:
local timeToRemove = 10 --Minutes ~
local itemID = ITEMID_HERE
local msg = "Double Experience"
local msg30 = "You have to be level 30 or higher"
local msgLost = "The amulet has been destroyed"

--Do no edit if you dont know what it does ~
local Interval = 1 --interval to check the time, minutes.
local Slot = 2

function CheckItemTime(x)
    local Item = getPlayerSlotItem(x.cid, Slot)
    if Item.itemid == itemID then
        if Item.actionid > 1000 then
            addEvent(CheckItemTime, Interval * 60 * 1000, {cid=x.cid})
            doSetItemActionId(Item.uid, Item.actionid - 1)
            doSetItemSpecialDescription(Item.uid, "It have energy for "..(Item.actionid - 1) - 1000 .." minutes left.")
        else
            setPlayerExtraExpRate(x.cid, 0)
            doCreatureSay(x.cid, msgLost, TALKTYPE_ORANGE_1)
            doRemoveItem(Item.uid)
        end    
    end
end

function onEquip(cid, item, slot)
    if item.actionid == 0 then
        doSetItemActionId(item.uid, timeToRemove + 1000)
    end
    if item.itemid == itemID and getPlayerLevel(cid) >= 30 then
        doCreatureSay(cid, msg, TALKTYPE_ORANGE_1)
        setPlayerExtraExpRate(cid, 2)
        addEvent(CheckRingTime, Interval * 60 * 1000, {cid=cid})
    else
        doCreatureSay(cid, msg30, TALKTYPE_ORANGE_1)
    end
end

function onDeEquip(cid, item, slot)
    setPlayerExtraExpRate(cid, 0)
end

Thanks elite scripter but ey...

Where do i put in this script ?

Edit: Using TFS 0.3 B2
 
movements/scripts


movements.xml add

Code:
 <movevent event="Equip" itemid="id" slot="necklace" script="name.lua"/>
    <movevent event="DeEquip" itemid="id" slot="necklace" script="name.lua"/>
 
don't complain on other scripts while your is as buggy as theirs :)

mine its not so buggy as his one, mine save time ~, also you can edit the interval to check every 5 seconds if you want and the user will not be able to take the ring before the time is gone.
 
If he take amulet off and on and off and on and off~ it will make multiple addEvents which will cause the amulet to lose several charges at once.
 
Back
Top