I'm trying to do an AMBUSH system, but calling from a Global LIB (AMBUSH_TABLE). It calls the name of monsters to be summoned for each UID tile you StepOut (in different locations, of course...) BTW the game don't create the monster and don't even appear anything in console to help me out how to fix... so I know the code is not well done, since i'm not good at scripts... btw I'm trying!
Also i'm trying to input an ADDEVENT() for create the monsters after 3 seconds.
and HERE is the LIB file:
Also i'm trying to input an ADDEVENT() for create the monsters after 3 seconds.
Lua:
function onStepOut(cid, item, position, fromPosition)
local tile = Item(item.uid)
local player = Player(cid)
if not tile or not player then
return true
end
local pos = player:getPosition()
local uniqueid = tile:getUniqueId()
if player:getStorageValue(uniqueid) == -1 or player:getStorageValue(uniqueid) == 0 then
local creatures_pool = {}
for i, monsters in pairs(AMBUSH_TABLE) do
table.insert(creatures_pool, AMBUSH_TABLE[i].monsters)
end
for k = 1, #creatures_pool do
local pos = player:getPosition()
local radius = 2
Game.createMonster(creatures_pool[k], position(math.random(pos.x-radius, pos.x+radius), math.random(pos.y-radius, pos.y+radius), pos.z))
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Você sofreu uma emboscada!")
-- player:setStorageValue(uniqueid, 1)
end
end
end
and HERE is the LIB file:
Lua:
AMBUSH_TABLE = { [60005] = {monsters = {'skeleton', 'poison spider'}
},
[60006] = {monsters = {}
},
}