• 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 Help in this Table

FabianoBN

l|¬¬"|l
Joined
Jan 23, 2009
Messages
745
Reaction score
22
Location
Goias - Brazil
Would be the right way to use to check if the area has some monster?

Lua:
local from = {x=1234, y=1234, z=3}
local to = {x=1234, y=1234, z=3}

for x = from.x, to.x do
 for y = from.y, to.y do
  local v = getTopCreature({x=x, y=y, z=from.z}).uid
   if isMonster(v) then
    return doCreatureSay(cid, 'There is already a monstter in the area.', TALKTYPE_ORANGE_1, false, cid)
   else
   doSetItemActionId(doCreateItem(1945,1,pos1), 1234)
   doSetItemActionId(doCreateItem(1945,1,pos2), 1234)
   doSetItemActionId(doCreateItem(1945,1,pos3), 1234)
   doSetItemActionId(doCreateItem(1945,1,pos4), 1234)
   doSetItemActionId(doCreateItem(1945,1,pos5), 1234)
   end
 end
end
 
Last edited:
Not positive what you're asking but, if what you're asking is if this script is a good way to check for a monster in an area, then yes it is more than effecient

fixed tabbing
Lua:
local from = {x=1234, y=1234, z=3}
local to = {x=1234, y=1234, z=3}
 
for x = from.x, to.x do
	for y = from.y, to.y do
		local v = getTopCreature({x=x, y=y, z=from.z}).uid
		if isMonster(v) then
			return doCreatureSay(cid, 'There is already a monster in the area.', TALKTYPE_ORANGE_1, false, cid)
		else
			doSetItemActionId(doCreateItem(2160,1,pos1), 1234)
			doSetItemActionId(doCreateItem(2160,1,pos2), 1234)
			doSetItemActionId(doCreateItem(2160,1,pos3), 1234)
			doSetItemActionId(doCreateItem(2160,1,pos4), 1234)
			doSetItemActionId(doCreateItem(2160,1,pos5), 1234)
		end
	end
end
 
Small notice. You should firstly check if v is higher than 0, if yes, then you can check if creature is monster. I don't see sense of using function isMonster for nil (because getTopCreature can return this value).


_
Regards,
sn3ejk
 
I use this table in the AddEvent.
but does not work ;x

I'm using so:
Lua:
local from = {x=1234, y=1234, z=3}
local to = {x=1234, y=1234, z=3}
 
local function createitem(item, pos)
   for x = from.x, to.x do
    for y = from.y, to.y do
     local v = getTopCreature({x=x, y=y, z=from.z}).uid
      if isMonster(v) then
       return doCreatureSay(cid, 'There is already a monster in the area.', TALKTYPE_ORANGE_1, false, cid)
       addEvent(createitem, 10*1000, cid) 
      else
       doSetItemActionId(doCreateItem(1945,1,pos1), 1234)
       doSetItemActionId(doCreateItem(1945,1,pos2), 1234)
       doSetItemActionId(doCreateItem(1945,1,pos3), 1234)
       doSetItemActionId(doCreateItem(1945,1,pos4), 1234)
       doSetItemActionId(doCreateItem(1945,1,pos5), 1234)
      end
    end
   end
end

this script are checking if the monster has and is creating the item anyway.
I need to check if have the monster in the area, if have the monster, it runs the message and then after 10 seconds rerun the same function.
 
Well the coordinates you have set are 1x1 area is the monster moving? If so you need from to be top left corner and to to be bottom right corner.
 
Back
Top