mRefaat
Marketing and Coding
Hello
I am using this script to update some storages but i get this error when equip the ring
script
error
How to fix this error or how to make this script with the right way without errors and avoid the tfs bug/w.e (3 times check on equip)?
I am using this script to update some storages but i get this error when equip the ring
script
Lua:
local config = {
[2471] = {attackspeed= 50, damageincrease = 50, dodge = 50, healingbonus = 50, damagereduction = 50}, -- golden helmet
[2493] = {attackspeed= 50, damageincrease = 50, dodge = 50, healingbonus = 50, damagereduction = 50}, -- ring of the sky
[2525] = {attackspeed= 50, damageincrease = 50, dodge = 50, healingbonus = 50, damagereduction = 50}, -- dwarven shield
}
function onEquip(player, item, slot, isCall)
if isCall == false then
player:setStorageValue(PlayerStorageKeys.ItemsExtraAttackSpeed, player:getStorageValue(PlayerStorageKeys.ItemsExtraAttackSpeed) + config[item:getId()].attackspeed) -- add attack speed
player:setStorageValue(PlayerStorageKeys.ItemsExtraDamageIncrease, player:getStorageValue(PlayerStorageKeys.ItemsExtraDamageIncrease) + config[item:getId()].damageincrease) -- add damage increase
player:setStorageValue(PlayerStorageKeys.ItemsExtraDodge, player:getStorageValue(PlayerStorageKeys.ItemsExtraDodge) + config[item:getId()].dodge) -- add dodge
player:setStorageValue(PlayerStorageKeys.ItemsExtraHealingBonus, player:getStorageValue(PlayerStorageKeys.ItemsExtraHealingBonus) + config[item:getId()].healingbonus) -- add healing bonus
player:setStorageValue(PlayerStorageKeys.ItemsDamageReduction, player:getStorageValue(PlayerStorageKeys.ItemsDamageReduction) + config[item:getId()].damagereduction) -- add damage reduction
end
return true
end
function onDeEquip(player, item, slot)
player:setStorageValue(PlayerStorageKeys.ItemsExtraAttackSpeed, player:getStorageValue(PlayerStorageKeys.ItemsExtraAttackSpeed) - config[item:getId()].attackspeed) -- remove attack speed
player:setStorageValue(PlayerStorageKeys.ItemsExtraDamageIncrease, player:getStorageValue(PlayerStorageKeys.ItemsExtraDamageIncrease) - config[item:getId()].damageincrease) -- remove damage increase
player:setStorageValue(PlayerStorageKeys.ItemsExtraDodge, player:getStorageValue(PlayerStorageKeys.ItemsExtraDodge) - config[item:getId()].dodge) -- remove dodge
player:setStorageValue(PlayerStorageKeys.ItemsExtraHealingBonus, player:getStorageValue(PlayerStorageKeys.ItemsExtraHealingBonus) - config[item:getId()].healingbonus) -- remove healing bonus
player:setStorageValue(PlayerStorageKeys.ItemsDamageReduction, player:getStorageValue(PlayerStorageKeys.ItemsDamageReduction) - config[item:getId()].damagereduction) -- remove damage reduction
return true
end
XML:
<movevent event="Equip" itemid="2471" slot="head" function="onEquipItem" script="custom/items_attributes.lua" />
<movevent event="DeEquip" itemid="2471" slot="head" function="onDeEquipItem" script="custom/items_attributes.lua" />
<movevent event="Equip" itemid="2123" slot="ring" function="onEquipItem" script="custom/items_attributes.lua" />
<movevent event="DeEquip" itemid="2123" slot="ring" function="onDeEquipItem" script="custom/items_attributes.lua" />
<movevent event="Equip" itemid="2525" slot="shield" function="onEquipItem" script="custom/items_attributes.lua" />
<movevent event="DeEquip" itemid="2525" slot="shield" function="onDeEquipItem" script="custom/items_attributes.lua" />
error
Code:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/custom/items_attributes.lua:onEquip
data/movements/scripts/custom/items_attributes.lua:10: attempt to index a nil value
stack traceback:
[C]: in function '__index'
data/movements/scripts/custom/items_attributes.lua:10: in function <data/movements/scripts/custom/items_attributes.lua:8>
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/custom/items_attributes.lua:onDeEquip
data/movements/scripts/custom/items_attributes.lua:20: attempt to index a nil value
stack traceback:
[C]: in function '__index'
data/movements/scripts/custom/items_attributes.lua:20: in function <data/movements/scripts/custom/items_attributes.lua:19>
How to fix this error or how to make this script with the right way without errors and avoid the tfs bug/w.e (3 times check on equip)?