• 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 Script spell don't work

Helliot1

Owner of Empire Online
Joined
Jul 26, 2017
Messages
315
Solutions
1
Reaction score
59
This spells have a Casting Time, and a Exhausted for this only spells,

But when I use it, don't work, I can use this spells on Casting Time, but don't works the Exhaust , what I'm doing wrong ?

Error
LUA:
input:1: attempt to call a nil value (global 'createCombatObject')

LUA:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, 21)
setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -1, -70, -1, -80, 5, 5, 1, 1)

local area1 = createCombatArea(AREA_INFERNO)
setCombatArea(combat1, area1)
local function onCastSpell1(parameters)
doCombat(parameters.cid, parameters.combat1, parameters.var)
    if exhaustion.check(cid, 23000) == false then
        exhaustion.set(cid,23000, 100)
        return doCombat(cid, combat, var)
    else
        doPlayerSendCancel(cid, "Cooldown[" ..exhaustion.get(cid,23000).."]")
    end
end
local function castingTime(cid)
end
local function castingStop(cid)
end
function onCastSpell(cid, var)
    local parameters = { cid = cid, var = var, combat1 = combat1 }
    local casttime = 4000
    local globaltime=(casttime)
  
    if (globaltime <= 0) then
    addEvent(castingStop, (50), cid)
    addEvent(onCastSpell1, (51), parameters)
  
    else
    addEvent(castingTime, 1, cid)
    addEvent(castingStop, (globaltime+50), cid)
    addEvent(onCastSpell1, (globaltime+51), parameters)
  
    end
    return true
end
 
This spells have a Casting Time, and a Exhausted for this only spells,

But when I use it, don't work, I can use this spells on Casting Time, but don't works the Exhaust , what I'm doing wrong ?

Error
LUA:
input:1: attempt to call a nil value (global 'createCombatObject')

LUA:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, 21)
setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -1, -70, -1, -80, 5, 5, 1, 1)

local area1 = createCombatArea(AREA_INFERNO)
setCombatArea(combat1, area1)
local function onCastSpell1(parameters)
doCombat(parameters.cid, parameters.combat1, parameters.var)
    if exhaustion.check(cid, 23000) == false then
        exhaustion.set(cid,23000, 100)
        return doCombat(cid, combat, var)
    else
        doPlayerSendCancel(cid, "Cooldown[" ..exhaustion.get(cid,23000).."]")
    end
end
local function castingTime(cid)
end
local function castingStop(cid)
end
function onCastSpell(cid, var)
    local parameters = { cid = cid, var = var, combat1 = combat1 }
    local casttime = 4000
    local globaltime=(casttime)
 
    if (globaltime <= 0) then
    addEvent(castingStop, (50), cid)
    addEvent(onCastSpell1, (51), parameters)
 
    else
    addEvent(castingTime, 1, cid)
    addEvent(castingStop, (globaltime+50), cid)
    addEvent(onCastSpell1, (globaltime+51), parameters)
 
    end
    return true
end

It's hard to tell what you're trying to achieve, maybe explain a little more what you want the spell to do. castingTime and castingStop are pointless and so is onCastSpell1 so basically all that's going on here is a spell that if exhausted sends that cancel message.
 
Not sure what you want to happen... maybe something similar to:
LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 21)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1, -70, -1, -80, 5, 5, 1, 1)
local area = createCombatArea(AREA_INFERNO)
setCombatArea(combat, area)

function onCastSpell(cid, var)
    if not exhaustion.check(cid, 23000) then
        return doCombat(cid, combat, var), exhaustion.set(cid, 23000, 100)
    end

    doPlayerSendCancel(cid, "Cooldown[" .. exhaustion.get(cid, 23000) .. "]")
    local duration = 4000 -- Delayed spell?
    return addEvent(
        function(cid, combat, var)
            return isPlayer(cid) and doCombat(cid, combat, var)
        end, duration, cid, combat, var
    )
end
 
It's hard to tell what you're trying to achieve, maybe explain a little more what you want the spell to do. castingTime and castingStop are pointless and so is onCastSpell1 so basically all that's going on here is a spell that if exhausted sends that cancel message.

Hello, thanks for attention,
this spell have a time to cast, example: 4 seconds, then when I use this spell, they will cast in 4 seconds. But they don't have a exhaust.

This is the script with the Casting Time(working):
LUA:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, 21)
setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -1, -70, -1, -80, 5, 5, 1, 1)

local area1 = createCombatArea(AREA_INFERNO)
setCombatArea(combat1, area1)
local function onCastSpell1(parameters)
doCombat(parameters.cid, parameters.combat1, parameters.var)
end
local function castingTime(cid)
end
local function castingStop(cid)
end
function onCastSpell(cid, var)
    local parameters = { cid = cid, var = var, combat1 = combat1 }
    local casttime = 4000
    local globaltime=(casttime)
  
    if (globaltime <= 0) then
    addEvent(castingStop, (50), cid)
    addEvent(onCastSpell1, (51), parameters)
  
    else
    addEvent(castingTime, 1, cid)
    addEvent(castingStop, (globaltime+50), cid)
    addEvent(onCastSpell1, (globaltime+51), parameters)
  
    end
    return true
end

And I need put a Exhaustion on this spell, because when I use this, in 1 second I can use again, and I need put a 4 seconds for Exhaustion.

I found this script to implement on my spell:
LUA:
function onCastSpell(cid, var)
    if exhaustion.check(cid, 23000) == false then
        exhaustion.set(cid,23000, 100)
        return doCombat(cid, combat, var)
    else
        doPlayerSendCancel(cid, "Cooldown[" ..exhaustion.get(cid,23000).."]")
    end
end

But when I implemented this script, my spell just Cast and don't have any exhaust.

Not sure what you want to happen... maybe something similar to:
LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 21)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1, -70, -1, -80, 5, 5, 1, 1)
local area = createCombatArea(AREA_INFERNO)
setCombatArea(combat, area)

function onCastSpell(cid, var)
    if not exhaustion.check(cid, 23000) then
        return doCombat(cid, combat, var), exhaustion.set(cid, 23000, 100)
    end

    doPlayerSendCancel(cid, "Cooldown[" .. exhaustion.get(cid, 23000) .. "]")
    local duration = 4000 -- Delayed spell?
    return addEvent(
        function(cid, combat, var)
            return isPlayer(cid) and doCombat(cid, combat, var)
        end, duration, cid, combat, var
    )
end

This don't work Bro :(
 
The magic has to have a dead time of 4 seconds and then after the 4 se onda pasess?

In spells.XML ( cooldown option and cooldowngroup ) you no have script for time exauste :/
 
Since no one pointed it out;

In line 12 in your first script, you're getting that error because:

return doCombat(cid, combat, var)

combat doesn't exist.

combat1 does tho.

I think <3, not my strong suit spells.
 
The magic has to have a dead time of 4 seconds and then after the 4 se onda pasess?

In spells.XML ( cooldown option and cooldowngroup ) you no have script for time exauste :/

Yes, I'll use the spell, and will have a 4 seconds to cast, and more 4 seconds to cooldown.

in spells.XML have cooldown and cooldown group. But if I put it, I don't can use others spells, I only need exhaust in a unique spell
 
Yes, I'll use the spell, and will have a 4 seconds to cast, and more 4 seconds to cooldown.

in spells.XML have cooldown and cooldown group. But if I put it, I don't can use others spells, I only need exhaust in a unique spell

I will go to my house in the afternoon, and I will help you when you are using my lapto there I have what you need.
 
Thanks Sarah!!
LUA:
-- example with unique time spell
local storage_time_spell = 50500 -- example storage
local spell_exaust_time = 4 -- in seconds
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ENERGYAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)

function onCastSpell(cid, var)
if getPlayerStorageValue(cid, storage_time_spell) <= os.time() then
setPlayerStorageValue(cid, storage_time_spell, os.time() + spell_exaust_time)
return doCombat(cid, combat, var)
end
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, 'Sorry, not posible.')
end
 
Back
Top