• 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 if all monsters die then remove the stone

Fir3z

New Member
Joined
Oct 31, 2017
Messages
2
Reaction score
0
Give as much information as possible(TFS version, OS, errors, scripts).
Hello, i'm trying to do it a quest, when I push the lever, will create 4 monsters, when everyone dies, I can push again the lever, and remove the stone, if I push the lever when have monsters alive, show the message "kill everyone to pass".

almost everything is working, my problem is:

if I hit the monster, I can push the lever and remove the stone... if the monster is not full life I can push the lever...

img: Screenshot (http://prntscr.com/p695oq)

someone know how can I fix this?

OTX Server 3.8 ver. 10.98

Code:
local monster_pos = {
    [1] = {pos = {517, 911, 7}, monster = "Elite Troll Champion"},
    [2] = {pos = {512, 911, 7}, monster = "Elite Troll Champion"},
    [3] = {pos = {512, 916, 7}, monster = "Elite Troll Champion"},
    [4] = {pos = {512, 921, 7}, monster = "Elite Troll Champion"},
    [5] = {pos = {517, 921, 7}, monster = "Elite Troll Champion"},
    [6] = {pos = {522, 921, 7}, monster = "Elite Troll Champion"},
    [7] = {pos = {522, 916, 7}, monster = "Elite Troll Champion"},
    [8] = {pos = {522, 911, 7}, monster = "Elite Troll Champion"}
}

local stone_1 = Position(517, 906, 7)
local stone_2 = Position(517, 916, 8)
   
local location = Position(517, 916, 7)

function onUse(cid, item, fromPosition, itemEx, toPosition, player, target, isHotkey)
    local tile2 = stone_2:getTile()
    if tile2 then
        local stone2 = tile2:getItemById(1355)
        if stone2 and item.itemid == 1945 then
            doPlayerSendTextMessage(cid,19,"You have already kill everyone and the stone has been removed!")
            return true
        elseif item.itemid == 1945 then
            for _, area in pairs(monster_pos) do
                doSummonCreature(area.monster,{x=area.pos[1],y=area.pos[2],z=area.pos[3]})
            end
            doPlayerSendTextMessage(cid,19,"Kill everyone to pass!")
            doTransformItem(item.uid,1946)
            Game.createItem(1355, 1, stone_2)
        elseif item.itemid == 1946 then
            local specs, spec = Game.getSpectators(location, false, false, 10, 10, 9, 9)
            for i = 1, #specs do
                spec = specs[i]
                local tile = stone_1:getTile()
                if spec:isMonster() then
                    doPlayerSendTextMessage(cid,19,"Kill everyone to pass.")
                    return false
                elseif tile then
                    local stone = tile:getItemById(1355)
                    if stone then
                        stone:remove()
                    end
                doPlayerSendTextMessage(cid,19,"The stone has been removed!")
                doTransformItem(item.uid,1945)          
                end
            end
        end
    end
return TRUE
end

(the "stone_2" is only for not push again)
 
Last edited:
TFS version?
Read Support Board rules before posting your next thread.

and about your script it is already posted many times with onkill/onuse
 
Back
Top