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

Vivelo

New Member
Joined
Aug 30, 2018
Messages
34
Reaction score
3
Hello,
I don't know how to write a script that will open a portal after killing a few monsters, not just one type of "Boss".

I have "standard" .lua without any options/commands of this.

Lua:
local config = {
    useCountdown = true
}

local t = {
    ["dog"] = {
        toPos = {x = 1275, y = 1053, z = 7, stackpos = 0},
        createPos = {x = 1277, y = 1053, z = 7, stackpos = 0},
        time = 10,
        msg = "You have taken my life!"
    },
    ["cat"] = {
        toPos = 'Venore',
        createPos = {x = 100, y = 100, z = 7, stackpos = 0},
        time = 10,
        msg = "You have taken my life!"
    }
}

local function remove(position)
    local k = getTileItemById(position, 1387).uid
    return k > 0 and doRemoveItem(k), doSendMagicEffect(position, CONST_ME_POFF)
end

local function doSendAnimatedText(pos, text, color, cid) -- by J.Dre
    if tonumber(text) then
        text = tonumber(text)
        if cid and isPlayer(cid) then
            doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE_OTHERS, "", text, color, pos)
        else
            local t = getSpectators(pos, 7, 5, false)
            if t then
                for _, cid in ipairs(t) do
                    if isPlayer(cid) then
                        doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE_OTHERS, "", text, color, pos)
                    end
                end
            end
        end
    else
        if cid and isCreature(cid) then
            doCreatureSay(cid, text, TALKTYPE_MONSTER)
        else
            local t = getSpectators(pos, 7, 5, false)
            if t then
                for _, cid in ipairs(t) do
                    if isPlayer(cid) then
                        doCreatureSay(cid, text, TALKTYPE_MONSTER, false, cid, pos)
                    end
                end
            end
        end
    end
end

function onKill(cid, target, damage, flags)
    local v = t[string.lower(getCreatureName(target))]
    if(v and (damage == true or bit.band(flags, 1) == 1) and isMonster(target)) then
        doCreatureSay(cid, v.msg, TALKTYPE_MONSTER, nil, nil, getCreaturePosition(target))
        doSendMagicEffect(v.createPos, CONST_ME_ENERGYAREA)
        doCreateTeleport(1387, type(v.toPos) == 'table' and v.toPos or getTownTemplePosition(getTownId(v.toPos)), v.createPos)
        if(config.useCountdown) then
            for j = 0, v.time do
                local i = v.time - j
                addEvent(doSendAnimatedText, j * 1000, v.createPos, i > 0 and tostring(i), MESSAGE_EVENT_DEFAULT)
            end
        end
        addEvent(remove, v.time * 1000, v.createPos)
    end

    return true
end

at the start i thinking about add to this line ( ["dog"] = { )operator "AND" but nothing happen. After that i try to compile this code with a code that determines the amounts of kills of a given type of monster and only opens the portal, but also nothing.

I need one of the two versions ...

First Version:
- You must kill "X" monsters of the same type, like rats.

Second Version:
- You must kill "X" monsters different types, like 3 rats and 6 rotworms, 11 skeleton and 1 mini boss.

I need this to create "dungeon".

THANKS FOR ANY HELP!
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,522
Solutions
378
Reaction score
3,638
Hello,
I don't know how to write a script that will open a portal after killing a few monsters, not just one type of "Boss".

I have "standard" .lua without any options/commands of this.

Lua:
local config = {
    useCountdown = true
}

local t = {
    ["dog"] = {
        toPos = {x = 1275, y = 1053, z = 7, stackpos = 0},
        createPos = {x = 1277, y = 1053, z = 7, stackpos = 0},
        time = 10,
        msg = "You have taken my life!"
    },
    ["cat"] = {
        toPos = 'Venore',
        createPos = {x = 100, y = 100, z = 7, stackpos = 0},
        time = 10,
        msg = "You have taken my life!"
    }
}

local function remove(position)
    local k = getTileItemById(position, 1387).uid
    return k > 0 and doRemoveItem(k), doSendMagicEffect(position, CONST_ME_POFF)
end

local function doSendAnimatedText(pos, text, color, cid) -- by J.Dre
    if tonumber(text) then
        text = tonumber(text)
        if cid and isPlayer(cid) then
            doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE_OTHERS, "", text, color, pos)
        else
            local t = getSpectators(pos, 7, 5, false)
            if t then
                for _, cid in ipairs(t) do
                    if isPlayer(cid) then
                        doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE_OTHERS, "", text, color, pos)
                    end
                end
            end
        end
    else
        if cid and isCreature(cid) then
            doCreatureSay(cid, text, TALKTYPE_MONSTER)
        else
            local t = getSpectators(pos, 7, 5, false)
            if t then
                for _, cid in ipairs(t) do
                    if isPlayer(cid) then
                        doCreatureSay(cid, text, TALKTYPE_MONSTER, false, cid, pos)
                    end
                end
            end
        end
    end
end

function onKill(cid, target, damage, flags)
    local v = t[string.lower(getCreatureName(target))]
    if(v and (damage == true or bit.band(flags, 1) == 1) and isMonster(target)) then
        doCreatureSay(cid, v.msg, TALKTYPE_MONSTER, nil, nil, getCreaturePosition(target))
        doSendMagicEffect(v.createPos, CONST_ME_ENERGYAREA)
        doCreateTeleport(1387, type(v.toPos) == 'table' and v.toPos or getTownTemplePosition(getTownId(v.toPos)), v.createPos)
        if(config.useCountdown) then
            for j = 0, v.time do
                local i = v.time - j
                addEvent(doSendAnimatedText, j * 1000, v.createPos, i > 0 and tostring(i), MESSAGE_EVENT_DEFAULT)
            end
        end
        addEvent(remove, v.time * 1000, v.createPos)
    end

    return true
end

at the start i thinking about add to this line ( ["dog"] = { )operator "AND" but nothing happen. After that i try to compile this code with a code that determines the amounts of kills of a given type of monster and only opens the portal, but also nothing.

I need one of the two versions ...

First Version:
- You must kill "X" monsters of the same type, like rats.

Second Version:
- You must kill "X" monsters different types, like 3 rats and 6 rotworms, 11 skeleton and 1 mini boss.

I need this to create "dungeon".

THANKS FOR ANY HELP!
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
 
Last edited:
OP
Vivelo

Vivelo

New Member
Joined
Aug 30, 2018
Messages
34
Reaction score
3
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)) then
            local g_storage, cur_time = getGlobalStorageValue(k.storage), os.time()
            if g_storage == -1 or 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

Where i must put this?
<event type="kill" name="onKillGlobalTeleportCreation" event="script" value="onKillGlobalTeleportCreation.lua"/> - I dont have Event.xml only global events. (OK THIS LINE IN Creaturescripts.XML - found it)

registerCreatureEvent(cid, "onKillGlobalTeleportCreation") - this line i put 2 weekes ago for something else and now dont remeber where i must put it. AYAYAYA.... I have temporary eclipse of the mind XDDD (Login.lua this line)
 
Last edited:

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,522
Solutions
378
Reaction score
3,638
Where i must put this?
<event type="kill" name="onKillGlobalTeleportCreation" event="script" value="onKillGlobalTeleportCreation.lua"/> - I dont have Event.xml only global events. (OK THIS LINE IN Creaturescripts.XML - found it)

registerCreatureEvent(cid, "onKillGlobalTeleportCreation") - this line i put 2 weekes ago for something else and now dont remeber where i must put it. AYAYAYA....
data/creaturescripts/creaturescripts.xml
XML:
<event type="kill" name="onKillGlobalTeleportCreation" event="script" value="onKillGlobalTeleportCreation.lua"/>
data/creaturescripts/scripts/login.lua [near the bottom with the other registered events]
Lua:
registerCreatureEvent(cid, "onKillGlobalTeleportCreation")
 
OP
Vivelo

Vivelo

New Member
Joined
Aug 30, 2018
Messages
34
Reaction score
3
data/creaturescripts/creaturescripts.xml
XML:
<event type="kill" name="onKillGlobalTeleportCreation" event="script" value="onKillGlobalTeleportCreation.lua"/>
data/creaturescripts/scripts/login.lua [near the bottom with the other registered events]
Lua:
registerCreatureEvent(cid, "onKillGlobalTeleportCreation")
haha yeah i found it!
But unfortunately not working :/
 
OP
Vivelo

Vivelo

New Member
Joined
Aug 30, 2018
Messages
34
Reaction score
3
You're going to need to give me more then that buddy.

Is there an error?

I want but unfortunately nothing is happening.

XML:
Lua:
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
    <event type="login" name="PlayerLogin" event="script" value="login.lua"/>

    <event type="joinchannel" name="GuildMotd" event="script" value="guildmotd.lua"/>
    <event type="receivemail" name="Mail" event="script" value="mail.lua"/>
    <event type="reportbug" name="SaveReportBug" script="reportbug.lua"/>
    <event type="advance" name="AdvanceSave" event="script" value="advancesave.lua"/>
    <event type="kill" name="onKillGlobalTeleportCreation" event="script" value="onKillGlobalTeleportCreation.lua"/>
    <event type="think" name="Idle" event="script" value="idle.lua"/>
    <event type="think" name="SkullCheck" event="script" value="skullcheck.lua"/>
</creaturescripts>

login.lua
Code:
local config = {
    loginMessage = getConfigValue('loginMessage'),
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
    elseif(accountManager == MANAGER_ACCOUNT) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end

    registerCreatureEvent(cid, "Mail")
    registerCreatureEvent(cid, "GuildMotd")

    registerCreatureEvent(cid, "Idle")
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
    end

    registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "AdvanceSave")
    registerCreatureEvent(cid, "onKillGlobalTeleportCreation")
    
    return true
end

onKill~.lua - I tried this code and fully copied from you, and nothing.

Code:
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 = 3, -- amount of monsters that need to be killed, in order to activate the teleporter
        teleport_position = {x = 1277 y = 1053, z = 7}, -- position that the teleporter will be spawned.
        teleport_destination = {x = 1277 y = 1054, 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)
    }
    }

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)) then
            local g_storage, cur_time = getGlobalStorageValue(k.storage), os.time()
            if g_storage == -1 or 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
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,522
Solutions
378
Reaction score
3,638
I want but unfortunately nothing is happening.

XML:
Lua:
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
    <event type="login" name="PlayerLogin" event="script" value="login.lua"/>

    <event type="joinchannel" name="GuildMotd" event="script" value="guildmotd.lua"/>
    <event type="receivemail" name="Mail" event="script" value="mail.lua"/>
    <event type="reportbug" name="SaveReportBug" script="reportbug.lua"/>
    <event type="advance" name="AdvanceSave" event="script" value="advancesave.lua"/>
    <event type="kill" name="onKillGlobalTeleportCreation" event="script" value="onKillGlobalTeleportCreation.lua"/>
    <event type="think" name="Idle" event="script" value="idle.lua"/>
    <event type="think" name="SkullCheck" event="script" value="skullcheck.lua"/>
</creaturescripts>

login.lua
Code:
local config = {
    loginMessage = getConfigValue('loginMessage'),
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
    elseif(accountManager == MANAGER_ACCOUNT) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end

    registerCreatureEvent(cid, "Mail")
    registerCreatureEvent(cid, "GuildMotd")

    registerCreatureEvent(cid, "Idle")
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
    end

    registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "AdvanceSave")
    registerCreatureEvent(cid, "onKillGlobalTeleportCreation")
 
    return true
end

onKill~.lua - I tried this code and fully copied from you, and nothing.

Code:
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 = 3, -- amount of monsters that need to be killed, in order to activate the teleporter
        teleport_position = {x = 1277 y = 1053, z = 7}, -- position that the teleporter will be spawned.
        teleport_destination = {x = 1277 y = 1054, 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)
    }
    }

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)) then
            local g_storage, cur_time = getGlobalStorageValue(k.storage), os.time()
            if g_storage == -1 or 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
Try this. and tell me what prints to the console. (black rectangle)
Lua:
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 = 3, -- amount of monsters that need to be killed, in order to activate the teleporter
        teleport_position = {x = 1277 y = 1053, z = 7}, -- position that the teleporter will be spawned.
        teleport_destination = {x = 1277 y = 1054, 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)
    }
}

local function delayedTeleportRemoval(position)
    print("attempting to find and remove teleport..")
    local teleport = getTileItemById(position, teleport_itemid).uid
    if teleport > 0 then
        print("teleport found. Removing..")
        doRemoveItem(teleport)
        doSendMagicEffect(position, CONST_ME_POFF)
        print("teleport removed.")
    end
    return true
end

function onKill(cid, target, damage, flags)
    print("-----------------")
    print("something is happening.")
    for v, k in pairs(t) do
        print("checking creature...")
        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
            print("creature is not a summon, is a monster, and is in the table.")
            local g_storage, cur_time = getGlobalStorageValue(k.storage), os.time()
            print("g_storage = " .. g_storage)
            print("cur_time = " .. cur_time)
            if g_storage == -1 or cur_time > g_storage then
                print("storage reset.")
                setGlobalStorageValue(k.storage, 0)
                g_storage = 0
            end
            print("g_storage = " .. g_storage)
            print("k.amount = " .. k.amount)
            if g_storage <= k.amount then
                print("storage value increased.")
                setGlobalStorageValue(k.storage, g_storage + 1)
                g_storage = g_storage + 1
            end
            print("g_storage = " .. g_storage)
            print("k.amount = " .. k.amount)
            if g_storage == k.amount then
                print("storage value transformed into timer.")
                setGlobalStorageValue(k.storage, cur_time + (60 * k.delay_between_activations))
                print("teleport created.")
                doCreateTeleport(teleport_itemid, k.teleport_destination, k.teleport_position)
                print("addEvent started.")
                addEvent(delayedTeleportRemoval, 1000 * k.time_until_remove, k.teleport_position)
            end
        end
    end
    print("script finished successfully.")
    return true
end
 
Last edited:

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,522
Solutions
378
Reaction score
3,638
yeah, this is your fault. xD
While editing, you removed the ,,,,

change
Lua:
teleport_position = {x = 1277 y = 1053, z = 7}, -- position that the teleporter will be spawned.
teleport_destination = {x = 1277 y = 1054, z = 7}, -- position that the teleporter will take you to.
to
Lua:
teleport_position = {x = 1277, y = 1053, z = 7}, -- position that the teleporter will be spawned.
teleport_destination = {x = 1277, y = 1054, z = 7}, -- position that the teleporter will take you to.
 
OP
Vivelo

Vivelo

New Member
Joined
Aug 30, 2018
Messages
34
Reaction score
3
yeah, this is your fault. xD
While editing, you removed the ,,,,

change
Lua:
teleport_position = {x = 1277 y = 1053, z = 7}, -- position that the teleporter will be spawned.
teleport_destination = {x = 1277 y = 1054, z = 7}, -- position that the teleporter will take you to.
to
Lua:
teleport_position = {x = 1277, y = 1053, z = 7}, -- position that the teleporter will be spawned.
teleport_destination = {x = 1277, y = 1054, z = 7}, -- position that the teleporter will take you to.

OMG XDDDD Sorry for that, BUT....

1596403685307.png

Still i dont have a teleport :D
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,522
Solutions
378
Reaction score
3,638
OMG XDDDD Sorry for that, BUT....

View attachment 47996

Still i dont have a teleport :D
okay, let's print even more information. xD
Lua:
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 = 3, -- amount of monsters that need to be killed, in order to activate the teleporter
        teleport_position = {x = 1277, y = 1053, z = 7}, -- position that the teleporter will be spawned.
        teleport_destination = {x = 1277, y = 1054, 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)
    }
}

local function delayedTeleportRemoval(position)
    print("attempting to find and remove teleport..")
    local teleport = getTileItemById(position, teleport_itemid).uid
    if teleport > 0 then
        print("teleport found. Removing..")
        doRemoveItem(teleport)
        doSendMagicEffect(position, CONST_ME_POFF)
        print("teleport removed.")
    end
    return true
end

function onKill(cid, target, damage, flags)
    print("-----------------")
    print("something is happening.")
    for v, k in pairs(t) do
        print("checking creature...")
        local master = getCreatureMaster(target)
        if master and master ~= target then
            print("creature is a summon. Script ending prematurely.")
            return true
        end
        print("creature is not a summon.")
        if bit.band(flags, 1) == 1 then
            print("cid is the killer of this monster.")
            if isMonster(target) then
                print("target is a monster.")
                print("getCreatureName(target):lower() = " .. getCreatureName(target):lower())
                if isInArray(v, getCreatureName(target):lower()) then
                    print(" monster is in the table.")
                    local g_storage, cur_time = getGlobalStorageValue(k.storage), os.time()
                    print("g_storage = " .. g_storage)
                    print("cur_time = " .. cur_time)
                    if g_storage == -1 or cur_time > g_storage then
                        print("storage reset.")
                        setGlobalStorageValue(k.storage, 0)
                        g_storage = 0
                    end
                    print("g_storage = " .. g_storage)
                    print("k.amount = " .. k.amount)
                    if g_storage <= k.amount then
                        print("storage value increased.")
                        setGlobalStorageValue(k.storage, g_storage + 1)
                        g_storage = g_storage + 1
                    end
                    print("g_storage = " .. g_storage)
                    print("k.amount = " .. k.amount)
                    if g_storage == k.amount then
                        print("storage value transformed into timer.")
                        setGlobalStorageValue(k.storage, cur_time + (60 * k.delay_between_activations))
                        print("teleport created.")
                        doCreateTeleport(teleport_itemid, k.teleport_destination, k.teleport_position)
                        print("addEvent started.")
                        addEvent(delayedTeleportRemoval, 1000 * k.time_until_remove, k.teleport_position)
                    end
                end
            end
        end
    end
    print("script finished successfuly.")
    return true
end
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,522
Solutions
378
Reaction score
3,638
I have TFS 0.3.6 :p
Okay so that's the issue then lol

we need to use
onKill(cid, target, lastHit)

and this is why we post the server version in the first post... xD
Lua:
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 = 3, -- amount of monsters that need to be killed, in order to activate the teleporter
        teleport_position = {x = 1277, y = 1053, z = 7}, -- position that the teleporter will be spawned.
        teleport_destination = {x = 1277, y = 1054, 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)
    }
}

local function delayedTeleportRemoval(position)
    print("attempting to find and remove teleport..")
    local teleport = getTileItemById(position, teleport_itemid).uid
    if teleport > 0 then
        print("teleport found. Removing..")
        doRemoveItem(teleport)
        doSendMagicEffect(position, CONST_ME_POFF)
        print("teleport removed.")
    end
    return true
end

function onKill(cid, target, lastHit)
    print("-----------------")
    print("something is happening.")
    print("checking creature...")
    local master = getCreatureMaster(target)
    if master and master ~= target then
        print("creature is a summon. Ending script prematurely.")
        return true
    end
    print("creature is not a summon.")
    for v, k in pairs(t) do
        if lastHit then
            print("cid is the killer of this monster.")
            if isMonster(target) then
                print("target is a monster.")
                print("getCreatureName(target):lower() = " .. getCreatureName(target):lower())
                if isInArray(v, getCreatureName(target):lower()) then
                    print(" monster is in the table.")
                    local g_storage, cur_time = getGlobalStorageValue(k.storage), os.time()
                    print("g_storage = " .. g_storage)
                    print("cur_time = " .. cur_time)
                    if g_storage == -1 or cur_time > g_storage then
                        print("storage reset.")
                        setGlobalStorageValue(k.storage, 0)
                        g_storage = 0
                    end
                    print("g_storage = " .. g_storage)
                    print("k.amount = " .. k.amount)
                    if g_storage <= k.amount then
                        print("storage value increased.")
                        setGlobalStorageValue(k.storage, g_storage + 1)
                        g_storage = g_storage + 1
                    end
                    print("g_storage = " .. g_storage)
                    print("k.amount = " .. k.amount)
                    if g_storage == k.amount then
                        print("storage value transformed into timer.")
                        setGlobalStorageValue(k.storage, cur_time + (60 * k.delay_between_activations))
                        print("teleport created.")
                        doCreateTeleport(teleport_itemid, k.teleport_destination, k.teleport_position)
                        print("addEvent started.")
                        addEvent(delayedTeleportRemoval, 1000 * k.time_until_remove, k.teleport_position)
                    end
                end
            end
        end
    end
    print("script finished successfuly.")
    return true
end
 
OP
Vivelo

Vivelo

New Member
Joined
Aug 30, 2018
Messages
34
Reaction score
3
Ups...I Will remember for the future! 😱

1596404841120.png

Still dont have tp :p
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,522
Solutions
378
Reaction score
3,638
I kill maybe 10 or more :D But i send you only this (up) fragment :D


Bigger here please XD :

View attachment 48001
I failed some logic. xP

Should work now.
Lua:
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 = 3, -- amount of monsters that need to be killed, in order to activate the teleporter
        teleport_position = {x = 1277, y = 1053, z = 7}, -- position that the teleporter will be spawned.
        teleport_destination = {x = 1277, y = 1054, 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)
    }
}

local function delayedTeleportRemoval(position)
    print("attempting to find and remove teleport..")
    local teleport = getTileItemById(position, teleport_itemid).uid
    if teleport > 0 then
        print("teleport found. Removing..")
        doRemoveItem(teleport)
        doSendMagicEffect(position, CONST_ME_POFF)
        print("teleport removed.")
    end
    return true
end

function onKill(cid, target, lastHit)
    print("-----------------")
    print("something is happening.")
    print("checking creature...")
    local master = getCreatureMaster(target)
    if master and master ~= target then
        print("creature is a summon. Ending script prematurely.")
        return true
    end
    print("creature is not a summon.")
    for v, k in pairs(t) do
        if lastHit then
            print("cid is the killer of this monster.")
            if isMonster(target) then
                print("target is a monster.")
                print("getCreatureName(target):lower() = " .. getCreatureName(target):lower())
                if isInArray(v, getCreatureName(target):lower()) then
                    print(" monster is in the table.")
                    local g_storage, cur_time = getGlobalStorageValue(k.storage), os.time()
                    print("g_storage = " .. g_storage)
                    print("cur_time = " .. cur_time)
                    if g_storage == -1 or g_storage > k.amount and cur_time > g_storage then
                        print("storage reset.")
                        setGlobalStorageValue(k.storage, 0)
                        g_storage = 0
                    end
                    print("g_storage = " .. g_storage)
                    print("k.amount = " .. k.amount)
                    if g_storage <= k.amount then
                        print("storage value increased.")
                        setGlobalStorageValue(k.storage, g_storage + 1)
                        g_storage = g_storage + 1
                    end
                    print("g_storage = " .. g_storage)
                    print("k.amount = " .. k.amount)
                    if g_storage == k.amount then
                        print("storage value transformed into timer.")
                        setGlobalStorageValue(k.storage, cur_time + (60 * k.delay_between_activations))
                        print("teleport created.")
                        doCreateTeleport(teleport_itemid, k.teleport_destination, k.teleport_position)
                        print("addEvent started.")
                        addEvent(delayedTeleportRemoval, 1000 * k.time_until_remove, k.teleport_position)
                    end
                end
            end
        end
    end
    print("script finished successfuly.")
    return true
end
 
Top