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

Kill x monster in x area

Status
Not open for further replies.

Amiroslo

Excellent OT User
Joined
Jul 28, 2009
Messages
6,768
Solutions
5
Reaction score
769
Hello,
Im looking for a script where you have to kill x monster before you can enter the door. if you try to enter the door it says please kill the monsters in room.

Rep++
 
Lua:
local z = 7
for x = 664, 690 do  --left X, right X
	for y = 800, 825 do  --left Y, right Y
			local v = getTopCreature({x=x, y=y, z=z}).uid
			if isMonster(v) then
				return false
			end
	end
end
 
creaturescripts
Lua:
local config = {
{["name"] = "Boss", ["storage"] = 5560},
}
function onKill(cid, target, lastHit)
	if(isPlayer(target) ~= TRUE) then
		for i = 1, #config do
			if getCreatureName(target):lower() == config[i].name:lower() then
				if getPlayerStorageValue(cid, config[i].storage) < 1 then
					setPlayerStorageValue(cid, config[i].storage, 2)
				end
			end
		end
	end
	return true
end
actions
Lua:
local config = {
[50060] = {5560}, -- uid, storage
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = config[item.uid]
	if v[1] < 1 then
		return doPlayerSendCancel(cid, "Please kill monster in room fist.")
	end
return true
end
 
I have 4 rooms, in each room there are 2 bosses. I want so he needs to kill the first 2 then a tp shows for 3sec and then he tps to the second room. there are also 2 bosses. he needs to do the same and when both gets killed, another tp opens to the 3room for 3sec and same for the last room. in the last room if he kills the last 2 bosses a tp shows for 5sec and he gets tp to prize room.

rep
 
Lua:
local c = {
	boss = { -- Boss Name, ttp = position for the new room, tp = position where you want it to appear Teleport, time = time after which disappears teleport, bro = the second boss to kill in this room
-- 1 room
		["Boss1 Name"]	= {ttp={x = 1111, y = 1111, z = 11},	tp={x = 1111, y = 1111, z = 11, stackpos=1},	time = 3,	bro = "Boss2 Name"},
		["Boss2 Name"]	= {ttp={x = 1111, y = 1111, z = 11},	tp={x = 1111, y = 1111, z = 11, stackpos=1},	time = 3,	bro = "Boss1 Name"},
-- 2 room
		["Boss3 Name"]	= {ttp={x = 2222, y = 1111, z = 11},	tp={x = 1111, y = 1111, z = 11, stackpos=1},	time = 3,	bro = "Boss4 Name"},
		["Boss4 Name"]	= {ttp={x = 2222, y = 1111, z = 11},	tp={x = 1111, y = 1111, z = 11, stackpos=1},	time = 3,	bro = "Boss3 Name"},
-- 3 room
		["Boss5 Name"]	= {ttp={x = 3333, y = 1111, z = 11},	tp={x = 1111, y = 1111, z = 11, stackpos=1},	time = 3,	bro = "Boss6 Name"},
		["Boss6 Name"]	= {ttp={x = 3333, y = 1111, z = 11},	tp={x = 1111, y = 1111, z = 11, stackpos=1},	time = 3,	bro = "Boss5 Name"},
-- 4 room
		["Boss7 Name"]	= {ttp={x = 4444, y = 1111, z = 11},	tp={x = 1111, y = 1111, z = 11, stackpos=1},	time = 5,	bro = "Boss8 Name"},
		["Boss8 Name"]	= {ttp={x = 4444, y = 1111, z = 11},	tp={x = 1111, y = 1111, z = 11, stackpos=1},	time = 5,	bro = "Boss7 Name"}
	}
}
function onKill(cid, target, lastHit)
	local k = c.boss[getCreatureName(target)]
	if(not isPlayer(target)) and isPlayer(cid) and k and not(getCreatureMaster(target)) then
		if(k.bro) then
			local bro = getCreatureByName(k.bro)
			if isMonster(bro) and getDistanceBetween(getThingPosition(cid), getThingPosition(bro)) < 12 then -- 
				return true
			end
		end
		doCreateTeleport(1387, k.ttp, k.tp)
		doCreatureSay(cid, "You now have ".. k.time .."sek  to exit this room through the teleporter. It will bring you to the next room only during his time or the teleporter will disappear", TALKTYPE_MONSTER_SAY)
		addEvent(function()
			local itek = getTileItemById(k.tp, 1387)
			if itek.uid > 0 then
				doRemoveItem(itek.uid, 1)
			end
		end, k.time*1000, k.tp)
	end
	return true
end
moore clear

------------- edit
"I want it, if u kill boss 1 and 2, a tp shows. not u kill 1 then tp shows and u kill 2 then tp shows. no, 2 boss in 1 room. both get killed then tp shows."

exactly as it is
 
Last edited:
I have 4 rooms, in each room there are 2 bosses. I want so he needs to kill the first 2 then a tp shows for 3sec and then he tps to the second room. there are also 2 bosses. he needs to do the same and when both gets killed, another tp opens to the 3room for 3sec and same for the last room. in the last room if he kills the last 2 bosses a tp shows for 5sec and he gets tp to prize room

:D
--
it's easy
unless you did not think you need a script for that on 5 pages? ;)
 
Last edited:
How does this script know if there is no monster in this room any more?
You didn't set up xyz top left and xyz bottom right to check? I'm just curious tho, Cuz I'm not understanding how it checks if it's dead or not ;p
 
<event type="kill" name="BossKill" event="script" value="bosskill.lua"/>

bosskill.lua
function onKill(cid, target, damage, flags)
local killstorage = "25909"
local name = getCreatureName(target):lower()

if isPlayer(target) then return true end
if name == 'testboss' then
doCreatureSay(cid, 'You have defeated the ' .. name .. '. You may continue exploring now.', TALKTYPE_ORANGE_1)
if(getCreatureStorage(cid, killstorage) < 1) then
doCreatureSetStorage(cid, killstorage, 1)
end
end
return true
end

login.lua:
registerCreatureEvent(cid, "BossKill")
 
Lua:
local bro = getCreatureByName(k.bro)
if isMonster(bro) and getDistanceBetween(getThingPosition(cid), getThingPosition(bro)) < 12 then -- 
	return true
end
if you do not understand, then test it..

and what does it mean by your description?
amiroslo
Lua Scripter + Mapper
;)
 
Yes I'm a lua scripter, but last time I scripted was long time ago. I need to start scripting again I guess ;p + I'm not an advanced scripter tho
 
good luck

- - - Updated - - -

"I Have boss 1 and boss 2 same name"
in this case:
Lua:
local c = {
	boss = { -- Boss Name, ttp = position for the new room, tp = position where you want it to appear Teleport, time = time after which disappears teleport
-- 1 room with crature with name "Boss1 Name"
		["Boss1 Name"] = {ttp={x = 1111, y = 1111, z = 11},	tp={x = 1111, y = 1111, z = 11, stackpos=1}, time = 3},
-- 2 room with crature with name "Boss2 Name"
		["Boss2 Name"] = {ttp={x = 2222, y = 1111, z = 11},	tp={x = 1111, y = 1111, z = 11, stackpos=1}, time = 3},
-- 3 room with crature with name "Boss3 Name"
		["Boss3 Name"] = {ttp={x = 3333, y = 1111, z = 11},	tp={x = 1111, y = 1111, z = 11, stackpos=1}, time = 3},
-- 4 room with crature with name "Boss4 Name"
		["Boss4 Name"] = {ttp={x = 4444, y = 1111, z = 11},	tp={x = 1111, y = 1111, z = 11, stackpos=1}, time = 5},
	}
}
function onKill(cid, target, lastHit)
	local k = c.boss[getCreatureName(target)]
	if(not isPlayer(target)) and isPlayer(cid) and k and not(getCreatureMaster(target)) then

		for _, pid in ipairs(getSpectators(getThingPosition(cid), 10, 10, false)) do -- room 10x10 tile ???
			if not isPlayer(pid) and getCreatureName(pid) == getCreatureName(target) then
				return true
			end
		end

		doCreateTeleport(1387, k.ttp, k.tp)
		doCreatureSay(cid, "You now have ".. k.time .."sek  to exit this room through the teleporter. It will bring you to the next room only during his time or the teleporter will disappear", TALKTYPE_MONSTER_SAY)
		addEvent(function()
			local itek = getTileItemById(k.tp, 1387)
			if itek.uid > 0 then
				doRemoveItem(itek.uid, 1)
			end
		end, k.time*1000, k.tp)
	end
	return true
end
 
Lua:
local c = {
	boss = { -- Boss Name, ttp = position for the new room, tp = position where you want it to appear Teleport, time = time after which disappears teleport, bro = the second boss to kill in this room
-- 1 room
		["Boss1 Name"]	= {ttp={x = 1111, y = 1111, z = 11},	tp={x = 1111, y = 1111, z = 11, stackpos=1},	time = 3,	bro = "Boss2 Name"},
		["Boss2 Name"]	= {ttp={x = 1111, y = 1111, z = 11},	tp={x = 1111, y = 1111, z = 11, stackpos=1},	time = 3,	bro = "Boss1 Name"},
-- 2 room
		["Boss3 Name"]	= {ttp={x = 2222, y = 1111, z = 11},	tp={x = 1111, y = 1111, z = 11, stackpos=1},	time = 3,	bro = "Boss4 Name"},
		["Boss4 Name"]	= {ttp={x = 2222, y = 1111, z = 11},	tp={x = 1111, y = 1111, z = 11, stackpos=1},	time = 3,	bro = "Boss3 Name"},
-- 3 room
		["Boss5 Name"]	= {ttp={x = 3333, y = 1111, z = 11},	tp={x = 1111, y = 1111, z = 11, stackpos=1},	time = 3,	bro = "Boss6 Name"},
		["Boss6 Name"]	= {ttp={x = 3333, y = 1111, z = 11},	tp={x = 1111, y = 1111, z = 11, stackpos=1},	time = 3,	bro = "Boss5 Name"},
-- 4 room
		["Boss7 Name"]	= {ttp={x = 4444, y = 1111, z = 11},	tp={x = 1111, y = 1111, z = 11, stackpos=1},	time = 5,	bro = "Boss8 Name"},
		["Boss8 Name"]	= {ttp={x = 4444, y = 1111, z = 11},	tp={x = 1111, y = 1111, z = 11, stackpos=1},	time = 5,	bro = "Boss7 Name"}
	}
}
function onKill(cid, target, lastHit)
	local k = c.boss[getCreatureName(target)]
	if(not isPlayer(target)) and isPlayer(cid) and k and not(getCreatureMaster(target)) then
		if(k.bro) then
			local bro = getCreatureByName(k.bro)
			if isMonster(bro) and getDistanceBetween(getThingPosition(cid), getThingPosition(bro)) < 12 then -- 
				return true
			end
		end
		doCreateTeleport(1387, k.ttp, k.tp)
		doCreatureSay(cid, "You now have ".. k.time .."sek  to exit this room through the teleporter. It will bring you to the next room only during his time or the teleporter will disappear", TALKTYPE_MONSTER_SAY)
		addEvent(function()
			local itek = getTileItemById(k.tp, 1387)
			if itek.uid > 0 then
				doRemoveItem(itek.uid, 1)
			end
		end, k.time*1000, k.tp)
	end
	return true
end
moore clear

------------- edit
"I want it, if u kill boss 1 and 2, a tp shows. not u kill 1 then tp shows and u kill 2 then tp shows. no, 2 boss in 1 room. both get killed then tp shows."

exactly as it is
when i kill both bosses at same time or if i only kill one, my tibia debugs and closes. lol
I Have boss 1 and boss 2 same name
 
Lua:
local c = {
	boss = { -- Boss Name, ttp = position for the new room, tp = position where you want it to appear Teleport, time = time after which disappears teleport
-- 1 room with crature with name "Boss1 Name"
		["Evil Eye"] = {ttp={x = 1592, y = 1908, z = 6},	tp={x = 1592, y = 1914, z = 7, stackpos=1}, time = 4},
-- 2 room with crature with name "Boss2 Name"
		["Boss2 Name"] = {ttp={x = 2222, y = 1111, z = 11},	tp={x = 1111, y = 1111, z = 11, stackpos=1}, time = 3},
-- 3 room with crature with name "Boss3 Name"
		["Boss3 Name"] = {ttp={x = 3333, y = 1111, z = 11},	tp={x = 1111, y = 1111, z = 11, stackpos=1}, time = 3},
-- 4 room with crature with name "Boss4 Name"
		["Boss4 Name"] = {ttp={x = 4444, y = 1111, z = 11},	tp={x = 1111, y = 1111, z = 11, stackpos=1}, time = 5},
	}
}
function onKill(cid, target, lastHit)
	local k = c.boss[getCreatureName(target)]
	if(not isPlayer(target)) and isPlayer(cid) and k and not(getCreatureMaster(target)) then
 
		for _, pid in ipairs(getSpectators(getThingPosition(cid), 5, 5, false)) do -- room 10x10 tile ???
			if not isPlayer(pid) and getCreatureName(pid) == getCreatureName(target) then
				return true
			end
		end
 
		doCreateTeleport(1387, k.ttp, k.tp)
		doCreatureSay(cid, "You now have ".. k.time .."sec  to exit this room through the teleporter. It will bring you to the next room only during his time or the teleporter will disappear", TALKTYPE_MONSTER_SAY)
		addEvent(function()
			local itek = getTileItemById(k.tp, 1387)
			if itek.uid > 0 then
				doRemoveItem(itek.uid, 1)
			end
		end, k.time*1000, k.tp)
	end
	return true
end
 
if not isPlayer(pid) and getCreatureName(pid) == getCreatureName(target) then
->
if not isPlayer(pid) and getCreatureName(pid) == getCreatureName(target) and pid ~= target then

now tested :)

-- edit
doch
Lua:
		for _, pid in ipairs(getSpectators(getThingPosition(cid), 6, 6, false)) do -- room 10x10 tile ???
			if isMonster(pid) and (getCreatureName(pid):lower()) == (getCreatureName(target):lower()) and pid ~= target then
				doCreatureSay(cid, "bedzie return true ".. getCreatureName(pid) ..", ".. getCreatureName(target) .."", TALKTYPE_MONSTER_SAY)
				return true
			end
		end

-- edit
you're a developer, try think :p
 
Last edited:
nothing, no errors, no tp nothing

- - - Updated - - -

edit:
still nothing happens
 
Status
Not open for further replies.
Back
Top