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

Make this spell execute several times?

murilow1

Member
Joined
Dec 2, 2011
Messages
37
Reaction score
9
PHP:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 14)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
 
function onCastSpell(cid, var)
	if isInParty(cid) then
		local lid = getPartyLeader(cid)
		local pm = getPartyMembers(lid)
		local lvl = getPlayerLevel(cid)
		local mlvl = getPlayerMagLevel(cid)
		for i = 1, #pm do
			doCreatureAddHealth(pm[i],math.random(50, 100))
            doCombat(pm[i], combat, var)
			doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(pm[i]), 30)
			doSendMagicEffect(getCreaturePosition(pm[i]), 14)
		end
	else
		return false,doPlayerSendCancel(cid, "You need to be in a party to cast this spell.")
	end
	return doCombat(cid, combat, var)
end

For example, i want to do this spell keep healing 'x' times...
How?

Thanks
 
the fastest solution if you need the spell to heal repeated times as you want
copy this code '
Lua:
 doCreatureAddHealth(pm[i],math.random(50, 100))
many times
so it will heal and heal and heal,,,,
 
try
Code:
local delay = 2000 -- each 2 seconds will heal


local combat = createCombatObject() 
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING) 
setCombatParam(combat, COMBAT_PARAM_EFFECT, 14) 
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE) 
  
function healParty(cid, times)
    if isCreature(cid) and isInParty(cid) then
        for i, pid in ipairs(getPartyMembers(cid)) do
            doCombat(pid, combat, var)
            doCreatureAddHealth(pid, math.random(50, 100), 14, 18)
            doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(pid), 30) 
        end
        return times > 0 and addEvent(healParty, delay, cid, times-1)
    end
end


function onCastSpell(cid, var) 


    if not isInParty(cid) then 
        return false, doPlayerSendCancel(cid, "You need to be in a party to cast this spell.") 
    end 


    return true, healParty(cid, 10)
end

will heal 10 times each 2 sec
Lua:
healParty(cid, 10)
 
try
Code:
local delay = 2000 -- each 2 seconds will heal


local combat = createCombatObject() 
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING) 
setCombatParam(combat, COMBAT_PARAM_EFFECT, 14) 
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE) 
  
function healParty(cid, times)
    if isCreature(cid) and isInParty(cid) then
        for i, pid in ipairs(getPartyMembers(cid)) do
            doCombat(pid, combat, var)
            doCreatureAddHealth(pid, math.random(50, 100), 14, 18)
            doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(pid), 30) 
        end
        return times > 0 and addEvent(healParty, delay, cid, times-1)
    end
end


function onCastSpell(cid, var) 


    if not isInParty(cid) then 
        return false, doPlayerSendCancel(cid, "You need to be in a party to cast this spell.") 
    end 


    return true, healParty(cid, 10)
end

will heal 10 times each 2 sec
Lua:
healParty(cid, 10)

hey thanks, but still giving error


attempt to index a nil value
in 'doCombat'
in function 'healParty'
 
Lua:
local delay = 2000 -- each 2 seconds will heal


local combat = createCombatObject() 
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING) 
setCombatParam(combat, COMBAT_PARAM_EFFECT, 14) 
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE) 
  
function healParty(cid, times)
    if isCreature(cid) and isInParty(cid) then
        for i, pid in ipairs(getPartyMembers(cid)) do
            doCombat(pid, combat, var)
            doCreatureAddHealth(pid, math.random(50, 100), 14, 18)
            doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(pid), 30) 
        end
        return times > 0 and addEvent(healParty, delay, cid, times-1)
    end
end


function onCastSpell(cid, var) 


    if not isInParty(cid) then 
        return false, doPlayerSendCancel(cid, "You need to be in a party to cast this spell.") 
    end 
    healParty(cid, 10)

    return doCombat(cid, combat, var)
end
 
Back
Top