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

[Action] Pull Lever Spawn Monster

xx Kami xx

Retired.
Joined
Dec 29, 2012
Messages
509
Reaction score
20
Hello and im looking for a simple script so when you use a lever it spawn's a monster outside the pz area where the lever is pulled i found a script but it isnt the 1 i need maybe someone can mix it around and make it like the script i need?

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:
local config = {
	["1"] = {n = 1},
	["2"] = {n = 2},
	["3"] = {n = 3},
	["4"] = {n = 4},
	["5"] = {n = 5},
	["6"] = {n = 6},
	["7"] = {n = 7},
	["8"] = {n = 8},
	["9"] = {n = 9},
	["10"] = {n = 10}
}

function onTextEdit(cid, item, newText)

	if item.uid == 15000 and item.itemid == 1811 then -- add the unique id in the blackboard
	local x = config[newText]
		if x then
			for i = 1, x.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("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.


Will Rep++ :cool:
 
Then how do you want it? without choosing, 1 monster with same amount? different monsters, different amount?

@Your pm

If you want to just let it spawn 1 monster just only use doSummonCreature("Ferumbras", {x= 100, y= 120, z= 7}), to make it an action just use function onUse(cid, item, fromPosition, itemEx, toPosition) and end to close the function
So that will be like this:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)

	doSummonCreature("Ferumbras", {x= 100, y= 120, z= 7})
end

Although I assume you want to add more then that, like exhaustion?
 
Last edited:
Then how do you want it? without choosing, 1 monster with same amount? different monsters, different amount?

i kinda want the script to go along something like this

Code:
local config = {
	["1"] = {n = 1},
}
 
function onTextEdit(cid, item, newText)
 
	if item.uid == 15000 and item.itemid == 9825 then -- add the unique id in the lever
	local x = config[newText]
		if x then
			for i = 1, x.n do
			local pos{x=1007, y=1026, z=7-- edit here the locations from the area they spawn in
				doSummonCreature("Ferumbras", pos)-- name of monster you want here
			end
			doPlayerSendTextMessage(cid, 22, "1"..newText.." Ferumbras spawned.")
		else 
			doPlayerSendTextMessage(cid, 22, "You can only spawn 1 Ferumbras at a time.")
		end
	end
	return true
end
 
Like this there is no reason for the table, I made the table to be able to choose between 10 numbers, so it will do the doSummonCreature function the same amount as the number the person entered in the blackboard. and you wanted to use a lever right instead of textedit?
 
Like this there is no reason for the table, I made the table to be able to choose between 10 numbers, so it will do the doSummonCreature function the same amount as the number the person entered in the blackboard. and you wanted to use a lever right instead of textedit?

yeah the lever ^^ so you can only spawn 1 ferumbras at a time like a private spawn type of script

Edit: i like the script ive tried to make it so its the script i want but i fail :(
 
How exactly do you want it? I posted an example on my first post, but like this you can spam it and it only summens a ferumbras and doesn't do anything else, so what else should it have, like exhaustion, level, magiceffects?
 
How exactly do you want it? I posted an example on my first post, but like this you can spam it and it only summens a ferumbras and doesn't do anything else, so what else should it have, like exhaustion, level, magiceffects?

No exhuast or level Req just so you can only use it once (untill it dies) then you can use it again
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
local fromPos = {x = toPosition.x - 10, y = toPosition.y - 10, z = toPosition.z} 
local toPos = {x = toPosition.x + 10, y = toPosition.y + 10, z = toPosition.z}
 
	local amount = 0
	for x = fromPos.x, toPos.x do
		for y = fromPos.y, toPos.y do
			for z = fromPos.z, toPos.z do
				local monster = getTopCreature({x=x,y=y,z=z}).uid
				if(isCreature(monster) == TRUE) then
					if getCreatureName(monster) == "Ferumbras" then
						amount = amount+1
					end
				end	
			end
		end
	end

	if amount >= 1 then
		doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) 
		doPlayerSendCancel(cid, "You need to kill Ferumbras first before you can summen one again.")
		return true
	else
		doSummonCreature("Ferumbras", {x = toPosition.x - 1, y = toPosition.y + 1, z = toPosition.z})
	      	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have summened Ferumbras.")
		doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
	end
        return true
end
 
Last edited:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
local fromPos = {x = toPosition.x - 10, y = toPosition.y - 10, z = toPosition.z} 
local toPos = {x = toPosition.x + 10, y = toPosition.y + 10, z = toPosition.z}
 
	local amount = 0
	for x = fromPos.x, toPos.x do
		for y = fromPos.y, toPos.y do
			for z = fromPos.z, toPos.z do
				local monster = getTopCreature({x=x,y=y,z=z}).uid
				if(isCreature(monster) == TRUE) then
					if getCreatureName(monster) == "Ferumbras" then
						amount = amount+1
					end
				end	
			end
		end
	end

	if amount >= 1 then
		doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) 
		doPlayerSendCancel(cid, "You need to kill Ferumbras first before you can summen one again.")
		return true
	else
		doSummonCreature("Ferumbras", {x = toPosition.x - 1, y = toPosition.y + 1, z = toPosition.z})
	      	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have summened Ferumbras.")
		doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
	end
end

Where do i but the position i want it to spawn? ;3
 
I added the position, it spawns now 1 square south west from the lever.

You can change the - 1 and + 1 numbers here if you want it to spawn on an other place around the lever:
Lua:
doSummonCreature("Ferumbras", {x = toPosition.x - 1, y = toPosition.y + 1, z = toPosition.z})
Btw, I assume Ferumbras should spawn close to the lever? If that's not the case, then just change all positions to normal positions.
 
Last edited:
I added the position, it spawns now 1 square south west from the lever.

You can change the - 1 and + 1 numbers here if you want it to spawn on an other place around the lever:
Lua:
doSummonCreature("Ferumbras", {x = toPosition.x - 1, y = toPosition.y + 1, z = toPosition.z})
Btw, I assume Ferumbras should spawn close to the lever? If that's not the case, then just change all positions to normal positions.

im not a scripter xD im still learning :( BUMP

Edit: i cant do it so maybe you can but it together for me? just but a random pos like 1015 , 1025 , 7 and ill change it to what i want :) wi repp+
 
Where should the Ferumbras spawn? is it close to the lever? then you can just add it like it is now without editing anything.
 
Last edited:
Where should the Ferumbras spawn? is it close to the lever? then you can just add it like it is now without editing anything.

aff nvm ill just start another thread, since no one can ever help me ;/

- - - Updated - - -

CLOSE THIS THREAD PLEASE
 
I made the script for you, I tested it, it works, what else do you want?

If you don't understand something, feel free to ask.
And like I said, just add the script to your server, you don't have to edit anything.
The toPosition is the position of the lever, it doesn't matter where the lever is it will always spawn around the lever.
 
where do i put . its from post 8 what folder... im new and if it works ill repp


function onUse(cid, item, fromPosition, itemEx, toPosition)

local fromPos = {x = toPosition.x - 10, y = toPosition.y - 10, z = toPosition.z}
local toPos = {x = toPosition.x + 10, y = toPosition.y + 10, z = toPosition.z}

local amount = 0
for x = fromPos.x, toPos.x do
for y = fromPos.y, toPos.y do
for z = fromPos.z, toPos.z do
local monster = getTopCreature({x=x,y=y,z=z}).uid
if(isCreature(monster) == TRUE) then
if getCreatureName(monster) == "Ferumbras" then
amount = amount+1
end
end
end
end
end

if amount >= 1 then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "You need to kill Ferumbras first before you can summen one again.")
return true
else
doSummonCreature("Ferumbras", {x = toPosition.x - 1, y = toPosition.y + 1, z = toPosition.z})
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have summened Ferumbras.")
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
end
end
 
Last edited:
You have to add it in actions, you can add an uniqueid in the level then add it with that uniqueid to actions.xml.
 
qwzq85.png
 
Back
Top