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

Lua ring isn't giving attributes properly

Lurk

Active Member
Joined
Dec 4, 2017
Messages
336
Reaction score
49
in items.xml (one transforms into the other)
XML:
<item id="10064" article="a" name="EXP Ring 90% de exp extra">
        <attribute key="weight" value="80"/>
        <attribute key="slotType" value="ring"/>
        <attribute key="skillSword" value="1"/>
        <attribute key="skillClub" value="1"/>
        <attribute key="skillAxe" value="1"/>
        <attribute key="magicpoints" value="1"/>
        <attribute key="skillDist" value="1"/>
        <attribute key="skillShield" value="1"/>
        <attribute key="showattributes" value="1" />
    </item>
    <item id="10063" article="an" name="EXP Ring 90% de exp extra.">
        <attribute key="weight" value="80"/>
        <attribute key="skillSword" value="1"/>
        <attribute key="skillClub" value="1"/>
        <attribute key="skillAxe" value="1"/>
        <attribute key="magicpoints" value="1"/>
        <attribute key="skillDist" value="1"/>
        <attribute key="skillShield" value="1"/>
        <attribute key="showattributes" value="1" />
        <attribute key="slotType" value="ring"/>
    </item>

in movements.xml
XML:
    <movevent type="Equip" itemid="10063" slot="ring" event="script" value="expring40.lua"/>
    <movevent type="DeEquip" itemid="10064" slot="ring" event="script" value="expring40.lua"/>

expring40.lua
LUA:
local rate = 1.9
local ratevip = 2.05
local rateaccess = 1.15

function onEquip(cid, item, slot)
doTransformItem(item.uid, 10064, 1)
doPlayerSendTextMessage(cid, 22, 'Agora você ganha 90% a mais de experiencia!')

if getPlayerStorageValue(cid, 13704) - os.time() >= 1 then
doPlayerSetExperienceRate(cid, ratevip)
else
doPlayerSetExperienceRate(cid, rate)
end

return TRUE
end

function onDeEquip(cid, item, slot)
doTransformItem(item.uid, 10063, 1)
doPlayerSendTextMessage(cid, 22, 'Experiencia extra cancelada.')

if getPlayerStorageValue(cid, 13704) - os.time() >= 1 then
doPlayerSetExperienceRate(cid, rateaccess)
else
doPlayerSetExperienceRate(cid, 1)
end

return TRUE
end

expected: equip the ring ang get 1 extra distance, sword... but ain't getting the stats, I have no idea why. All the other items give attributes properly
 
didn't work, got this console error
Code:
[22:27:35.090] [Error - MoveEvents Interface]
[22:27:35.094] data/movements/scripts/expring40.lua:onDeEquip
[22:27:35.096] Description:
[22:27:35.098] data/movements/scripts/expring40.lua:28: attempt to call global 'equipFunction' (a nil value)
[22:27:35.102] stack traceback:
[22:27:35.104]  data/movements/scripts/expring40.lua:28: in function <data/movements/scripts/expring40.lua:18>
 
didn't work, got this console error
Code:
[22:27:35.090] [Error - MoveEvents Interface]
[22:27:35.094] data/movements/scripts/expring40.lua:onDeEquip
[22:27:35.096] Description:
[22:27:35.098] data/movements/scripts/expring40.lua:28: attempt to call global 'equipFunction' (a nil value)
[22:27:35.102] stack traceback:
[22:27:35.104]  data/movements/scripts/expring40.lua:28: in function <data/movements/scripts/expring40.lua:18>
LUA:
return callFunction(cid, item.uid, slot) -- use this one
return callFunction(cid, item, slot) -- if you get an error, try this instead
 
the first one:
Code:
[23:25:16.480] [Error - MoveEvents Interface]
[23:25:16.482] data/movements/scripts/expring40.lua:onDeEquip
[23:25:16.484] Description:
[23:25:16.485] (MoveEventScript::luaCallFunction) Item not found

the second one:
Code:
[23:27:43.533] [Error - MoveEvents Interface]
[23:27:43.535] data/movements/scripts/expring40.lua:onDeEquip
[23:27:43.538] Description:
[23:27:43.539] (MoveEventScript::luaCallFunction) Item not found

I'm using this returns on the dequip since when I use them on Equip (first return) the first time I try to equip the item it sends an error message, the item transforms (like if it was equiped but it's not) and then I can equip it, still no attributes and I receive this erros the first time I try to equipe the ring (the one it transformes to the equiped version but it is still in my backpack)
Code:
[23:28:16.744] [Error - MoveEvents Interface]
[23:28:16.746] data/movements/scripts/expring40.lua:onEquip
[23:28:16.749] Description:
[23:28:16.750] (MoveEventScript::luaCallFunction) Item not found

I've changed the code to
LUA:
return callFunction(cid, 10063, slot) -- if you get an error, try this instead

and got this in the console (again)
Code:
[23:32:20.944] [Error - MoveEvents Interface]
[23:32:20.947] data/movements/scripts/expring40.lua:onDeEquip
[23:32:20.949] Description:
[23:32:20.950] (MoveEventScript::luaCallFunction) Item not found
 
the first one:
Code:
[23:25:16.480] [Error - MoveEvents Interface]
[23:25:16.482] data/movements/scripts/expring40.lua:onDeEquip
[23:25:16.484] Description:
[23:25:16.485] (MoveEventScript::luaCallFunction) Item not found

the second one:
Code:
[23:27:43.533] [Error - MoveEvents Interface]
[23:27:43.535] data/movements/scripts/expring40.lua:onDeEquip
[23:27:43.538] Description:
[23:27:43.539] (MoveEventScript::luaCallFunction) Item not found

I'm using this returns on the dequip since when I use them on Equip (first return) the first time I try to equip the item it sends an error message, the item transforms (like if it was equiped but it's not) and then I can equip it, still no attributes and I receive this erros the first time I try to equipe the ring (the one it transformes to the equiped version but it is still in my backpack)
Code:
[23:28:16.744] [Error - MoveEvents Interface]
[23:28:16.746] data/movements/scripts/expring40.lua:onEquip
[23:28:16.749] Description:
[23:28:16.750] (MoveEventScript::luaCallFunction) Item not found

I've changed the code to
LUA:
return callFunction(cid, 10063, slot) -- if you get an error, try this instead

and got this in the console (again)
Code:
[23:32:20.944] [Error - MoveEvents Interface]
[23:32:20.947] data/movements/scripts/expring40.lua:onDeEquip
[23:32:20.949] Description:
[23:32:20.950] (MoveEventScript::luaCallFunction) Item not found
in your items.xml
add these lines to the respective items.
LUA:
<attribute key="transformEquipTo" value="10064"/>
<attribute key="transformDeEquipTo" value="10063"/>
Then for your script, just try something extremely simple, and see if you get any errors.
And of course and importantly, check to make sure you are receiving the skills from the items properly.
LUA:
function onEquip(cid, item, slot)
    print(1)
    return callFunction(cid, item.uid, slot)
end

function onDeEquip(cid, item, slot)
    print(2)
    return callFunction(cid, item.uid, slot)
end
 
in your items.xml
add these lines to the respective items.
LUA:
<attribute key="transformEquipTo" value="10064"/>
<attribute key="transformDeEquipTo" value="10063"/>
Then for your script, just try something extremely simple, and see if you get any errors.
And of course and importantly, check to make sure you are receiving the skills from the items properly.
LUA:
function onEquip(cid, item, slot)
    print(1)
    return callFunction(cid, item.uid, slot)
end

function onDeEquip(cid, item, slot)
    print(2)
    return callFunction(cid, item.uid, slot)
end
I think he'll have to use a storage value/check if item is in slot cause IIRC onEquip/onDeEquip executes 3-4 times in older TFS versions.
 
I think he'll have to use a storage value/check if item is in slot cause IIRC onEquip/onDeEquip executes 3-4 times in older TFS versions.
 
still ain't giving extra stats, when trying to equip for the first time I get the error message in client "You cannot dress object there" and console errors:
Code:
1

[1:33:28.338] [Error - MoveEvents Interface]
[1:33:28.343] data/movements/scripts/expring40.lua:onEquip
[1:33:28.345] Description:
[1:33:28.347] (MoveEventScript::luaCallFunction) Item not found
2

[1:33:38.702] [Error - MoveEvents Interface]
[1:33:38.706] data/movements/scripts/expring40.lua:onDeEquip
[1:33:38.708] Description:
[1:33:38.710] (MoveEventScript::luaCallFunction) Item not found

I have a lot of items that are giving stats just fine, can't I just do something like this in the script?
LUA:
function onEquip(cid, item, slot)
addatributex = 3

function onDeEquip(cid, item, slot)
removeatributex = 3
 

Similar threads

Replies
0
Views
183
Back
Top