• 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 Spell Error in gui

Dexftw

Total Boss
Joined
Jan 30, 2011
Messages
317
Reaction score
8
Code:
[01/02/2011 12:12:50] Lua Script Error: [Test Interface] 
[01/02/2011 12:12:50] data/spells/scripts/spells87/Ultimateicestrike.lua
[01/02/2011 12:12:50] data/spells/scripts/spells87/Ultimateicestrike.lua:5: attempt to call global 'setAttackFormula' (a nil value)
[01/02/2011 12:12:50] stack traceback:
[01/02/2011 12:12:50] 	[C]: in function 'setAttackFormula'
[01/02/2011 12:12:50] 	data/spells/scripts/spells87/Ultimateicestrike.lua:5: in main chunk
[01/02/2011 12:12:50] Warning: [Event::checkScript] Can not load script. /scripts/spells87/Ultimateicestrike.lua
<-- in gui

code for spell is
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
setAttackFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 5, 5, 5, 14)

function onCastSpell(cid, var)
	local storage = 23026
	local spellname = "Ultimate Ice Strike"
	local time = 30

        if exhaustion.check(cid, storage) == false then
                exhaustion.set(cid, storage, time)
                return doCombat(cid, combat, var) and doCombat(cid, combat, var)
        else
                doPlayerSendCancel(cid, "You are exhausted in " .. spellname .. " for: " ..exhaustion.get(cid, storage).." segundos.")
        end
end
the lua spell code
 
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
function onGetFormulaValues(cid, level, maglevel)
	local min = level / 5 + maglevel * 5
	local max = level / 5 + maglevel * 14
	return -min, -max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, 'onGetFormulaValues')

function onCastSpell(cid, var)
	local storage = 23026
	local spellname = 'Ultimate Ice Strike'
	local time = 30

	if exhaustion.check(cid, storage) == false then
		exhaustion.set(cid, storage, time)
		return doCombat(cid, combat, var) and doCombat(cid, combat, var)
	else
		doPlayerSendCancel(cid, 'You are exhausted in ' .. spellname .. ' for: ' ..exhaustion.get(cid, storage)..' seconds.')
	end
end
Add to global.lua:
Lua:
exhaustion =
{
	check = function (cid, storage)
		if(getPlayerFlagValue(cid, PlayerFlag_HasNoExhaustion)) then
			return false
		end

		return getPlayerStorageValue(cid, storage) >= os.time(t)
	end,

	get = function (cid, storage)
		if(getPlayerFlagValue(cid, PlayerFlag_HasNoExhaustion)) then
			return false
		end

		local exhaust = getPlayerStorageValue(cid, storage)
		if(exhaust > 0) then
			local left = exhaust - os.time(t)
			if(left >= 0) then
				return left
			end
		end

		return false
	end,

	set = function (cid, storage, time)
		setPlayerStorageValue(cid, storage, os.time(t) + time)
	end,

	make = function (cid, storage, time)
		local exhaust = exhaustion.get(cid, storage)
		if(not exhaust) then
			exhaustion.set(cid, storage, time)
			return true
		end

		return false
	end
}
You should use the built-in cooldown system instead, though.
 
Back
Top