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

Solved How to put 'pause' in lua spell?

morp164

New Member
Joined
Jul 13, 2010
Messages
44
Reaction score
0
Hello fellow users.

I'd like to ask if someone knows how to put something like exhaustion between 'two' spells .

There is a spell code and on the end is function :

Code:
function onCastSpell(cid, var)
    doCombat(cid, combat, var)
    doCombat(cid, combat2, var)
end

I'd like to do something like : first spell goes on , then there is a pause for like 0,25 sec and then next spell will go.

something like :
Code:
function onCastSpell(cid, var)
    doCombat(cid, combat, var)
    pause(seconds)
    doCombat(cid, combat2, var)
end

I cant find anywhere the pause function.
 
Try this


Code:
local storageValue = 3005

function repeatEffect(cid, effect, delay)
if getPlayerStorageValue(cid, storageValue) == TRUE then
doSendMagicEffect(getPlayerPosition(cid), effect)
addEvent(repeatEffect, delay, cid, effect, delay)
end
end

function onCastSpell(cid, var)
doCombat(cid, combat, var)
repeatEffect(cid, 5, 1000)
doCombat(cid, combat2, var)
end
 
You can use addEvent
Code:
addEvent(doCombat, 250, cid, combat2, var)

The function addEvent executes a function after a certain time.
First parameter is the function, second parameter the time in milliseconds and the rest are the parameters of the function you added in addEvent.
 
Thank you all

So I ended with this :
Code:
function onCastSpell(cid, var)
    addEvent(doCombat, 0, cid, combat, var)
    addEvent(doCombat, 500, cid, combat2, var)
end

Which works perfectly , but it doesn't show the spell's words during casting the spell. For example when you are using exevo flam hur , the character is saying above his head "exevo flam hur" .
I've found that it shows it when the function is ending with 'return'
for example :

Code:
function onCastSpell(cid, var)
   return  addEvent(doCombat, 0, cid, combat, var)
end
Then it displays the words above character's head.

How to put return for more than 1 events in lua function?

I know It can't be like :
return addEvent(doCombat, 0, cid, combat, var)
return addEvent(doCombat, 0, cid, combat, var)
because it would only execute the first line and then will close the function.
 
Hey guys , got one more problem. I need something that whole spell (all the combats) will cast from the position it starts casting. Now it works only if you stay and use spell , but when you constantly run and use the spell , it is going crazy , like it is casting every each combat from new position. I hope you understand . Waiting for your gold respondies :3
 
The script consists of 8 combats , so it is long, also all the combats are similiar so posting the whole thing is pointless.

I think there's the problem:
Code:
function onCastSpell(cid, var)
    addEvent(doCombat, 0, cid, combat1, var)
    addEvent(doCombat, 50, cid, combat2, var)
    addEvent(doCombat, 100, cid, combat3, var)
    addEvent(doCombat, 150, cid, combat4, var)
    addEvent(doCombat, 200, cid, combat5, var)
    addEvent(doCombat, 250, cid, combat6, var)
    addEvent(doCombat, 300, cid, combat7, var)
    addEvent(doCombat, 350, cid, combat8, var)
    return true
end

What's cid?
Im looking for the position from where it is casted from.
And then im gonna do something like this :

Code:
function onCastSpell(cid, var)
cid = cookie // a stable variable , which knows where the cast begins
    addEvent(doCombat, 0, cookie, combat1, var)
    addEvent(doCombat, 50, cookie, combat2, var)
    addEvent(doCombat, 100, cookie, combat3, var)
    addEvent(doCombat, 150, cookie, combat4, var)
    addEvent(doCombat, 200, cookie, combat5, var)
    addEvent(doCombat, 250, cookie, combat6, var)
    addEvent(doCombat, 300, cookie, combat7, var)
    addEvent(doCombat, 350, cookie, combat8, var)
    return true
end
I tried it but it worked strange .
But im not sure where is variable responsible for position from where combat will cast.
What is var?
Is there even a thing which is describing the position from where is combat casting in this function 'addevent'?
 
Var is like the target, on what it casts the spell. You can for example get the creatureid of the target with getTopCreature(variantToPosition(var)).uid or variantToNumber(var).
What you can do is add the doCombat functions in different Lua made functions in the script and call/add those Lua made functions in the addEvent.
 
I want that the every combats will cast from first position where player casted spell. When he run , his position is changing and spell is going crazy
 
Back
Top