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

Solved Huntig Arena Script PROBLEM !

Daniel Kopeć

Member
Joined
Dec 8, 2018
Messages
125
Solutions
4
Reaction score
12
Location
Poland
After the server restart, the player who was in the arena logs in to the arena and from that moment has unlimited time and is not kicked out to the Temple.
How to fix it?

Here is my script from the mods folder:

XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Hunting_rooms" version='2.0' author='VirrageS' contact='otland.net' enabled='yes'>
    <config name="huntingConfig">
        <![CDATA[
            huntingConfig = {
                [1] = {
                    fromPos = {x=32446, y=32486, z=6}, -- left top corner of event room
                    toPos = {x=32454, y=32494, z=6},
                    teleportPos = {x=32450, y=32490, z=6},

                    expireTime = 1200,
                    enteryAid = 7231,
                    monsters = {'Worker', 4}
                },

                [2] = {
                    fromPos = {x=32460, y=32486, z=6},
                    toPos = {x=32468, y=32494, z=6},
                    teleportPos = {x=32464, y=32490, z=6},

                    expireTime = 1200,
                    enteryAid = 7232,
                    monsters = {'Magic Dragon', 4}
                },
                [3] = {
                    fromPos = {x=32474, y=32486, z=6},
                    toPos = {x=32482, y=32494, z=6},
                    teleportPos = {x=32478, y=32490, z=6},

                    expireTime = 1200,
                    enteryAid = 7233,
                    monsters = {'Worker', 4}
                },
                [4] = {
                    fromPos = {x=32446, y=32472, z=6},
                    toPos = {x=32454, y=32480, z=6},
                    teleportPos = {x=32450, y=32476, z=6},

                    expireTime = 1200,
                    enteryAid = 7234,
                    monsters = {'Lady Warlock', 4}
                },
                [5] = {
                    fromPos = {x=32460, y=32472, z=6},
                    toPos = {x=32468, y=32480, z=6},
                    teleportPos = {x=32464, y=32476, z=6},

                    expireTime = 1200,
                    enteryAid = 7235,
                    monsters = {'Poisoned Insect', 4}
                },
                [6] = {
                    fromPos = {x=32474, y=32472, z=6},
                    toPos = {x=32482, y=32480, z=6},
                    teleportPos = {x=32478, y=32476, z=6},

                    expireTime = 1200,
                    enteryAid = 7236,
                    monsters = {'Drzewiec', 4}
                },
                [7] = {
                    fromPos = {x=32446, y=32457, z=6},
                    toPos = {x=32454, y=32465, z=6},
                    teleportPos = {x=32450, y=32461, z=6},

                    expireTime = 1200,
                    enteryAid = 7237,
                    monsters = {'Giant', 4}
                },
                [8] = {
                    fromPos = {x=32460, y=32457, z=6},
                    toPos = {x=32468, y=32465, z=6},
                    teleportPos = {x=32464, y=32461, z=6},

                    expireTime = 1200,
                    enteryAid = 7238,
                    monsters = {'Giant', 4}
                },
                [9] = {
                    fromPos = {x=32474, y=32457, z=6},
                    toPos = {x=32482, y=32465, z=6},
                    teleportPos = {x=32478, y=32461, z=6},

                    expireTime = 1200,
                    enteryAid = 7239,
                    monsters = {'Lady Warlock', 4}
                },   
                [10] = {
                    fromPos = {x=32446, y=32486, z=5}, -- left top corner of event room
                    toPos = {x=32454, y=32494, z=5},
                    teleportPos = {x=32450, y=32490, z=5},

                    expireTime = 1200,
                    enteryAid = 7240,
                    monsters = {'Worker', 8}
                },
                [11] = {
                    fromPos = {x=32460, y=32486, z=5},
                    toPos = {x=32468, y=32494, z=5},
                    teleportPos = {x=32464, y=32490, z=5},

                    expireTime = 1200,
                    enteryAid = 7241,
                    monsters = {'Magic Dragon', 8}
                },
                [12] = {
                    fromPos = {x=32474, y=32486, z=5},
                    toPos = {x=32482, y=32494, z=5},
                    teleportPos = {x=32478, y=32490, z=5},

                    expireTime = 1200,
                    enteryAid = 7242,
                    monsters = {'Worker', 8}
                },
                [13] = {
                    fromPos = {x=32446, y=32472, z=5},
                    toPos = {x=32454, y=32480, z=5},
                    teleportPos = {x=32450, y=32476, z=5},

                    expireTime = 1200,
                    enteryAid = 7243,
                    monsters = {'Lady Warlock', 8}
                },
                [14] = {
                    fromPos = {x=32460, y=32472, z=5},
                    toPos = {x=32468, y=32480, z=5},
                    teleportPos = {x=32464, y=32476, z=5},

                    expireTime = 1200,
                    enteryAid = 7244,
                    monsters = {'Poisoned Insect', 8}
                },
                [15] = {
                    fromPos = {x=32474, y=32472, z=5},
                    toPos = {x=32482, y=32480, z=6},
                    teleportPos = {x=32478, y=32476, z=5},

                    expireTime = 1200,
                    enteryAid = 7245,
                    monsters = {'Drzewiec', 8}
                },
                [16] = {
                    fromPos = {x=32446, y=32457, z=5},
                    toPos = {x=32454, y=32465, z=5},
                    teleportPos = {x=32450, y=32461, z=5},

                    expireTime = 1200,
                    enteryAid = 7246,
                    monsters = {'Armored Giant', 8}
                },
                [17] = {
                    fromPos = {x=32460, y=32457, z=5},
                    toPos = {x=32468, y=32465, z=5},
                    teleportPos = {x=32464, y=32461, z=5},

                    expireTime = 1200,
                    enteryAid = 7247,
                    monsters = {'Armored Giant', 8}
                },
                [18] = {
                    fromPos = {x=32474, y=32457, z=5},
                    toPos = {x=32482, y=32465, z=5},
                    teleportPos = {x=32478, y=32461, z=5},

                    expireTime = 1200,
                    enteryAid = 7248,
                    monsters = {'Lady Warlock', 8}

                }
            }

            configHunting = {
                storage = 25050,
                
                timeStorage = 61472,
                
                storageExh = 25051,
                exhaust = 1,

                exhaustStorage = 4546,
                exhaustTime = 10,

                itemId = 2157,10
            }
        ]]>
    </config>

    <talkaction words="!timeleft" event="script">
        <![CDATA[
            domodlib("huntingConfig")

            function onSay(cid, words, param)
                if getCreatureStorage(cid, configHunting.storage) <= 0 then
                    return doPlayerSendCancel(cid, 'Musisz byc w roomie, by zobaczyc pozostaly czas.')
                end
                
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Pozostaly czas do wyrzucenia z roomu to '..getCreatureStorage(cid, configHunting.timeStorage)-os.time()..' sekund.')
                return true
            end
        ]]>
    </talkaction>

    <!-- wyjscie -->
    <movement type="StepIn" actionid="8231" event="script">
        <![CDATA[
            domodlib("huntingConfig")

            function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
                if isPlayer(cid) then
                    for k, v in pairs(huntingConfig) do
                        if isInRange(getThingPos(cid), v.fromPos, v.toPos) then
                            for x = v.fromPos.x, v.toPos.x do
                                for y = v.fromPos.y, v.toPos.y do
                                    doCleanTile({x=x, y=y, z=v.toPos.z})
                                    local t = getTopCreature({x=x, y=y, z=v.toPos.z}).uid
                                    if t ~= 0 then
                                        if isMonster(t) then
                                            doRemoveCreature(t)
                                        end
                                    end
                                end
                            end
                            stopEvent(getCreatureStorage(cid, configHunting.storage))
                            doCreatureSetStorage(cid, configHunting.storage, -1)
                            doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), true)
                            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Zostales wyrzucony z hunting roomu.')
                            break
                        end
                    end
                end
                return true
            end
        ]]>
    </movement>


    <!-- to jest do tworzenia potworow -->
    <movement type="StepIn" actionid="8230" event="script">
        <![CDATA[
            domodlib("huntingConfig")

            function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
                local monsters, player = false, false
                if isPlayer(cid) then
                    for k, v in pairs(huntingConfig) do
                        if isInRange(getThingPos(cid), v.fromPos, v.toPos) then
                            for x = v.fromPos.x, v.toPos.x do
                                for y = v.fromPos.y, v.toPos.y do
                                    doCleanTile({x=x, y=y, z=v.toPos.z})
                                    local t = getTopCreature({x=x, y=y, z=v.toPos.z}).uid
                                    if t ~= 0 then
                                        if isMonster(t) then
                                            monsters = true
                                        end
                                    end
                                end
                            end
                            
                            if monsters then
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Musisz zabic wszystkie potwory, by zrespic kolejne.')
                                doTeleportThing(cid, fromPosition)
                            else
                                if exhaustion.check(cid, configHunting.storageExh) then
                                    doPlayerSendCancel(cid, 'Musisz czekac '..exhaustion.get(cid, configHunting.storageExh)..' sekund, by zsummonowac ponownie potwory.')
                                    doTeleportThing(cid, fromPosition)
                                else
                                    exhaustion.set(cid, configHunting.storageExh, configHunting.exhaust)
                                    doTeleportThing(cid, fromPosition, true)
                                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Potwory zostaly zrespione.')
                                    for i = 1, v.monsters[2] do
                                        doCreateMonster(v.monsters[1], v.teleportPos, false, false, false)
                                    end
                                end
                            end
                            break
                        end
                    end
                end
                return true
            end
        ]]>
    </movement>

    <!-- to jest do wchodzenia do roomow -->
    <movement type="StepIn" actionid="7231-7248" event="script">
        <![CDATA[
            domodlib("huntingConfig")

            function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
                if isPlayer(cid) then
                    if getPlayerItemCount(cid, configHunting.itemId) < 1 then
                        return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'Aby wejsc musisz miec przynajmniej 1 soltrion coins!'), doTeleportThing(cid, fromPosition)
                    end

                    if exhaustion.check(cid, configHunting.exhaustStorage) ~= false then
                        return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'Musisz poczekac ' .. exhaustion.get(cid, configHunting.exhaustStorage) .. ' sec.'), doTeleportThing(cid, fromPosition)
                    end

                    local monsters, player = {}, false
                    for k, v in pairs(huntingConfig) do
                        if v.enteryAid == item.actionid then
                            for x = v.fromPos.x, v.toPos.x do
                                for y = v.fromPos.y, v.toPos.y do
                                    doCleanTile({x=x, y=y, z=v.toPos.z})
                                    local t = getTopCreature({x=x, y=y, z=v.toPos.z}).uid
                                    if t ~= 0 then
                                        if isMonster(t) then
                                            table.insert(monsters, t)
                                        else
                                            if isPlayer(t) then
                                                player = true
                                            end
                                        end
                                    end
                                end
                            end
                            
                            if not player then
                                doTeleportThing(cid, v.teleportPos, true)
                                doPlayerRemoveItem(cid, configHunting.itemId, 1)
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Wszedles do roomu.')

                                local x = addEvent(removePlayerFromRoom, v.expireTime * 1000, cid, configHunting, huntingConfig)
                                doCreatureSetStorage(cid, configHunting.storage, x)
                                doCreatureSetStorage(cid, configHunting.timeStorage, os.time()+v.expireTime)
                                
                                for _, v in ipairs(monsters) do
                                    if isCreature(v) then
                                        doRemoveCreature(v)
                                    end
                                end
                            else
                                doTeleportThing(cid, fromPosition, true)
                                doPlayerSendCancel(cid, 'Ten room jest zajety, wroc pozniej.')
                            end
                            break
                        end
                    end

                    exhaustion.set(cid, configHunting.exhaustStorage, configHunting.exhaustTime)
                end
                return true
            end

            function removePlayerFromRoom(pid, configHunting, huntingConfig)
                if isPlayer(pid) then
                    doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), true)
                    doPlayerSendTextMessage(pid, MESSAGE_STATUS_WARNING, 'Twoj czas sie skonczyl.')
                    doCreatureSetStorage(pid, configHunting.storage, -1)
                end
            end
        ]]>
    </movement>

    <event type="login" name="huntingRoom_login" event="script">
        <![CDATA[
            domodlib("huntingConfig")

            function onLogin(cid)
                registerCreatureEvent(cid, "huntingRoom_death")
                return true
            end
        ]]>
    </event>

    <event type="death" name="huntingRoom_death" event="script">
        <![CDATA[
            domodlib("huntingConfig")

            function onDeath(cid, target, damage, flags)
                if isPlayer(cid) then
                    if getCreatureStorage(cid, configHunting.storage) > 0 then
                        stopEvent(getCreatureStorage(cid, configHunting.storage))
                        doCreatureSetStorage(cid, configHunting.storage, -1)

                        for k, v in pairs(huntingConfig) do
                            if isInRange(getThingPos(cid), v.fromPos, v.toPos) then
                                for x = v.fromPos.x, v.toPos.x do
                                    for y = v.fromPos.y, v.toPos.y do
                                        doCleanTile({x=x, y=y, z=v.toPos.z})
                                        local t = getTopCreature({x=x, y=y, z=v.toPos.z}).uid
                                        if t ~= 0 then
                                            if isMonster(t) then
                                                doRemoveCreature(t)
                                            end
                                        end
                                    end
                                end
                                break
                            end
                        end
                    end
                end
                return true
            end
        ]]>
    </event>
</mod>
 
Just add non-logout zone to arena room in map editor?
Tak mam not logout zone w calej arenie. Tu chodzi o to ze przy restarcie serwera gdy silnik sie wylacza i wlacza to gracz loguje sie na arenie i expi dalej a gdy timeleft czyli czas zejdzie do zera to idzie caly czas na minusie w nieskonczoność i moze expic caly czas bezplatnie.

Yes, I have a not logout zone throughout the arena. The point here is that when the server is restarted, when the engine turns off and on, the player logs in to the arena and expires, and when the timeleft, i.e. time goes down to zero, it goes all the time in the minus for infinity and can expire all the time for free.
 
if I read and understood the code correctly, you should be able to check for storage onLogin.
getCreatureStorage(cid, configHunting.storage)

if it has expired, Tp player to temple or exit pos
 
Last edited:
if I read and understood the code correctly, you should be able to check for storage onLogin.
getCreatureStorage(cid, configHunting.storage)

if it has expired, Tp player to temple or exit pos
Yes, but when the time reaches 0 seconds it starts to drop to the minus
 
Yes, but when the time reaches 0 seconds it starts to drop to the minus
Thats when you know it has expired.

When setting storage, for example; player enters arena for the first time, you set os.time() + expireTime as storage value.
after (os.time()+expireTime) seconds have passed current time will be bigger than the storage value: os.time() > playerStorage which means it's time to teleport player somewhere outside.

.. unless you did it in a different way 🤔
 
Thats when you know it has expired.

When setting storage, for example; player enters arena for the first time, you set os.time() + expireTime as storage value.
after (os.time()+expireTime) seconds have passed current time will be bigger than the storage value: os.time() > playerStorage which means it's time to teleport player somewhere outside.

.. unless you did it in a different way 🤔
I don't have a line (os.time.
There is only expireTime
 
Back
Top