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

Using storage in weapons

Infernum

Senator
Joined
Feb 14, 2015
Messages
5,640
Solutions
559
Reaction score
3,976
Is there a way to get a storage value and use it for damage in a weapon?

I tried this but it didn't work, can anyone show me how to do this?
Code:
local stor = getPlayerStorageValue(cid, 45001)
local combat = createCombatObject()
    setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
    setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)
    setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
    setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -0.1, -stor*8+10, -0.2, -stor*8+20)
    setCombatArea(combat,createCombatArea({{3}}))

function onUseWeapon(cid, var)
    return doCombat(cid, combat, var)
end
 
Use the following:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PIERCEDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_WEAPONTYPE)

function onGetFormulaValues(cid, level, skill, attack, element, factor)
   min = getPlayerStorageValue(cid, "minattack")
   max = getPlayerStorageValue(cid, "maxattack")
   return -min, -max
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onUseWeapon(cid, var)
   return doCombat(cid, combat, var)
end
 
I edited the storage values to make the damage, I get no errors or anything, the weapon just doesn't work.
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PIERCEDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_WEAPONTYPE)

function onGetFormulaValues(cid, level, skill, attack, element, factor)
   min = getPlayerStorageValue(cid, 45001)*8+10
   max = getPlayerStorageValue(cid, 45001)*8+20
   return -min, -max
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onUseWeapon(cid, var)
   return doCombat(cid, combat, var)
end
 
Nevermind, fixed it myself, had to edit the combat params, should have looked at the script more before I made another reply.
Thank you @Flatlander.

Yea I had PIERCEDAMAGE in there instead of PHYSICALDAMAGE. sorry! My servers are always pretty custom and I got that from an older version of one of my servers.
 
Back
Top