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

TFS 1.X+ Movement addSpecialSkill bug (tripling value)

oserc

Advanced OT User
Joined
Mar 5, 2022
Messages
148
Solutions
1
Reaction score
194
Location
Brazil
Hey folks, I'm trying to make a brass helmet, when equipped, to give +1 critical chance and + 1 critical amount to the player. Obviously, with a movement script, that has been written as follows:

XML:
function onEquip(player, item, slot)
    player:addSpecialSkill(SPECIALSKILL_CRITICALHITCHANCE, 1)
    player:addSpecialSkill(SPECIALSKILL_CRITICALHITAMOUNT, 1)
return true
end

function onDeEquip(player, item, slot)
    player:addSpecialSkill(SPECIALSKILL_CRITICALHITCHANCE, -1)
    player:addSpecialSkill(SPECIALSKILL_CRITICALHITAMOUNT, -1)
return true
end

Inside movements.xml, I put this:

XML:
<movevent event="Equip" itemid="2460" slot="head" script="brasshelmet.lua" />
<movevent event="DeEquip" itemid="2460" slot="head" script="brasshelmet.lua" />

The problem is: when i equip the item, it gives me 3 (not 1) critical hit chance and critical amount, for NO reason. If I log out with the brass helmet equipped, when I log in again my crit chance/amount is 1 (correct), but if I dequip it and equip it again, it raises to 3 again.

Any thoughts about why is this happening?
 
Solution
try this:
Lua:
function onEquip(player, item, slot, isCheck)
    if isCheck then
        return true
    end

    player:addSpecialSkill(SPECIALSKILL_CRITICALHITCHANCE, 1)
    player:addSpecialSkill(SPECIALSKILL_CRITICALHITAMOUNT, 1)
    return true
end

Currently #4214 has been added to TFS, however there are still two calls instead of three, one for verification, with isCheck true, and another to conclude that the item is being equipped with isCheck false
try this:
Lua:
function onEquip(player, item, slot, isCheck)
    if isCheck then
        return true
    end

    player:addSpecialSkill(SPECIALSKILL_CRITICALHITCHANCE, 1)
    player:addSpecialSkill(SPECIALSKILL_CRITICALHITAMOUNT, 1)
    return true
end

Currently #4214 has been added to TFS, however there are still two calls instead of three, one for verification, with isCheck true, and another to conclude that the item is being equipped with isCheck false
 
Solution
By the way, I'm using TFS 1.4.1 and OTClient Redemption 1.0
Post automatically merged:

try this:
Lua:
function onEquip(player, item, slot, isCheck)
    if isCheck then
        return true
    end

    player:addSpecialSkill(SPECIALSKILL_CRITICALHITCHANCE, 1)
    player:addSpecialSkill(SPECIALSKILL_CRITICALHITAMOUNT, 1)
    return true
end
Works perfectly! Thank you very much!
 
Back
Top