function checkAreaForItem(pos, range, item)
local from = {x=pos.x-range, y=pos.y-range, z=pos.z}
local to = {x=pos.x+range, y=pos.y+range, z=pos.z}
for z = from.z, to.z do
for y = from.y, to.y do
for x = from.x, to.x do
local t = Tile(Position(x, y, z))
if t:getItemById(item) then
return true
end
end
end
end
end
-- checkAreaForItem(pos, range, itemId) With this function you can change the range and the itemId what are you looking for.
-- checkAreaForItem(pos, 2, 2725) In this case, whe are looking for item 2725, 2 sqm arround the position called.
function onCastSpell(cid, var)
local c = Creature(cid)
local pos = c:getPosition()
if checkAreaForItem(pos, 2, 2725) then
doCreatureSay(cid, "Ok", TALKTYPE_ORANGE_1)
else
doCreatureSay(cid, "Ok NO", TALKTYPE_ORANGE_1)
end
end