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

Lever Script that spawns monster[I used search]

pwner123

New Member
Joined
Jul 1, 2009
Messages
211
Reaction score
1
Hello, could anyone help me make a lever script that when the lever is pulled it spawns a monster/monsters of the same kind? Like for example a demon lever, when pulled it asks how many demons you would like spawned and you could choose between 1 and 10, then the demons are spawned within an area. Rep++ to anyone who can help :)
 
I made something similar to what you want, I only used a blackboard instead of a lever, because you can't write on/talk to a lever. So maybe this is usefull too.
creaturescripts.xml
XML:
<event type="textedit" name="Demons" event="script" value="demons.lua"/>

Add this to login.lua
Lua:
registerCreatureEvent(cid, "Demons")

demons.lua
Lua:
function onTextEdit(cid, item, newText)
 
	if item.uid == 15000 and item.itemid == 1811 then -- add the unique id in the blackboard
		if tonumber(newText) <= 10 then
			for i = 1, tonumber(newText) do
			local pos = {x= math.random(94, 100), y= math.random(114, 120), z=7} -- edit here the locations from the area they spawn in
				doSummonCreature("Demon", pos)
			end
			doPlayerSendTextMessage(cid, 22, ""..newText.." demons spawned.")
		else 
			doPlayerSendTextMessage(cid, 22, "You can only choose between 1 and 10.")
		end
	end
	return true
end

You can write the number of demons you want on the blackboard and they will spawn in the area from local pos.
Btw, if you only want to use a lever, tell me the idea you had about how a player can choose a number while using a lever.
 
Last edited:
up@ , it's not a lever , limos made a blackboard , so you write on it the number of monsters that you want to spawn , and it will summon demons as you wrote on the blackboard.

so you should have a blackboard with id: 1811


and uniqueid: 15000 on the blackboard which itemid: 1811

example: if i want to summon 5 demons?
i press on that blackboard with uid and itemid , and i write on it 5 then press ok , the demons will spawn <3
----
a few edit of limo's script so people who need other blackboard or other uid and don't know how , change it easier:

Lua:
local uniqueid = 15000 -- put this uniqueid on the blackboard using map editor.
local itemid = 1811 -- the item id of blackboard
local monster = demon
local msg = "demons spawned."

function onTextEdit(cid, item, newText)
 
	if item.uid == uniqueid and item.itemid == itemid then -- add the unique id in the blackboard
		if tonumber(newText) <= 10 then
			for i = 1, tonumber(newText) do
			local pos = {x= math.random(94, 100), y= math.random(114, 120), z=7} -- edit here the locations from the area they spawn in
				doSummonCreature("monster", pos)
			end
			doPlayerSendTextMessage(cid, 22, ""..newText..msg)
		else 
			doPlayerSendTextMessage(cid, 22, "You can only choose between 1 and 10.")
		end
	end
	return true
end
 
Last edited:
You can do it like this, add the monsters you want in the local monsters table and then write for example: demon, 2. If you don't add a number it will summen 1.
Lua:
local monsters = {"demon", "fury"}
function onTextEdit(cid, item, newText)
 
	if item.uid == 15000 and item.itemid == 1811 then -- add the unique id in the blackboard
		local t = {}
		if(newText ~= '') then
			t = string.explode(newText, ",")
		end
		local n = tonumber(t[2])
		if(not n) then
			n = 1
		end
		if isInArray(monsters, t[1]) then
			if n <= 10 and n >= 1 then
				for i = 1, n do
				        local pos = {x= math.random(94, 100), y= math.random(114, 120), z=7} -- edit here the locations from the area they spawn in
					doSummonCreature(t[1], pos)
				end
				doPlayerSendTextMessage(cid, 25, n.." "..(n > 1 and ""..t[1].."s" or t[1]).." spawned.")
			else 
				doPlayerSendTextMessage(cid, 22, "You can only choose between 1 and 10.")
			end
		else
			local text = "Monsters you can choose"
			for _, x in pairs(monsters) do
				text = text .."\n"..x.. ""
			end
			doPlayerSendTextMessage(cid, 27, text.."\nExample: monstername, 2")
		end
	end
	return true
end
 
Last edited:
I was working on it last night with him, We got the demons one but he wanted to make another blackboard for Furys or Nightmares, but when we tried the same thing as the demons, replacing the name with furys it didn't work... D:

EDIT: We will try both of those.
 
Last edited:
Back
Top