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

Lua Damage type buffs (onuse) bug in spells

dheikon

New Member
Joined
Jan 29, 2011
Messages
5
Reaction score
1
Hello, I added this code (Damage type buffs (onuse) by Xikini) on my server and it works normally when it is a weapon with elemental damage, but when using a spell, like the exori flam, for example, I get the return of the following error:

Code:
Lua Script Error: [Scripts Interface]
C:\Users\lgfav\Desktop\1220 otservbr-global-develop\data\scripts\actions\new\onUse_damage_buff_potion.lua:callback
...op\data\scripts\actions\new\onUse_damage_buff_potion.lua:59: attempt to index a nil value
stack traceback:
        [C]: in function '__index'
        ...op\data\scripts\actions\new\onUse_damage_buff_potion.lua:59: in function 'damageCalculator'
        ...op\data\scripts\actions\new\onUse_damage_buff_potion.lua:73: in function <...op\data\scripts\actions\new\onUse_damage_buff_potion.lua:70>
        [C]: at 0x7ff7054e60c0

How can I make sure the bonus is applied to both the weapon and the spell?



 
Solution
Hello, I added this code (Damage type buffs (onuse) by Xikini) on my server and it works normally when it is a weapon with elemental damage, but when using a spell, like the exori flam, for example, I get the return of the following error:

Code:
Lua Script Error: [Scripts Interface]
C:\Users\lgfav\Desktop\1220 otservbr-global-develop\data\scripts\actions\new\onUse_damage_buff_potion.lua:callback
...op\data\scripts\actions\new\onUse_damage_buff_potion.lua:59: attempt to index a nil value
stack traceback:
        [C]: in function '__index'
        ...op\data\scripts\actions\new\onUse_damage_buff_potion.lua:59: in function 'damageCalculator'
        ...op\data\scripts\actions\new\onUse_damage_buff_potion.lua:73: in function...
Hello, I added this code (Damage type buffs (onuse) by Xikini) on my server and it works normally when it is a weapon with elemental damage, but when using a spell, like the exori flam, for example, I get the return of the following error:

Code:
Lua Script Error: [Scripts Interface]
C:\Users\lgfav\Desktop\1220 otservbr-global-develop\data\scripts\actions\new\onUse_damage_buff_potion.lua:callback
...op\data\scripts\actions\new\onUse_damage_buff_potion.lua:59: attempt to index a nil value
stack traceback:
        [C]: in function '__index'
        ...op\data\scripts\actions\new\onUse_damage_buff_potion.lua:59: in function 'damageCalculator'
        ...op\data\scripts\actions\new\onUse_damage_buff_potion.lua:73: in function <...op\data\scripts\actions\new\onUse_damage_buff_potion.lua:70>
        [C]: at 0x7ff7054e60c0

How can I make sure the bonus is applied to both the weapon and the spell?




Update the damageCalculator function with this. đź‘Ť
Lua:
local function damageCalculator(primaryDamage, primaryType, secondaryDamage, secondaryType, playerid)
    local player = Player(playerid)
    local currentTime = os.time()
    
    if primaryType ~= 0 and player:getStorageValue(damageTypes[primaryType][2]) > currentTime then
        local damageValue = player:getStorageValue(damageTypes[primaryType][1])
        local additionalDamage = damageValue > 0 and damageValue or 0
        primaryDamage = primaryDamage + additionalDamage
    end
    
    if secondaryType ~= 0 and player:getStorageValue(damageTypes[secondaryType][2]) > currentTime then
        local damageValue = player:getStorageValue(damageTypes[secondaryType][1])
        local additionalDamage = damageValue > 0 and damageValue or 0
        secondaryDamage = secondaryDamage + additionalDamage
    end
    
    return primaryDamage, secondaryDamage
end
 
Solution
Back
Top