• 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 Help with Custom Script for Monster

yohanaugusto

New Member
Joined
Sep 28, 2008
Messages
73
Reaction score
0
I've made this script:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ENERGYHIT)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGYBALL)

local area = createCombatArea(AREA_CIRCLE3X3)
combat:setArea(area)

function onGetFormulaValues(player, level, maglevel)
min = -1000
max = -5000
return min, max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCreatureSay(cid, speak, talktype, text)
local MonsterText= "msg to active spell"

if (text == MonsterText) then
addEvent(useSpell, 4000)
end
end

function useSpell(cid)
local creature = Creature(cid)
if getCreatureTarget(cid) ~= 0 then
doCreatureSay(cid, "Using Spell", TALKTYPE_ORANGE_2)
return combat:execute(creature:getPosition(creature:getTarget(cid)))
end
end

But it's not working, I've tried several times. I had this script before, but i lost it when I changed computer.

The erro is: "Attempt to index local 'creature' (a nil value)
 
local creature = Creature(cid)
it doesn't know what Creature is.
 
I tried

function useSpell(cid, creature)
local creature = creature:getMonster()
if getCreatureTarget(cid) ~= 0 then
doCreatureSay(cid, "Using Spell", TALKTYPE_ORANGE_2)
return combat:execute(creature:getPosition())
end
end

But it's not working :/
 
You need to add cid in the addEvent line.
Code:
addEvent(useSpell, 4000, cid)
Or if it's userdata cid.uid.
 
Back
Top