Tbol
Well-Known Member
- Joined
- Apr 7, 2019
- Messages
- 529
- Reaction score
- 56
Hello, I created this code that I found from Oen and edited it a bit. I'm wondering how I can prevent it from spawning on trees and other objects. Is it possible to allow it to spawn only on walkable ground? I've tried something like this, but it still spawns on stairs or mountains.
Basically this code spawns in area x,y,z and in radius of 6 and it allows only to spawn 10 objects in that area
Basically this code spawns in area x,y,z and in radius of 6 and it allows only to spawn 10 objects in that area
Lua:
CURSED_CHESTS_AID = 9000
CURSED_CHESTS_SPAWNS = {
[1] = {
pos = Position(96, 210, 7),
radius = 6,
limit = 10,
item = 19512,
spawnedCount = 0
}
}
function onThink(cid, interval, lastExecution)
for _, data in pairs(CURSED_CHESTS_SPAWNS) do
if data.spawnedCount < data.limit then
local spawnPos = Position(data.pos.x + math.random(-data.radius, data.radius), data.pos.y + math.random(-data.radius, data.radius), data.pos.z)
local tile = Tile(spawnPos)
if tile and tile:getGround() then
local chest = Game.createItem(data.item, 1, spawnPos)
if chest then
chest:setActionId(CURSED_CHESTS_AID)
data.spawnedCount = data.spawnedCount + 1
end
end
end
end
return true
end