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

Area tfs 0.4 dev.

ok, poprawione już chodziło o addevent wystarczyło do tablicy do każdej areny zerować i problemu już nie ma.
 
#up

prawda jest taka, że w Lua może mieć. I jest to jak najbardziej na miejscu :eek:
jednakże w tym wypadku trzeba wypieprzyć kickEvent poza funkcję onStepIn i podawać kickEventowi inny parametr niż cid- np guid, lub name.
Dlaczego? Cid jest dynamiczne- wystarczy, że gracz przeloguje i sprawa załatwiona.
Wtedy zbierasz sobie prawidłowy cid gracza po guid lub name funkcją getPlayerByGUID lub getCreatureByName i jeśli istnieje takowy, to działasz- jeśli nie, to przerywasz skrypt.

Profit?

[email protected], mój paypal ;]

baardzo ladnie wytlumaczone, dzieki, tak sie czlowiek uczy
 
Mam podobny problem że podczas restartu serwera postac loguje sie na arenie, nie wywala jej do temple po restarcie i czas sie buguje i może wtedy sziedzieć ile chce na arenie.

Oto Mój skrypt:

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>
 
Back
Top