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

RevScripts Bug/with exp ring+exp eggs

Joker Man

Active Member
Joined
Nov 7, 2021
Messages
106
Reaction score
27
hello guys
I`m have a problem in my server, when i use exp ring + eggs give 10% Exp get bug everytime use eggs get 10%+10% and no lose
can eggs up 1000%
when up exp ring change with other ring get skill down like 0
script ring is full bug skill/items with save all my eggs time no down
tfs 1.2
how i can fix it
local config = {

rate = 0.02, -- 0.02 = 1x faster than normal.
un_equip = 7967, -- Item ID of the UN-Equipped ring.
equip = 7968 -- Item ID of the Equipped ring.

}

function onDeEquip(cid, item, slot)
doPlayerSetExperienceRate(cid, 0.02)
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))*0.02)
else
doPlayerSetExperienceRate(cid, getConfigValue("rateExperience")*0.02)
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has been activated! It is now: " .. config.rate .. "x doubled your former experience rate.")
doTransformItem(item.uid, config.equip)
doDecayItem(item.uid)
return true
end
<!-- Exp Ring -->
<movevent type="Equip" itemid="7967" slot="ring" event="function" value="onEquipItem"/>
<movevent type="Equip" itemid="7968" slot="ring" event="script" value="script.lua"/>
<movevent type="DeEquip" itemid="7968" slot="ring" event="script" value="script.lua"/>
 

Attachments

Last edited:
Try it out:
Lua:
local config = {
    rate = 0.02,     -- Experience rate multiplier
}

local useExpStages = getConfigValue("experienceStages") == "yes"
local rateExperiance = getConfigValue("rateExperience")

local function getInitialExpRate(cid)
    return useExpStages and getExperienceStage(getPlayerLevel(cid)) or rateExperiance
end

function onDeEquip(cid, item, slot)
    doPlayerSetExperienceRate(cid, getInitialExpRate(cid))
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has ended.")
    return true
end

function onEquip(cid, item, slot)
    doPlayerSetExperienceRate(cid, getInitialExpRate(cid) * config.rate)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,
        "Your extra experience rate has been activated! It is now: " ..
        config.rate .. "x doubled your former experience rate.")
    doDecayItem(item.uid)
    return true
end

BTW: Actually you need to set config.rate to something grater than 1 :)
 
Last edited:
Try it out:
Lua:
local config = {
    rate = 0.02,     -- Experience rate multiplier
    un_equip = 7967, -- Item ID of the UN-Equipped ring.
    equip = 7968     -- Item ID of the Equipped ring.
}

local useExpStages = getConfigValue("experienceStages") == "yes"
local rateExperiance = getConfigValue("rateExperience")

local function getInitialExpRate(cid)
    return useExpStages and getExperienceStage(getPlayerLevel(cid)) or rateExperiance
end

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

    return true
end

function onEquip(cid, item, slot)
    doPlayerSetExperienceRate(cid, getInitialExpRate(cid) * config.rate)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,
        "Your extra experience rate has been activated! It is now: " ..
        config.rate .. "x doubled your former experience rate.")
    doTransformItem(item.uid, config.equip)
    doDecayItem(item.uid)
    return true
end

BTW: Actually you need to set config.rate to something grater than 1 :)
still bug you can test it
when change my exp ring with other ring skill 0
items.xml
<item id="7967" article="a" name="Exp ring">
<attribute key="weight" value="80"/>
<attribute key="slotType" value="ring"/>
<attribute key="transformEquipTo" value="7968"/>
<attribute key="stopduration" value="1"/>
<attribute key="showduration" value="1"/>
</item>
<item id="7968" article="a" name="Exp ring">
<attribute key="weight" value="80"/>
<attribute key="slotType" value="ring"/>
<attribute key="decayTo" value="0"/>
<attribute key="transformDeEquipTo" value="7967"/>
<attribute key="duration" value="3700"/>
<attribute key="showduration" value="1"/>
<attribute key="description" value="2x Double exp."/>
</item>
movements.xml
<!-- Exp Ring -->
<movevent type="Equip" itemid="7967" slot="ring" event="function" value="onEquipItem"/>
<movevent type="Equip" itemid="7968" slot="ring" event="script" value="script.lua"/>
<movevent type="DeEquip" itemid="7968" slot="ring" event="script" value="script.lua"/>
 

Attachments

Last edited:
@Joker Man Is onDeEquip executed once you replace this ring with another? (Put there some print('onDeEquip'))

EDIT: Wait a minute, you said you're on TFS 1.2, where doPlayerSetExperienceRate is anyway deprecated.
Do you get any warning in console?
Are you sure it's 1.2? As yours movements entries looks like they produce errors (missing "event" property):
[Error - MoveEvent::configureMoveEvent] Missing event

Maybe simply change movements.xml to
XML:
<!-- Exp Ring -->
<movevent event="Equip" itemid="7967" slot="ring" function="onEquipItem" />
<movevent event="DeEquip" itemid="7968" slot="ring" function="onDeEquipItem" />

And register custom eventCallback in data/scripts/eventcallbacks/player
Lua:
local ec = EventCallback

local bonusExperienceItems = {
     {
        id = 7968,
        slot = CONST_SLOT_RING,
        multiplier = 1.1 -- 10%
    }
}

ec.onGainExperience = function(self, source, exp, rawExp)
    local player = Player(self)
    if not player then
        return nil
    end

    local multiplier = 1
    for _, config in pairs(bonusExperienceItems) do
        local item = player:getSlotItem(config.slot)
        if item and item:getId() == config.id then
            multiplier = math.max(multiplier, config.multiplier)
        end
    end

    return exp * multiplier
end

ec:register()
 
Last edited:
@Joker Man Is onDeEquip executed once you replace this ring with another? (Put there some print('onDeEquip'))

EDIT: Wait a minute, you said you're on TFS 1.2, where doPlayerSetExperienceRate is anyway deprecated.
Do you get any warning in console?
Are you sure it's 1.2? As yours movements entries looks like they produce errors (missing "event" property):
[Error - MoveEvent::configureMoveEvent] Missing event

Maybe simply change movements.xml to
XML:
<!-- Exp Ring -->
<movevent event="Equip" itemid="7967" slot="ring" function="onEquipItem" />
<movevent event="DeEquip" itemid="7968" slot="ring" function="onDeEquipItem" />

And register custom eventCallback in data/scripts/eventcallbacks/player
Lua:
local ec = EventCallback

local bonusExperienceItems = {
     {
        id = 7968,
        slot = CONST_SLOT_RING,
        multiplier = 1.1 -- 10%
    }
}

ec.onGainExperience = function(self, source, exp, rawExp)
    local player = Player(self)
    if not player then
        return nil
    end

    local multiplier = 1
    for _, config in pairs(bonusExperienceItems) do
        local item = player:getSlotItem(config.slot)
        if item and item:getId() == config.id then
            multiplier = math.max(multiplier, config.multiplier)
        end
    end

    return exp * multiplier
end

ec:register()
<!-- Player methods -->
<event file="Player" function="onGainExperience" enabled="1" />
no working erro in tfs
 
Last edited:
It’s custom callback, name whatever you like and put there:
data/scripts/eventcallbacks/player

When you’re not certain things are registered correcrly just put some print(„executed”) in there or put breakpoint in debugger to manually check which things are/not executed
 
Last edited:
i fix it
but thanks for everything
proplem was in V
function" value="onEquipItem"/>< i change to value="expring.lua"/>
now working good
thanks my brother
was
<!-- Exp Ring -->
<movevent type="Equip" itemid="7967" slot="ring" event="function" value="onEquipItem"/>
<movevent type="Equip" itemid="7968" slot="ring" event="script" value="script.lua"/>
<movevent type="DeEquip" itemid="7968" slot="ring" event="script" value="script.lua"/>


im upated to
<movevent type="Equip" itemid="7967" slot="ring" event="script" value="expring.lua"/>
<movevent type="Equip" itemid="7968" slot="ring" event="script" value="expring.lua"/>
<movevent type="DeEquip" itemid="7968" slot="ring" event="script" value="expring.lua"/>
 
Last edited:
It still has duplicates (as you dont equip item with ID: 7968), that should be enough
Try:
XML:
<movevent event="Equip" itemid="7967" slot="ring" script="expring.lua"/>
<movevent event="Equip" itemid="7968" slot="ring" script="expring.lua"/>
<movevent event="DeEquip" itemid="7968" slot="ring" script="expring.lua"/>
 
Last edited:
But I’d try to test it furthermore as there are for some reason such equip entries in TFS (maybe to make it work after re-login while equiped)
 
Back
Top