• 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 [0.4] Spawn chests each 3 hours

elnelson

Lunaria World Dev
Joined
Jun 20, 2009
Messages
595
Solutions
2
Reaction score
66
Location
México
Hello, otlanders, i was thinking about a script that spawns chest every 3 hours in certain areas (configurable) IF nobody took the chest (and the chest is there yet) dont spawn another chest in that location only spawn on the areas whose chest have been looted (when chest is looted, it dissapears tho)

As title says im using TFS 0.4 rev 3777 =)
 
i guess i found a simple solution using getTopCreature, anyway here is the script =P


LUA:
local randompos = {{x = 300, y = 232, z = 7}, {x = 301, y = 232, z = 7}}, -- positions where chests will spawn (creature chests)
function onThink(cid, interval)
        local rpos = randompos[math.random(1, #randompos)] -- checks how many pos are and creates a random function
        local pid = getTopCreature(rpos).uid -- analyze if there is a creature on the position
        if pid == 0 then -- if no creature is on the pos then
                doCreateMonster("chest", rpos) -- creates a creature names Chest (it gives loot with noice items tho)
            else --if there is a creature standing in that pos then
                print("--Chest is available") -- this is test porpouse, you can remove this else
        end
    return true
end

Hope you guys enjoy this simple script ;)
 
Last edited:
Back
Top