• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Monster Lever Script, doRemoveCreature.

Cornwallis

Member
Joined
Jan 3, 2010
Messages
480
Reaction score
16
I'm sick of this script lol, everything about it works fine except for the doRemoveCreature, and I'm not sure how to make it remove random creatures in a 1x1 area, for example "exori gran". I tried a lot of stuff, nothing wants to work.. 0.3.1pl2. If possible, can the tiles be cleaned too on 1945? If there is a function I must add to do so, let me know, thanks in advance, any advice is appreciated!
PHP:
local t = {
	[{1, 14}] = "Rotworm",
	[{15, 39}] = "Dragon",
	[{40, 79}] = "Dragon Lord",
	[{80, 179}] = "Demon",
	[{180, 3000}] = "Bog Spider"
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local fromPos = {x=fromPosition.x+1,y=fromPosition.y,z=fromPosition.z}
local toPos = {x=toPosition.x,y=toPosition.y-1,z=toPosition.z}
	if(item.itemid == 1946) then
		for k, v in pairs(t) do
			if(getPlayerLevel(cid) >= k[1] and getPlayerLevel(cid) <= k[2]) then
				doSummonCreature(v, getPlayerPosition(cid))
				doSummonCreature(v, getPlayerPosition(cid))
			end
		end
	elseif(item.itemid == 1945 or getPlayerLevel(cid) > k[2]) then
		doPlayerSendCancel(cid, "Sorry, not possible.")
		doRemoveCreature(isMonster(isInArea(fromPos, toPos)))
		doRemoveCreature(isMonster(isInArea(fromPos, toPos)))
	end
return true
end

Forgot the error;
PHP:
[16/06/2012 07:56:09] data/lib/function.lua:258: attempt to index local 'toPos' (a nil value)
[16/06/2012 07:56:09] stack traceback:
[16/06/2012 07:56:09] 	data/lib/function.lua:258: in function 'isInArea'
[16/06/2012 07:56:09] 	data/actions/scripts/other/monster_lever.lua:21: in function <data/actions/scripts/other/monster_lever.lua:9>

Edit; here is the function in lib/function.lua:
PHP:
function isInArea(pos, fromPos, toPos)
	if(pos.x >= fromPos.x and pos.x <= toPos.x) then
		if(pos.y >= fromPos.y and pos.y <= toPos.y) then
			if(pos.z >= fromPos.z and pos.z <= toPos.z) then
				return TRUE
			end
		end
	end

	return FALSE
end
-------------------------------------------------------------------------------------------------------------------------------------
Sorry for all these edits, but here is what I got to after reviewing that function. If this one is closer you can use it, if it isn't then use the above one.
PHP:
local t = {
	[{1, 14}] = "Rotworm",
	[{15, 39}] = "Dragon",
	[{40, 79}] = "Dragon Lord",
	[{80, 179}] = "Demon",
	[{180, 3000}] = "Bog Spider"
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local fromPos = {x=fromPosition.x+1,y=fromPosition.y,z=fromPosition.z}
local toPos = {x=toPosition.x,y=toPosition.y-1,z=toPosition.z}
	if(item.itemid == 1946) then
		for k, v in pairs(t) do
			if(getPlayerLevel(cid) >= k[1] and getPlayerLevel(cid) <= k[2]) then
				doSummonCreature(v, getPlayerPosition(cid))
				doSummonCreature(v, getPlayerPosition(cid))
			end
		end
	elseif(item.itemid == 1945 or getPlayerLevel(cid) > k[2]) then
		doPlayerSendCancel(cid, "Sorry, not possible.")
		doRemoveCreature(isMonster(isInArea(getCreaturePosition(cid), fromPos, toPos)))
		doRemoveCreature(isMonster(isInArea(getCreaturePosition(cid), fromPos, toPos)))
	end
return true
end
Code:
[16/06/2012 09:18:57] luaDoRemoveCreature(). Creature not found
 
Last edited:
Back
Top