• 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 onUse, summon monsters, 5 min exhaust.

ohman

Member
Joined
Oct 24, 2008
Messages
289
Reaction score
5
Location
Sweden
Hi! I want a script that summons x monster if I use a item (a statue). You should only be able to do this every 5 minutes. If someone know how, please post :) Thanks!
 
Code:
local timeToUse = 300
local monsters = {
    {name = "Rat", pos = {x = 111, y = 111, z = 7}},
    {name = "Troll", pos = {x = 112, y = 112, z = 7}},
    {name = "Demon", pos = {x = 113, y = 113, z = 7}}
}

local lastTime = 0 -- Ignore this
function onUse(cid, item, position, itemEx, toPosition)
    local osTime = os.time()
    if(lastTime <= osTime) then
        for _, mob in ipairs(monsters) do
            Game.createMonster(mob.name, mob.pos)
        end
        lastTime = osTime + timeToUse
    end
    return true
end

This is for TFS 1.0, if you're using anything else then replace Game.createMonster with doSummonCreature.
 
Thanks! It works good :) I changed it a bit and added some extra stuff. The monster now removes after 20 minutes. And I added a message if you cant use it.



Code:
local name = "Fury of the Emperor"
local timeToUse = 1200
local pos = {x = 33055, y = 31116, z = 15}

local lastTime = 0 -- Ignore this
function onUse(cid, item, position, itemEx, toPosition)
    local osTime = os.time()
    if(lastTime <= osTime) then
    addEvent(furyoftheemperor,1200*1000)
            doSummonCreature(name, pos)
        lastTime = osTime + timeToUse
else
doPlayerSendTextMessage(cid,22,"You")
    end
    return true
end


function furyoftheemperor()
for _, monster in ipairs{(name)} do
doRemoveCreature(getCreatureByName(monster))
return true
end
end
 
Back
Top