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

Create teleport while killing monterS - How to do?

Now its work perfectly ! šŸ˜

Thanks Master of LUA! :D
Nice!

Feel free to 'give reputation' by liking posts, and remember to choose a "best answer", to let other people know that your issue/request is resolved.
 
I have one more question for you. I am also interested in the teleport (constans on the map) - while you enter other player cant do the same (enter THIS tp for "some time" (for example - 3 minutes).

Will the script be similar? But is it something completely different?
 
I have one more question for you. I am also interested in the teleport (constans on the map) - while you enter other player cant do the same (enter THIS tp for "some time" (for example - 3 minutes).

Will the script be similar? But is it something completely different?
I would create a new thread for that, as those types of scripts can be very simple, or very complex, depending on what exactly you require it to do.
 
Lua:
-- this script is built to be 'globally used'.
-- So all players on the server work towards the goal of unlocking the teleport.

--[[
<event type="kill" name="onKillGlobalTeleportCreation" event="script" value="onKillGlobalTeleportCreation.lua"/>
registerCreatureEvent(cid, "onKillGlobalTeleportCreation")
--]]

local teleport_itemid = 1387
local t = {
    [{"rat", "cave rat"}] = { -- one or more creatures
        storage = 45001, -- global storage value. Change to something currently not in use.
        amount = 10, -- amount of monsters that need to be killed, in order to activate the teleporter
        teleport_position = {x = 1000, y = 1000, z = 7}, -- position that the teleporter will be spawned.
        teleport_destination = {x = 1000, y = 1000, z = 7}, -- position that the teleporter will take you to.
        time_until_remove = 10, -- time in SECONDS until teleport is removed.
        delay_between_activations = 10 -- time in MINUTES before the teleport can be re-activated again. (aka: reset)
    },

    [{"rat"}] = {
        storage = 45002,
        amount = 10,
        teleport_position = {x = 1000, y = 1000, z = 7},
        teleport_destination = {x = 1000, y = 1000, z = 7},
        time_until_remove = 10,
        delay_between_activations = 10
    },
    
    -- can put it like above, or 'condensed' like below.
    [{"rat", "cave rat"}] = {storage = 45003, amount = 10, teleport_position = {x = 1000, y = 1000, z = 7}, teleport_destination = {x = 1000, y = 1000, z = 7}, time_until_remove = 10, delay_between_activations = 10},
    [{"cave rat"}] = {storage = 45004, amount = 10, teleport_position = {x = 1000, y = 1000, z = 7}, teleport_destination = {x = 1000, y = 1000, z = 7}, time_until_remove = 10, delay_between_activations = 10},
    [{"rat"}] = {storage = 45005, amount = 10, teleport_position = {x = 1000, y = 1000, z = 7}, teleport_destination = {x = 1000, y = 1000, z = 7}, time_until_remove = 10, delay_between_activations = 10}
}

local function delayedTeleportRemoval(position)
    local teleport = getTileItemById(position, teleport_itemid).uid
    if teleport > 0 then
        doRemoveItem(teleport)
        doSendMagicEffect(position, CONST_ME_POFF)
    end
    return true
end

function onKill(cid, target, damage, flags)
    for v, k in pairs(t) do
        local master = getCreatureMaster(target)
        if master and master ~= target then
            return true
        end
        if bit.band(flags, 1) == 1 and isMonster(target) and isInArray(v, getCreatureName(target):lower()) then
            local g_storage, cur_time = getGlobalStorageValue(k.storage), os.time()
            if g_storage == -1 or g_storage > k.amount and cur_time > g_storage then
                setGlobalStorageValue(k.storage, 0)
                g_storage = 0
            end
            if g_storage <= k.amount then
                setGlobalStorageValue(k.storage, g_storage + 1)
                g_storage = g_storage + 1
            end
            if g_storage == k.amount then
                setGlobalStorageValue(k.storage, cur_time + (60 * k.delay_between_activations))
                doCreateTeleport(teleport_itemid, k.teleport_destination, k.teleport_position)
                addEvent(delayedTeleportRemoval, 1000 * k.time_until_remove, k.teleport_position)
            end
        end
    end
    return true
end
what tfs version this script?
 
Back
Top