• 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 Change Attack Wand/ice-fire

Gaber Zen

Well-Known Member
Joined
Apr 22, 2023
Messages
224
Reaction score
51
Location
Egypt
hello every one some one can help me
when i Change wand attack get erro
(otx-tibia 8.60)
[Error - Weapon Interface]
data/weapons/scripts/Assault Staff.lua:eek:nUseWeapon
Description:
data/weapons/scripts/Assault Staff.lua:49: attempt to index local 'combat' (a boolean value)
stack traceback:
data/weapons/scripts/Assault Staff.lua:49: in function <data/weapons/scripts/Assault Staff.lua:42>

Lua:
local combat_types = {
    [1] = {cond = CONDITION_FREEZING, effect = CONST_ME_ICEATTACK, anim = CONST_ANI_ICE, damage = COMBAT_ICEDAMAGE},
    [2] = {cond = CONDITION_FIRE, effect = CONST_ME_FIREATTACK, anim = CONST_ANI_FIRE, damage = COMBAT_FIREDAMAGE},
    [3] = {cond = CONDITION_POISON, effect = CONST_ME_SMALLPLANTS, anim = CONST_ANI_EARTH, damage = COMBAT_EARTHDAMAGE},
    [4] = {cond = CONDITION_ENERGY, effect = CONST_ME_ENERGYHIT, anim = CONST_ANI_ENERGY, damage = COMBAT_ENERGYDAMAGE},
    [5] = {effect = CONST_ME_CAKE, anim = CONST_ANI_CAKE, damage = COMBAT_CAKEDAMAGE},
    [6] = {cond = CONDITION_CURSED, effect = CONST_ME_MORTAREA, anim = CONST_ANI_SUDDENDEATH, damage = COMBAT_DEATHDAMAGE},

    default = {damage = COMBAT_CAKEDAMAGE},
}

local config = {
    storage = 101010,
    block_armor = true,
    condition_rounds = 0,
    condition_value = 0,
    condition_time = 2000,
}

for key, combat in pairs(combat_types) do
    combat.object = createCombatObject()

    setCombatParam(combat.object, COMBAT_PARAM_TYPE, combat.damage or COMBAT_PHYSICALDAMAGE)
    setCombatParam(combat.object, COMBAT_PARAM_EFFECT, combat.effect or CONST_ME_NONE)
    setCombatParam(combat.object, COMBAT_PARAM_DISTANCEEFFECT, combat.anim or CONST_ANI_NONE)
    setCombatParam(combat.object, COMBAT_PARAM_BLOCKARMOR, config.block_armor and 1 or 0)

    setCombatFormula(combat.object, COMBAT_FORMULA_LEVELMAGIC, 0, -3000, 0, -3500)

    if combat.cond then
        local condition = createConditionObject(combat.cond)
        setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
        addDamageCondition(condition, config.condition_rounds, config.condition_time, config.condition_value)
        setCombatCondition(combat.object, condition)
    end
end

local function find_combat(id)
    return combat_types[id] or false
end

function onUseWeapon(cid, var)
    local combat = find_combat(getCreatureStorage(cid, config.storage))

    if not combat then
        doCreatureSetStorage(cid, config.storage, 5)
    end

    return doCombat(cid, combat.object, var)
end
 
Solution
combat is returning false from the function find_combat(id), and in this case you are setting the creatureStorage to 5 but never calling or redefining combat which leaves it to false when it's getting called in doCombat

Lua:
function onUseWeapon(cid, var)
    local combat = find_combat(getCreatureStorage(cid, config.storage))
    if not combat then
        doCreatureSetStorage(cid, config.storage, 5)
        combat = find_combat(getCreatureStorage(cid, config.storage))
    end
    return doCombat(cid, combat.object, var)
end
combat is returning false from the function find_combat(id), and in this case you are setting the creatureStorage to 5 but never calling or redefining combat which leaves it to false when it's getting called in doCombat

Lua:
function onUseWeapon(cid, var)
    local combat = find_combat(getCreatureStorage(cid, config.storage))
    if not combat then
        doCreatureSetStorage(cid, config.storage, 5)
        combat = find_combat(getCreatureStorage(cid, config.storage))
    end
    return doCombat(cid, combat.object, var)
end
 
Last edited:
Solution
I think everyone is busy, They ignore the posts?
Best Support Ignore me I dont Know why? Look There V

 
I think everyone is busy, They ignore the posts?
Best Support Ignore me I dont Know why? Look There V

Using otx2
no wonder u not getting support :D
 
Back
Top