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

TFS 1.X+ problem with spell script

darknelson

Member
Joined
Jun 19, 2011
Messages
190
Solutions
1
Reaction score
15
im trying to do a spell for my god player who can one shot kill every monster in game for test boss etc, this is the script i make

Lua:
local combat = Combat()
local player = creature:getPlayer()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 4.3) + 32
    local max = (level / 5) + (maglevel * 7.4) + 48
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, var, isHotkey)
    if Player:getAccountType() == ACCOUNT_TYPE_GOD then
    return combat:execute(creature, var)
end
end

but it simply doest not return any error it just says the spell name and nothing else more :( what can be?[/CODE]
 
Solution
Impossible that there isn't an error, using Player would give you an error (attempt to call nil value), the local player variable you have outside of the onCastSpell function would also error.
Use creature:getAccountType() instead, or make the spell requirement higher than the max level so only gods can cast it & see it in spellbooks.
Impossible that there isn't an error, using Player would give you an error (attempt to call nil value), the local player variable you have outside of the onCastSpell function would also error.
Use creature:getAccountType() instead, or make the spell requirement higher than the max level so only gods can cast it & see it in spellbooks.
 
Solution
spellkill.lua
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 1)
combat:setFormula(COMBAT_FORMULA_LEVELMAGIC, -999999, 1, -999999, 1)

function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end
in spells.xml put
Code:
needlearn="1"
only the gm will use, if other players dont learn this spell
Impossible that there isn't an error, using Player would give you an error (attempt to call nil value), the local player variable you have outside of the onCastSpell function would also error.
Use creature:getAccountType() instead, or make the spell requirement higher than the max level so only gods can cast it & see it in spellbooks.
 
Back
Top