• 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+ function onhealthchange how use item attribute

Michcol94

Member
Joined
Sep 2, 2021
Messages
105
Reaction score
19
Hello. I want to load the attack and defense attribute in the onhealthchange function and I don't know how to do it, can anyone help? because I keep getting a nil value error
 
Lua Script Error: [Scripts Interface]
C:\Users\Majke\Desktop\github kopia z dokkumenty SYSTEM SKILLLI\data_moja Ś system upgrade\data\scripts\Skille\hpdamage.lua:callback
...a_moja Ś system upgrade\data\scripts\Skille\hpdamage.lua:230: attempt to index global 'itemType' (a nil value)
stack traceback:
[C]: in function '__index'
...a_moja Ś system upgrade\data\scripts\Skille\hpdamage.lua:230: in function 'modifyDamage'
...a_moja Ś system upgrade\data\scripts\Skille\hpdamage.lua:325: in function <...a_moja Ś system upgrade\data\scripts\Skille\hpdamage.lua:321>
or
Lua Script Error: [Scripts Interface]
C:\Users\Majke\Desktop\github kopia z dokkumenty SYSTEM SKILLLI\data_moja Ś system upgrade\data\scripts\Skille\hpdamage.lua:callback
...a_moja Ś system upgrade\data\scripts\Skille\hpdamage.lua:230: attempt to index global 'item' (a nil value)
stack traceback:
[C]: in function '__index'
...a_moja Ś system upgrade\data\scripts\Skille\hpdamage.lua:230: in function 'modifyDamage'
...a_moja Ś system upgrade\data\scripts\Skille\hpdamage.lua:325: in function <...a_moja Ś system upgrade\data\scripts\Skille\hpdamage.lua:321>
onHealthChangeandSkills - Pastebin.com (https://pastebin.com/vZsRyAig) use in line 77
local attackAttribute = itemType:getAttack()
and
local attackAttribute = item:getAttribute(ITEM_ATTRIBUTE_ATTACK)
USE TFS 1.5 DOWNGRADE 8.6 BY NEKIRO
 
I can't program from objects, I did it for the first time and I still can't hehe... but I found a solution for myself and it was:

Lua:
local attackAttribute = attacker:getSlotItem(CONST_SLOT_LEFT):getAttack()

--and--

local defenceAttribute = creature:getSlotItem(CONST_SLOT_LEFT):getDefense()

Thanks a lot @Evil Puncker , I knew the commands mate, I found them in the server sources, I didn't know how to use them and unfortunately by trial and error I managed to find a solution, nothing else would work for me and it always returned null or I used the wrong method for the command . If anyone would like to add some info on functions starting with getting and setting elements and modifying those values then feel free to add a post below for me and others looking for a solution or a link to a tutorial. I will thank you have a nice day greetings.
 
Back
Top