• 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!

Boss room with cooldown 20 hours

massuco

Brazilian, sorry for my bad english XD
Joined
Feb 17, 2013
Messages
199
Solutions
8
Reaction score
22
Location
Brasil
I want to do one boss, that player can kill each 20 hours, like warzones.
To access the boss, Im using the default script for anihilator of othire (but with 5 player), but i want to make the lever pushable only if the 5 players needed are not on the boss cooldown time (20 hours), any idea?
OTServ: OTHire 0.0.3
Version: 7.72
Lua:
        -- CONFIG --
        
        local playersOnly = "no"
        local questLevel = 1

        local room = {     -- boss room
        fromX = 985,
        fromY = 1146,
        fromZ = 6,
        --------------
        toX = 993,
        toY = 1157,
        toZ = 6
        }

        local monster_pos = {
        [1] = {pos = {989, 1147, 6}, monster = "Librarian"}
        }

        local players_pos = {
        {x = 1031, y = 1130, z = 5, stackpos = 253},
        {x = 1031, y = 1131, z = 5, stackpos = 253},
        {x = 1031, y = 1132, z = 5, stackpos = 253},
        {x = 1031, y = 1133, z = 5, stackpos = 253},
        {x = 1031, y = 1134, z = 5, stackpos = 253}
        }

        local new_player_pos = {
        {x = 989, y = 1151, z = 6},
        {x = 989, y = 1152, z = 6},
        {x = 989, y = 1153, z = 6},
        {x = 989, y = 1154, z = 6},
        {x = 989, y = 1155, z = 6}
        }

        ------------------------------------------------------
        --- CONFIG END ---------------------------------------
        ------------------------------------------------------

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local all_ready, monsters, player, level = 0, 0, {}, 0
    if item.uid == 7003 then
        if item.itemid == 1946 then
                for i = 1, #players_pos do
                        table.insert(player, 0)
                end
                for i = 1, #players_pos do
                        player[i] = getThingfromPos(players_pos[i])
                        if player[i].itemid > 0 then
                                if string.lower(playersOnly) == "yes" then
                                        if isPlayer(player[i].uid) == true then
                                                all_ready = all_ready+1
                                        else
                                                monsters = monsters+1
                                        end
                                else
                                        all_ready = all_ready+1
                                end
                        end
                end
                if all_ready == #players_pos then
                        for i = 1, #players_pos do
                                player[i] = getThingfromPos(players_pos[i])
                                if isPlayer(player[i].uid) == true then
                                        if getPlayerLevel(player[i].uid) >= questLevel then
                                                level = level+1
                                        end
                                else
                                        level = level+1
                                end
                        end
                        if level == #players_pos then
                                if string.lower(playersOnly) == "yes" and monsters == 0 or string.lower(playersOnly) == "no" then
                                        for _, area in pairs(monster_pos) do
                                                        doSummonCreature(area.monster,{x=area.pos[1],y=area.pos[2],z=area.pos[3]})
                                        end
                                        for i = 1, #players_pos do
                                                doSendMagicEffect(players_pos[i], CONST_ME_POFF)
                                                doTeleportThing(player[i].uid, new_player_pos[i])
                                                doSendMagicEffect(new_player_pos[i], CONST_ME_ENERGYAREA)
                                                doTransformItem(item.uid,1945)
                                        end
                                else
                                        doPlayerSendTextMessage(cid,19,"Only players can do this quest.")
                                end
                        else
                                doPlayerSendTextMessage(cid,19,"All Players have to be level "..questLevel.." to do this quest.")
                        end
                else
                        doPlayerSendCancel(cid,"You need "..table.getn(players_pos).." players to do this quest.")
                end
        elseif item.itemid == 1945 then
                local player_room = 0
                for x = room.fromX, room.toX do
                        for y = room.fromY, room.toY do
                                for z = room.fromZ, room.toZ do
                                        local pos = {x=x, y=y, z=z,stackpos = 253}
                                        local thing = getThingfromPos(pos)
                                        if thing.itemid > 0 then
                                                if isPlayer(thing.uid) == true then
                                                        player_room = player_room+1
                                                end
                                        end
                                end
                        end
                end
                if player_room >= 1 then
                        doPlayerSendTextMessage(cid,19,"There is already a team in the quest room.")         
                elseif player_room == 0 then
                        for x = room.fromX, room.toX do
                                for y = room.fromY, room.toY do
                                        for z = room.fromZ, room.toZ do
                                                local pos = {x=x, y=y, z=z,stackpos = 253}
                                                local thing = getThingfromPos(pos)
                                                if thing.itemid > 0 then
                                                        doRemoveCreature(thing.uid)
                                                end
                                        end
                                end
                        end
                        doTransformItem(item.uid,1946)
                end
        end
    end   
        return true
end
 
Solution
Try this
Lua:
-- CONFIG --
    local playersOnly = "no"
    local questLevel = 1
    local STORAGE_BOSS_CD = 22497
    local cdtime = 20 * 60 * 60 -- exhaust in seconds

    local room = {     -- boss room
        fromX = 985,
        fromY = 1146,
        fromZ = 6,
        --------------
        toX = 993,
        toY = 1157,
        toZ = 6
    }

    local monster_pos = {
        [1] = {pos = {989, 1147, 6}, monster = "Librarian"}
    }

    local players_pos = {
        {x = 1031, y = 1130, z = 5, stackpos = 253},
        {x = 1031, y = 1131, z = 5, stackpos = 253},
        {x = 1031, y = 1132, z = 5, stackpos = 253},
        {x = 1031, y = 1133, z = 5, stackpos = 253},
        {x = 1031, y = 1134, z = 5, stackpos = 253}
    }...
Try this
Lua:
-- CONFIG --
    local playersOnly = "no"
    local questLevel = 1
    local STORAGE_BOSS_CD = 22497
    local cdtime = 20 * 60 * 60 -- exhaust in seconds

    local room = {     -- boss room
        fromX = 985,
        fromY = 1146,
        fromZ = 6,
        --------------
        toX = 993,
        toY = 1157,
        toZ = 6
    }

    local monster_pos = {
        [1] = {pos = {989, 1147, 6}, monster = "Librarian"}
    }

    local players_pos = {
        {x = 1031, y = 1130, z = 5, stackpos = 253},
        {x = 1031, y = 1131, z = 5, stackpos = 253},
        {x = 1031, y = 1132, z = 5, stackpos = 253},
        {x = 1031, y = 1133, z = 5, stackpos = 253},
        {x = 1031, y = 1134, z = 5, stackpos = 253}
    }

    local new_player_pos = {
        {x = 989, y = 1151, z = 6},
        {x = 989, y = 1152, z = 6},
        {x = 989, y = 1153, z = 6},
        {x = 989, y = 1154, z = 6},
        {x = 989, y = 1155, z = 6}
    }
-- CONFIG END --

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local all_ready, monsters, player, level = 0, 0, {}, 0

    if item.itemid == 1946 then
        for i = 1, #players_pos do
            table.insert(player, 0)
        end
        for i = 1, #players_pos do
            player[i] = getThingfromPos(players_pos[i])
            if player[i].itemid > 0 then
                if string.lower(playersOnly) == "yes" then
                    if isPlayer(player[i].uid) == true then
                        all_ready = all_ready+1
                    else
                        monsters = monsters+1
                    end
                else
                    all_ready = all_ready+1
                end
            end
        end
        if all_ready == #players_pos then
            for i = 1, #players_pos do
                player[i] = getThingfromPos(players_pos[i])
                if isPlayer(player[i].uid) == true then
                    if getPlayerStorageValue(player[i].uid,STORAGE_BOSS_CD) > os.time() then
                        doPlayerSendCancel(cid,"On cooldown for at least one player.")
                        return false
                    end
                    if getPlayerLevel(player[i].uid) >= questLevel then
                        level = level+1
                    end
                else
                    level = level+1
                end
            end
            if level == #players_pos then
                if string.lower(playersOnly) == "yes" and monsters == 0 or string.lower(playersOnly) == "no" then
                    for _, area in pairs(monster_pos) do
                        doSummonCreature(area.monster,{x=area.pos[1],y=area.pos[2],z=area.pos[3]})
                    end
                    for i = 1, #players_pos do
                        doSendMagicEffect(players_pos[i], CONST_ME_POFF)
                        doTeleportThing(player[i].uid, new_player_pos[i])
                        doSendMagicEffect(new_player_pos[i], CONST_ME_ENERGYAREA)
                        setPlayerStorageValue(player[i].uid,STORAGE_BOSS_CD,os.time() + cdtime)
                    end
                    doTransformItem(item.uid,1945)
                else
                    doPlayerSendTextMessage(cid,19,"Only players can do this quest.")
                    return false
                end
            else
                doPlayerSendTextMessage(cid,19,"All Players have to be level "..questLevel.." to do this quest.")
                return false
            end
        else
            doPlayerSendCancel(cid,"You need "..table.getn(players_pos).." players to do this quest.")
            return false
        end
    elseif item.itemid == 1945 then
        local player_room = 0
        for x = room.fromX, room.toX do
            for y = room.fromY, room.toY do
                for z = room.fromZ, room.toZ do
                    local pos = {x=x, y=y, z=z,stackpos = 253}
                    local thing = getThingfromPos(pos)
                    if thing.itemid > 0 then
                        if isPlayer(thing.uid) == true then
                            player_room = player_room+1
                        end
                    end
                end
            end
        end
        if player_room >= 1 then
            doPlayerSendTextMessage(cid,19,"There is already a team in the quest room.")
            return false
        elseif player_room == 0 then
            for x = room.fromX, room.toX do
                for y = room.fromY, room.toY do
                    for z = room.fromZ, room.toZ do
                        local pos = {x=x, y=y, z=z,stackpos = 253}
                        local thing = getThingfromPos(pos)
                        if thing.itemid > 0 then
                            doRemoveCreature(thing.uid)
                        end
                    end
                end
            end
            doTransformItem(item.uid,1946)
        end
    end

    return true
end
 
Last edited by a moderator:
Solution
Moderator, this lua shit is changing my tab for spaces. #TABIDENTATIONMASTERRACE
Sorry for the offtopic, but I hardly agree with that statement.
PEP-8 for Python, which is King of syntax if it comes to indents, says you should use spaces. Therefore I believe it would be wise to use them, or at least configure your environment to convert from tabs to spaces.


@down:
Oh yes. Thank you.
 
Last edited:
I hardly disagree with that statement.
This means you agree. Hardly = not at all.

Yes, spaces should be used in most languages but it's a war not worth bringing over here. What's important is that our Code highlighter seems to use spaces, hence there will be spaces.
 
Back
Top