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

[Help] for Summons to instantly dissapear

canaan

New Member
Joined
Sep 21, 2008
Messages
53
Reaction score
0
Is there any possibility to make a summon die after some time (5 min or so)?
script:

Code:
function onCastSpell(cid, var) 
 
local playerpos = getPlayerPosition(cid) 
local health = getCreatureHealth(cid) 
local maxhealth = getCreatureMaxHealth(cid) 
local MaximoSummon = 2 
 
local summons = getCreatureSummons(cid) 
if(table.maxn(summons) < MaximoSummon) then 
local clone = doSummonCreature("Monster", getCreaturePosition(cid)) 
doConvinceCreature(cid, clone) 
setCreatureMaxHealth(clone, maxhealth) 
doCreatureAddHealth(clone, health) 
registerCreatureEvent(clone, "DieClone") 
 
local clone2 = doSummonCreature("Monster", getCreaturePosition(cid)) 
doConvinceCreature(cid, clone2) 
setCreatureMaxHealth(clone2, maxhealth) 
doCreatureAddHealth(clone2, health) 
registerCreatureEvent(clone2, "DieClone") 
return TRUE 
end 
end

rep + for helping
 
Last edited:
Try sumething like this:

Lua:
local summon = doSummonMonster(cid, "Name")
doConvinceCreature(cid, summon)
addEvent(doRemoveCreature, 5*60*1000, summon)
 
Lua:
local f = function(c)
	if isCreature(c) then
		doRemoveCreature(c)
	end
end

function onCastSpell(cid, var)
	local n, ret, a, b = #getCreatureSummons(cid)

	for i = 1, 2 - n do
		if not a then
			a, b = getCreatureHealth(cid), getCreatureMaxHealth(cid)
		end
		ret = doSummonMonster(cid, 'Monster')
		if ret == 1 then
			local s = getCreatureSummons(cid)
			s = s[n + i]
			setCreatureMaxHealth(s, b)
			doCreatureAddHealth(s, a)
			registerCreatureEvent(s, 'DieClone')
			addEvent(f, 5 * 60 * 1000, s)
		else
			doPlayerSendDefaultCancel(cid, ret)
			return i ~= 1
		end
	end

	return ret
end
 
Back
Top