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

Exp Ring Problem

Misokoko

New Member
Joined
Mar 29, 2013
Messages
126
Reaction score
0
hello i got a problem with my exp ring when i equip or de equip it server got crash
my tfs 0.4 and the script in movements.xml :

Code:
<movevent type="Equip" itemid="6301" slot="ring" event="function" value="onEquipItem"/>
<movevent type="Equip" itemid="6300" slot="ring" event="script" value="expring.lua"/>
<movevent type="DeEquip" itemid="6301" slot="ring" event="script" value="expring.lua"/>

and in scripts
Code:
local config = {

rate = 1.2, -- 1.2 =  faster than normal.
un_equip = 6300, -- Item ID of the UN-Equipped ring.
equip = 6301 -- Item ID of the Equipped ring.

}

function onDeEquip(cid, item, slot)
doPlayerSetExperienceRate(cid, 1.0)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has ended.")
doTransformItem(item.uid, config.un_equip)
return true
end

function onEquip(cid, item, slot)
if getConfigValue("experienceStages") == "yes" then
doPlayerSetExperienceRate(cid, getExperienceStage(getPlayerLevel(cid))*1.2)
else
doPlayerSetExperienceRate(cid, getConfigValue("rateExperience")*1.2)
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has been activated! It is now doubled your former experience rate.")
doTransformItem(item.uid, config.equip)
doDecayItem(item.uid)
return true
end
and sometimes igot this only error in console :
[Error - ItemSpawnEvent::configureRaidEvent] id (or name) tag missing for itemspawn event.
[Error - ItemSpawnEvent::configureRaidEvent] id (or name) tag missing for itemspawn event.
 
I don't think you need to transform the object?
I think items.xml and movements.xml handles that for you.

I think it's trying to register the item, but it's ID changes, and the server is like.. wtf? .. and then crashes maybe.
Try green texting/removing the doTransformItem in both equip and deEquip, and see what happens. (also checking items.xml to make sure the ring is set to change id's. You can check other ring examples like life ring to see what I mean)
 
don't set the base id (the id before transformation) to a script
keep it as function onEquip in the xml, set 6301 equip/deequip to the scripts
 
I don't think you need to transform the object?
I think items.xml and movements.xml handles that for you.

I think it's trying to register the item, but it's ID changes, and the server is like.. wtf? .. and then crashes maybe.
Try green texting/removing the doTransformItem in both equip and deEquip, and see what happens. (also checking items.xml to make sure the ring is set to change id's. You can check other ring examples like life ring to see what I mean)
don't set the base id (the id before transformation) to a script
keep it as function onEquip in the xml, set 6301 equip/deequip to the scripts
failed with that can someone rewrite it with right use @Xeraphus @Xikini !
 
Last edited:
Try Xeraphus's suggestion, as it sounds right.

Your current.
Code:
<movevent type="Equip" itemid="6301" slot="ring" event="function" value="onEquipItem"/>
<movevent type="Equip" itemid="6300" slot="ring" event="script" value="expring.lua"/>
<movevent type="DeEquip" itemid="6301" slot="ring" event="script" value="expring.lua"/>
Xeraphus's suggestion.
Code:
<movevent type="Equip" itemid="6300" slot="ring" event="function" value="onEquipItem"/>
<movevent type="Equip" itemid="6301" slot="ring" event="script" value="expring.lua"/>
<movevent type="DeEquip" itemid="6301" slot="ring" event="script" value="expring.lua"/>
 
Try Xeraphus's suggestion, as it sounds right.

Your current.
Code:
<movevent type="Equip" itemid="6301" slot="ring" event="function" value="onEquipItem"/>
<movevent type="Equip" itemid="6300" slot="ring" event="script" value="expring.lua"/>
<movevent type="DeEquip" itemid="6301" slot="ring" event="script" value="expring.lua"/>
Xeraphus's suggestion.
Code:
<movevent type="Equip" itemid="6300" slot="ring" event="function" value="onEquipItem"/>
<movevent type="Equip" itemid="6301" slot="ring" event="script" value="expring.lua"/>
<movevent type="DeEquip" itemid="6301" slot="ring" event="script" value="expring.lua"/>
worked but when i un equiped the ring and back it to ring slot again stop working and there is no errors !!
 
--- Explaination:

Try Xeraphus's suggestion, as it sounds right.

Your current.
Code:
<movevent type="Equip" itemid="6301" slot="ring" event="function" value="onEquipItem"/>
<movevent type="Equip" itemid="6300" slot="ring" event="script" value="expring.lua"/>
<movevent type="DeEquip" itemid="6301" slot="ring" event="script" value="expring.lua"/>
Xeraphus's suggestion.
Code:
<movevent type="Equip" itemid="6300" slot="ring" event="function" value="onEquipItem"/>
<movevent type="Equip" itemid="6301" slot="ring" event="script" value="expring.lua"/>
<movevent type="DeEquip" itemid="6301" slot="ring" event="script" value="expring.lua"/>
This is just bad. Cannot handle the logic.

When you have a item with id 6300 which turns into 6301 when you equip it and back to 6300 when deequip, you have to use these simple things:

In movements.xml
Code:
<movevent type="Equip" itemid="6300" slot="ring" event="function" value="onEquipItem"/>
<movevent type="DeEquip" itemid="6301" slot="ring" event="function" value="onDeEquipItem"/>

And in items.xml
Code:
<item id="6300" article="a" name="death ring">
    <attribute key="decayTo" value="6301"/>
</item>
<item id="6301" article="a" name="death ring">
    <attribute key="decayTo" value="6300"/>
</item>

If you want to use something different then "built-in-sources' script" with function onEquipItem/onDeEquipItem you have to use this instead. But then if you dont put doTransformItem manually inside script item won't change when you equip/deequip it.
Code:
<movevent type="Equip" itemid="6300" slot="ring" event="script" value="expring.lua"/>
<movevent type="DeEquip" itemid="6301" slot="ring" event="script" value="expring.lua"/>
No any extra lines like you have atm.

This part is missing code and is wrong. Becouse when you equip ring on 100x rate server, your exp rate will be temporary boosted to 120x as long as you wear ring. But when you deEquip this ring your exp rate will drop to 1x instead of back to normal 100x.
Code:
function onDeEquip(cid, item, slot)
    doPlayerSetExperienceRate(cid, 1.0) -- THIS IS WRONG!!!
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has ended.")
    doTransformItem(item.uid, config.un_equip)
    return true
end

Also this part is wrong too:
Code:
function onEquip(cid, item, slot)
    if getConfigValue("experienceStages") == "yes" then
        doPlayerSetExperienceRate(cid, getExperienceStage(getPlayerLevel(cid))*1.2)
    else
        doPlayerSetExperienceRate(cid, getConfigValue("rateExperience")*1.2)
    end
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has been activated! It is now doubled your former experience rate.")
    doTransformItem(item.uid, config.equip) -- TRANSFORMS ITEM
    doDecayItem(item.uid) -- TRANSFORMS IT ONCE AGAIN TO ITEMID TAKEN FROM ITEMS.XML
    return true
end

The last lines of code are looping decay. 4th line from the end doTransformItem turns item to 6301 and then instantly 3th line from the end doDecayItem turns that item to value taken from items.xml.

--- As requested:

Full correct movements:
Code:
<movevent type="Equip" itemid="6300" slot="ring" event="script" value="expring.lua"/>
<movevent type="DeEquip" itemid="6301" slot="ring" event="script" value="expring.lua"/>

And full correct script:
Code:
local config = {

rate = 1.2, -- 1.2 =  faster than normal.
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 extra experience rate has ended.")
    doTransformItem(item.uid, config.un_equip)
    -- sets rates back to normal, based on server's rates
    if getConfigValue("experienceStages") == "yes" then
        doPlayerSetExperienceRate(cid, getExperienceStage(getPlayerLevel(cid)))
    else
        doPlayerSetExperienceRate(cid, getConfigValue("rateExperience"))
    end
    return true
end

function onEquip(cid, item, slot)
    if getConfigValue("experienceStages") == "yes" then
        doPlayerSetExperienceRate(cid, getExperienceStage(getPlayerLevel(cid))*1.2)
    else
        doPlayerSetExperienceRate(cid, getConfigValue("rateExperience")*1.2)
    end
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has been activated! It is now doubled your former experience rate.")
    doTransformItem(item.uid, config.equip)
    return true
end

#edit
Don't put:
Code:
<attribute key="decayTo" value="xxxx"/>
in your items.xml
 
Last edited:
--- Explaination:


This is just bad. Cannot handle the logic.

When you have a item with id 6300 which turns into 6301 when you equip it and back to 6300 when deequip, you have to use these simple things:

In movements.xml
Code:
<movevent type="Equip" itemid="6300" slot="ring" event="function" value="onEquipItem"/>
<movevent type="DeEquip" itemid="6301" slot="ring" event="function" value="onDeEquipItem"/>

And in items.xml
Code:
<item id="6300" article="a" name="death ring">
    <attribute key="decayTo" value="6301"/>
</item>
<item id="6301" article="a" name="death ring">
    <attribute key="decayTo" value="6300"/>
</item>

If you want to use something different then "built-in-sources' script" with function onEquipItem/onDeEquipItem you have to use this instead. But then if you dont put doTransformItem manually inside script item won't change when you equip/deequip it.
Code:
<movevent type="Equip" itemid="6300" slot="ring" event="script" value="expring.lua"/>
<movevent type="DeEquip" itemid="6301" slot="ring" event="script" value="expring.lua"/>
No any extra lines like you have atm.

This part is missing code and is wrong. Becouse when you equip ring on 100x rate server, your exp rate will be temporary boosted to 120x as long as you wear ring. But when you deEquip this ring your exp rate will drop to 1x instead of back to normal 100x.
Code:
function onDeEquip(cid, item, slot)
    doPlayerSetExperienceRate(cid, 1.0) -- THIS IS WRONG!!!
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has ended.")
    doTransformItem(item.uid, config.un_equip)
    return true
end

Also this part is wrong too:
Code:
function onEquip(cid, item, slot)
    if getConfigValue("experienceStages") == "yes" then
        doPlayerSetExperienceRate(cid, getExperienceStage(getPlayerLevel(cid))*1.2)
    else
        doPlayerSetExperienceRate(cid, getConfigValue("rateExperience")*1.2)
    end
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has been activated! It is now doubled your former experience rate.")
    doTransformItem(item.uid, config.equip) -- TRANSFORMS ITEM
    doDecayItem(item.uid) -- TRANSFORMS IT ONCE AGAIN TO ITEMID TAKEN FROM ITEMS.XML
    return true
end

The last lines of code are looping decay. 4th line from the end doTransformItem turns item to 6301 and then instantly 3th line from the end doDecayItem turns that item the value taken from items.xml.

--- As requested:

Full correct movements:
Code:
<movevent type="Equip" itemid="6300" slot="ring" event="script" value="expring.lua"/>
<movevent type="DeEquip" itemid="6301" slot="ring" event="script" value="expring.lua"/>

And full correct script:
Code:
local config = {

rate = 1.2, -- 1.2 =  faster than normal.
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 extra experience rate has ended.")
    doTransformItem(item.uid, config.un_equip)
    -- sets rates back to normal, based on server's rates
    if getConfigValue("experienceStages") == "yes" then
        doPlayerSetExperienceRate(cid, getExperienceStage(getPlayerLevel(cid)))
    else
        doPlayerSetExperienceRate(cid, getConfigValue("rateExperience"))
    end
    return true
end

function onEquip(cid, item, slot)
    if getConfigValue("experienceStages") == "yes" then
        doPlayerSetExperienceRate(cid, getExperienceStage(getPlayerLevel(cid))*1.2)
    else
        doPlayerSetExperienceRate(cid, getConfigValue("rateExperience")*1.2)
    end
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has been activated! It is now doubled your former experience rate.")
    doTransformItem(item.uid, config.equip)
    return true
end

#edit
Don't put:
Code:
<attribute key="decayTo" value="xxxx"/>
in your items.xml
i made as u said
1- ring can't be un equiped
2- i got this error in console and after that server crash
R6025
- pure virtual function call
here is the script in items.xml
Code:
    <item id="6300" article="a" name="Exp Ring">
        <attribute key="weight" value="80" />
        <attribute key="slotType" value="ring" />
        <attribute key="transformEquipTo" value="6301" />
        <attribute key="stopduration" value="1" />
        <attribute key="showduration" value="1" />
    </item>
    <item id="6301" article="a" name="Exp Ring">
        <attribute key="weight" value="80" />
        <attribute key="slotType" value="ring" />
        <attribute key="transformDeEquipTo" value="6300" />
        <attribute key="duration" value="60" />
        <attribute key="armor" value="1" />
        <attribute key="showduration" value="1" />
    </item>
 
you have to have 6300 as function onEquip
6301 as script for both equip and deequip

6300 gets equipped, fires function onEquip from source -> transforms to 6301 -> 6301 script executes for onEquip

you might need callFunction in 0.4

instead of return true:
return callFunction(cid, item.uid, slot)
 
i made as u said
1- ring can't be un equiped
2- i got this error in console and after that server crash
R6025
- pure virtual function call
here is the script in items.xml
Code:
    <item id="6300" article="a" name="Exp Ring">
        <attribute key="weight" value="80" />
        <attribute key="slotType" value="ring" />
        <attribute key="transformEquipTo" value="6301" />
        <attribute key="stopduration" value="1" />
        <attribute key="showduration" value="1" />
    </item>
    <item id="6301" article="a" name="Exp Ring">
        <attribute key="weight" value="80" />
        <attribute key="slotType" value="ring" />
        <attribute key="transformDeEquipTo" value="6300" />
        <attribute key="duration" value="60" />
        <attribute key="armor" value="1" />
        <attribute key="showduration" value="1" />
    </item>

Forgot 0.4, so again:

Here, movements.xml:
Code:
    <movevent type="Equip" itemid="6300" slot="ring" event="script" value="expring.lua"/>
    <movevent type="Equip" itemid="6301" slot="ring" event="script" value="expring.lua"/>
    <movevent type="DeEquip" itemid="6301" slot="ring" event="script" value="expring.lua"/>
Items.xml (same as yours):
Code:
    <item id="6300" article="a" name="death ring">
        <attribute key="weight" value="80"/>
        <attribute key="slotType" value="ring"/>
        <attribute key="transformEquipTo" value="6301"/>
        <attribute key="stopduration" value="1"/>
        <attribute key="showduration" value="1"/>
    </item>
    <item id="6301" article="a" name="death ring">
        <attribute key="weight" value="80"/>
        <attribute key="slotType" value="ring"/>
        <attribute key="decayTo" value="0"/>
        <attribute key="transformDeEquipTo" value="6300"/>
        <attribute key="duration" value="480"/>
        <attribute key="skillShield" value="-11"/>
        <attribute key="showduration" value="1"/>
    </item>
Script, expring.lua (same as before):
Code:
local config = {

rate = 1.2, -- 1.2 =  faster than normal.
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 extra experience rate has ended.")
    doTransformItem(item.uid, config.un_equip)
    if getConfigValue("experienceStages") == "yes" then
        doPlayerSetExperienceRate(cid, getExperienceStage(getPlayerLevel(cid)))
    else
        doPlayerSetExperienceRate(cid, getConfigValue("rateExperience"))
    end
    return true
end

function onEquip(cid, item, slot)
    if getConfigValue("experienceStages") == "yes" then
        doPlayerSetExperienceRate(cid, getExperienceStage(getPlayerLevel(cid))*1.2)
    else
        doPlayerSetExperienceRate(cid, getConfigValue("rateExperience")*1.2)
    end
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has been activated! It is now doubled your former experience rate.")
    doTransformItem(item.uid, config.equip)
    return true
end
 
Last edited:
Forgot 0.4, so again:

Here, movements.xml:
Code:
    <movevent type="Equip" itemid="6300" slot="ring" event="script" value="expring.lua"/>
    <movevent type="Equip" itemid="6301" slot="ring" event="script" value="expring.lua"/>
    <movevent type="DeEquip" itemid="6301" slot="ring" event="script" value="expring.lua"/>
Items.xml (same as yours):
Code:
    <item id="6300" article="a" name="death ring">
        <attribute key="weight" value="80"/>
        <attribute key="slotType" value="ring"/>
        <attribute key="transformEquipTo" value="6301"/>
        <attribute key="stopduration" value="1"/>
        <attribute key="description" value="(death damage +30%)"/>
        <attribute key="showduration" value="1"/>
    </item>
    <item id="6301" article="a" name="death ring">
        <attribute key="weight" value="80"/>
        <attribute key="slotType" value="ring"/>
        <attribute key="decayTo" value="0"/>
        <attribute key="transformDeEquipTo" value="6300"/>
        <attribute key="duration" value="480"/>
        <attribute key="description" value="(death damage +30%)"/>
        <attribute key="skillShield" value="-11"/>
        <attribute key="showduration" value="1"/>
    </item>
Script, expring.lua (same as before):
Code:
local config = {

rate = 1.2, -- 1.2 =  faster than normal.
un_equip = 6300, -- Item ID of the UN-Equipped ring.
equip = 6301 -- Item ID of the Equipped ring.

}

function onDeEquip(cid, item, slot)
    doPlayerSetExperienceRate(cid, 1.0)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has ended.")
    doTransformItem(item.uid, config.un_equip)
    if getConfigValue("experienceStages") == "yes" then
        doPlayerSetExperienceRate(cid, getExperienceStage(getPlayerLevel(cid)))
    else
        doPlayerSetExperienceRate(cid, getConfigValue("rateExperience"))
    end
    return true
end

function onEquip(cid, item, slot)
    if getConfigValue("experienceStages") == "yes" then
        doPlayerSetExperienceRate(cid, getExperienceStage(getPlayerLevel(cid))*1.2)
    else
        doPlayerSetExperienceRate(cid, getConfigValue("rateExperience")*1.2)
    end
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has been activated! It is now doubled your former experience rate.")
    doTransformItem(item.uid, config.equip)
    return true
end
6300 should be function onEquip instead of script
otherwise it executes twice, + the extra time because of onEquip bug
in the equip script you're supposed to check itemid once and execute the rest of the script if it's the correct itemid in the ring slot since equip executes twice
Code:
if item.itemid == 6301 then
    if getPlayerSlotItem(cid, CONST_SLOT_RING).itemid == 6301 then
        ...
    end
end
 
6300 should be function onEquip instead of script
otherwise it executes twice, + the extra time because of onEquip bug
in the equip script you're supposed to check itemid once and execute the rest of the script if it's the correct itemid in the ring slot since equip executes twice
Code:
if item.itemid == 6301 then
    if getPlayerSlotItem(cid, CONST_SLOT_RING).itemid == 6301 then
        ...
    end
end
Half measures to avoid evil bugs of 0.4, know that pain. Checked it and it's even worse, not executing 2 times, but even 3.
That's why I never used 0.4 on my ot

OKU2tSV.png
 
Half measures to avoid evil bugs of 0.4, know that pain. Checked it and it's even worse, not executing 2 times, but even 3.
That's why I never used 0.4 on my ot

OKU2tSV.png
i thought it was 3 but i second guessed myself and figured there was no way
but i guess it is 3 lmao
the bug exists on all server versions pretty sure, on tfs 1.2 it executes twice
 
omg :D is there is another Replacement for this script like in action id or something instead of movements
@Xeraphus @andu @Xikini
You can use code we gave to you. It's not a big problem. Script is just executed 3 times instead of 1. The difference is very minimal, like 0,3kB more RAM. While 1GB RAM = around 1.000.000 kB RAM
 
You can use code we gave to you. It's not a big problem. Script is just executed 3 times instead of 1. The difference is very minimal, like 0,3kB more RAM. While 1GB RAM = around 1.000.000 kB RAM
i used yours and got this error : pure virtual function call then server crashed
 

Similar threads

Back
Top