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

Lua Need Help with Lever Monster Script

xx Kami xx

Retired.
Joined
Dec 29, 2012
Messages
509
Reaction score
20
hello and i need help fixing a small script

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
			doSummonCreature("Ferumbras", {x= 1007, y= 1025, z= 7})
 
	local amount = 1
	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
	end
	      	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have summened Ferumbras.")
		doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
	end
end

What the script is suppose to do: Using the lever you spawn 1 ferumbras but cannot use lever again untill the ferumbras is dead.

Repp++ if anyone can fix it
 
Last edited by a moderator:
I think mine is a bit better though....Its way less information being passed.

But you also have to keep a global variable with your script that contains userdata if he uses 1.x.

If he wants to improve it he should use the one I posted above but use getSpectators insted.
Also avoid passing functions as a return values.
 
Well, he can check a stored value or he can scan a bunch of tiles in a loop. Which ever one seems better.

There is no real problem with storing userdata as long as the script is set up to handle it. In this case it is.
 
Well, he can check a stored value or he can scan a bunch of tiles in a loop. Which ever one seems better.

There is no real problem with storing userdata as long as the script is set up to handle it. In this case it is.

You didn't read what I said, I told him to use getSpectators if you know what that function does you know it's alot better than getTopCreature.

Correct you can store userdata, but IMO unless you actually need the userdata itself it's useless.
And the only way to use your script in that case is to store the userdata or uid to then check if that creature exists, if it dosn't it shouldn't spawn.

It's up to him, but I would go with Position:getSpectators, most poeple use that and if you ex look at ORTS that what they use aswell since you can avoid bugs if the monster is teleported by a GM or something.
 
Back
Top