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

addEvent onKill

zakius

Enter the Ninja!
Joined
Apr 30, 2009
Messages
2,635
Reaction score
65
Location
with Taiga
I want to summon some monsters 10 sec after you kill boss, I created this script but it doesn't work
Lua:
function onKill(cid, target)
	if getCreatureName(target) == "Drasith" then
		addEvent(addSkele, 10000)
	return TRUE
	end
end


function addSkele()
pos1={991, 1247, 7}
pos2={985, 1241, 7}
pos3={985, 1253, 7}
pos4={997, 1241, 7}
pos5={997, 1253, 7}
doCreateMonster(cid, "skeleton", pos1)
doCreateMonster(cid, "skeleton", pos2)
doCreateMonster(cid, "skeleton", pos3)
doCreateMonster(cid, "skeleton", pos4)
doCreateMonster(cid, "skeleton", pos5)
return TRUE
end
Can someone help mi with this? No errors in console,just no effect.
 
replace the fucntion with this

Lua:
function addSkele()
pos1={x = 991, y = 1247, z = 7}
pos2={x = 985, y = 1241, z = 7}
pos3={x = 985, y = 1253, z = 7}
pos4={x = 997, y = 1241, z = 7}
pos5={x = 997, y = 1253, z = 7}
doCreateMonster("skeleton", pos1)
doCreateMonster("skeleton", pos2)
doCreateMonster("skeleton", pos3)
doCreateMonster("skeleton", pos4)
doCreateMonster("skeleton", pos5)
return TRUE
end
 
replace the fucntion with this

Lua:
function addSkele()
pos1={x = 991, y = 1247, z = 7}
pos2={x = 985, y = 1241, z = 7}
pos3={x = 985, y = 1253, z = 7}
pos4={x = 997, y = 1241, z = 7}
pos5={x = 997, y = 1253, z = 7}
doCreateMonster("skeleton", pos1)
doCreateMonster("skeleton", pos2)
doCreateMonster("skeleton", pos3)
doCreateMonster("skeleton", pos4)
doCreateMonster("skeleton", pos5)
return TRUE
end

Better? :thumbup:
Lua:
function onKill(cid, target)
    if (getCreatureName(target) == "Drasith") then
        addEvent(addSkele, 10 * 1000)
    end
    return true
end
local function addSkele()
	local pos = { 
		{x = 991, y = 1247, z = 7},
		{x = 985, y = 1241, z = 7},
		{x = 985, y = 1253, z = 7},
		{x = 997, y = 1241, z = 7},
		{x = 997, y = 1253, z = 7}
	}
	local spawn = math.random(5, #pos)
	doCreateMonster("skeleton", #pos[spawn])
	return true
end
 
Last edited:
darkhaos: no effect when I use this one, but you are right, I forgot about position letters in pos
EDIT: ok, now it works, forgot to remove the cid things
JDB:
Code:
[01/11/2009 12:00:31] Lua Script Error: [CreatureScript Interface] 
[01/11/2009 12:00:31] data/creaturescripts/scripts/drasith.lua:onKill

[01/11/2009 12:00:31] luaAddEvent(). Callback parameter should be a function.
And I prefer the easier ones, that I understand how it works ;d
 
Better? :thumbup:
Lua:
function onKill(cid, target)
    if (getCreatureName(target) == "Drasith") then
        addEvent(addSkele, 10 * 1000, cid)
    end
    return true
end
local function addSkele(cid)
	local pos = { 
		{x = 991, y = 1247, z = 7},
		{x = 985, y = 1241, z = 7},
		{x = 985, y = 1253, z = 7},
		{x = 997, y = 1241, z = 7},
		{x = 997, y = 1253, z = 7}
	}
	local spawn = math.random(5, #pos)
	doCreateMonster("skeleton", #pos[spawn])
	return true
end

Just wondering why you gave a parameter cid there xD
 
Better? :thumbup:
Lua:
function onKill(cid, target)
    if (getCreatureName(target) == "Drasith") then
        addEvent(addSkele, 10 * 1000, cid)
    end
    return true
end
local function addSkele(cid)
	local pos = { 
		{x = 991, y = 1247, z = 7},
		{x = 985, y = 1241, z = 7},
		{x = 985, y = 1253, z = 7},
		{x = 997, y = 1241, z = 7},
		{x = 997, y = 1253, z = 7}
	}
	local spawn = math.random(5, #pos)
	doCreateMonster("skeleton", #pos[spawn])
	return true
end
What is the cid for? Also use for i = 1, #pos do
 
JDB: didn't tested urs again, I preffer scripts that I understand and can easy edit if I wand to add sth and the darkhaos' script is working.
 
Try this then :)
Lua:
--[[
	By zonet :)
]]--

local summonSec = 10 -- How many seconds they should be summoned after kill
function onKill(cid, target)
    if(getCreatureName(target) == "Drasith")then
            addEvent(createMonster, summonSec*1000)
		end
        return true
end

function createMonster()
local positions = {
    {x = 991, y = 1247, z = 7},
    {x = 985, y = 1241, z = 7},
    {x = 985, y = 1253, z = 7},
    {x = 997, y = 1241, z = 7},
    {x = 997, y = 1253, z = 7}
}
	for i = 1, 5 do
		doCreateMonster(cid, "skeleton", positions[i])
		end
	return true
end
 
Code:
function onKill(cid, target)
	local config = {
		secs = 5,
		positions = {
			{x = 991, y = 1247, z = 7},
			{x = 985, y = 1241, z = 7},
			{x = 985, y = 1253, z = 7},
			{x = 997, y = 1241, z = 7},
			{x = 997, y = 1253, z = 7}
		}
	}

	if(getCreatureName(target):lower == "drasith") then
		for i = 1, #config.positions do
			addEvent(doCreatureMonster, config.secs * 1000, "Skeleton", config.positions[i])
		end
	end
	return true
end
:eek:
 
Lua:
local config = {secs = 5, positions = {{x = 991, y = 1247, z = 7},{x = 985, y = 1241, z = 7},{x = 985, y = 1253, z = 7},{x = 997, y = 1241, z = 7},{x = 997, y = 1253, z = 7}}}
local function summon() for i = 1, #config.positions do doSummonCreature("Skeleton", config.positions[i]) end end
function onKill(cid, target) if(string.lower(getCreatureName(target)) == "drasith") then addEvent(summon, config.secs * 1000) end return true end
:S
 

Similar threads

Back
Top