• 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 lever spawn monster

janes123

New Member
Joined
Jun 21, 2012
Messages
100
Reaction score
4
who knows how to make this script block the respawn of the second monster? on tfs 1.3 :D

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local fromPos = {x = toPosition.x - 10, y = toPosition.y - 10, z = toPosition.z}
local toPos = {x = toPosition.x + 10, y = toPosition.y + 10, z = toPosition.z}
    local amount = 0
    for x = fromPos.x, toPos.x do
        for y = fromPos.y, toPos.y do
            for z = fromPos.z, toPos.z do
                local monster = getTopCreature({x=x,y=y,z=z}).uid
                if(isCreature(monster) == TRUE) then
                    if getCreatureName(monster) == "Ferumbras" then
                        amount = amount+1
                    end
                end
            end
        end
    end
    if amount >= 1 then
        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
        doPlayerSendCancel(cid, "You need to kill Ferumbras first before you can summen one again.")
        return true
    else
        doSummonCreature("Ferumbras", {x = toPosition.x - 1, y = toPosition.y + 1, z = toPosition.z})
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have summened Ferumbras.")
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
    end
        return true
end
Only the monster spawn work
 
Solution
Something like this. Only thing I'm not sure is 'cid'. Is there 'cid' as first parameter to 'onUse' or 'player' in 1.3?
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local fromPos = {x = toPosition.x - 10, y = toPosition.y - 10, z = toPosition.z}
    local toPos = {x = toPosition.x + 10, y = toPosition.y + 10, z = toPosition.z}

    for x = fromPos.x, toPos.x do
        for y = fromPos.y, toPos.y do
            for z = fromPos.z, toPos.z do
                local tile = Tile(x, y, z)
                if tile then -- check if tile exists
                    local creature = tile:getTopCreature() -- get top creature
                    local monster = Monster(creature) -- change Creature to Monster (check if it's...
Something like this. Only thing I'm not sure is 'cid'. Is there 'cid' as first parameter to 'onUse' or 'player' in 1.3?
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local fromPos = {x = toPosition.x - 10, y = toPosition.y - 10, z = toPosition.z}
    local toPos = {x = toPosition.x + 10, y = toPosition.y + 10, z = toPosition.z}

    for x = fromPos.x, toPos.x do
        for y = fromPos.y, toPos.y do
            for z = fromPos.z, toPos.z do
                local tile = Tile(x, y, z)
                if tile then -- check if tile exists
                    local creature = tile:getTopCreature() -- get top creature
                    local monster = Monster(creature) -- change Creature to Monster (check if it's monster)
                    if monster and monster:getName() == "Ferumbras" then
                        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
                        doPlayerSendCancel(cid, "You need to kill Ferumbras first before you can summen one again.")
                        return true
                    end
                end
            end
        end
    end

    doSummonCreature("Ferumbras", {x = toPosition.x - 1, y = toPosition.y + 1, z = toPosition.z})
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have summened Ferumbras.")
    doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)

    return true
end
 
Solution
Back
Top