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

Solved Boolean issues

Giddran

Techical Artist
Joined
Sep 8, 2007
Messages
70
Reaction score
25
Location
Sweden
Hello guys, i'm having abit trouble understanding how to deal with the boolean values. The script works perfectly if arrowcount is a clean number or equation. But not if i extract the number from the players storage value. I appreciate the help i can get.

Code:
local spirit = 40106
local arrowcount = getPlayerStorageValue(cid, spirit)
¨
local function onCastSpell2(parameters)
doCombat(parameters.cid, parameters.combat1, parameters.var)
if n <= arrowcount then
addEvent(onCastSpell2, 350, parameters)
n = n + 1
end
end
 
Add it inside a function with the parameter cid (function onCastSpell(cid, var)), for example in the local function onCastSpell2(parameters) you showed, since cid is added to the parameters table.
Code:
local arrowcount = getPlayerStorageValue(parameters.cid, 40106)
 
I made som tries and i'm still not getting it to work. I believe my main issue is based on my lack of deeper understanding on the running of functions and especially the parameters for example cid, topos etc. I will try to find a guide somewhere that will allow me to increase my knowledge base in that area. Any directions would be sweet. I'm also posting the full version of my script, maybe i can learn something.

Thanks for the help!

Code:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, CONST_ME_HITBYFIRE)
setCombatParam(combat1, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FLAMMINGARROW)

local fire = 40101
local spirit = 40106
local arrowcount = 5 + 10
function onGetFormulaValues(cid, level, maglevel)
    local min = getPlayerStorageValue(cid, fire) * 2 + (maglevel * 1.00)+ (level * 0.2) + 20
    local max = getPlayerStorageValue(cid, fire) * 3 + (maglevel * 1.50) + (level * 0.3) + 30
    return -min, -max
end
setCombatCallback(combat1, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local function onCastSpell2(cid, var)
    doCombat(cid, var, combat1)
      if n <= arrowcount then
      addEvent(onCastSpell2, 350)
    n = n + 1
end
end

function onCastSpell(cid, var)

local parameters = { cid = cid, var = var, combat1 = combat1}
n = 2
addEvent(onCastSpell2, 1)

return
end
 
Code:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, CONST_ME_HITBYFIRE)
setCombatParam(combat1, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FLAMMINGARROW)

local fire, spirit, n = 40101, 40106, 2

function onGetFormulaValues(cid, level, maglevel)
       local min = getPlayerStorageValue(cid, fire) * 2 + (maglevel * 1.00)+ (level * 0.2) + 20
       local max = getPlayerStorageValue(cid, fire) * 3 + (maglevel * 1.50) + (level * 0.3) + 30
       return -min, -max
end

setCombatCallback(combat1, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local function onCastSpell2(cid, var)
     local arrowcount = getPlayerStorageValue(cid, spirit)
   
     doCombat(cid, combat1, var)
     if n <= arrowcount then
         addEvent(onCastSpell2, 350, cid, var)
         n = n + 1
     else
         n = 2
     end
     return true
end

function onCastSpell(cid, var)
     return onCastSpell2(cid, var)
end

If you use cid, it should be in a function with the parameter cid, else it doesn't know what cid is.
When you make a custom function (function onCastSpell2), you can add parameters to it. This way you can use the parameters from the main function (function onCastSpell) in the custom function.
 
First of all, thank you!
You were the final factor that helped me finally understand all of this.

Cheers!
 
Last edited:
Back
Top