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

Lua After kill mob teleport appears -PROBLEM-

equero

New Member
Joined
Feb 22, 2013
Messages
51
Reaction score
1
Hello.
I have just read these post and nothing works.
I mean teleport's not showing after monster kill.
Can someone resolve this problem. I'm done...
I have found on my old server this code but he does not work tho.
sorry for my english

Lua:
function onDeath(cid, corpse, killer)
registerCreatureEvent(cid, "Grand War Golem")
local creaturename = getCreatureName(cid)
--- place where tp will be created
local pos1 = {x=788, y=1213, z=10, stackpos=2}
--- position to teleport?:
local pos2 = {x=796, y=1242, z=7, stackpos=1}
local time_to_pass = 180 -- time to disappear
local tpID = 5023
local doEffect = CONST_ME_ENERGYHIT
local message = "Done! You got 3 mins.."
if creaturename == 'Grand War Golem' then
teleport = doCreateTeleport(tpID, pos2, pos1)
doSendMagicEffect(pos1, doEffect)
doCreatureSay(cid, message, TALKTYPE_ORANGE_1)
addEvent(removeTeleportInBossWard, (1000*time_to_pass))
end
end
function removeTeleportInBossWard()
--- place where tp will be created
if getThingfromPos({x=788, y=1213, z=10, stackpos=1}).itemid == 5023 then
--- miejsce gdzie tp zostanie utworzone
doRemoveItem(getThingfromPos({x=788, y=1213, z=10, stackpos=1}).uid,1)
--- place where tp will be created
doSendMagicEffect({x=788, y=1213, z=10, stackpos=1}, CONST_ME_POFF)
return TRUE
end
end

XML:
<event type="death" name="Grand War Golem" script="grand war golem.lua"/>
 
Solution
E
have you registered the script on the monster .xml file?

XML:
<script>
        <event name="Grand War Golem" />
    </script>
Do you think i need to recompile Or Maybe change The tfs?
Post automatically merged:

@mackerel could you link The TFS1.3 so i can try to change?

You can try compiling latest TFS and see if that works for you :D

Here is wiki on how-to-compile: Link (Windows (with vcpkg) worked for me)

Just create new folder and follow the instructions, it will download all necessary source files for you
 
Can you maybe try this, but change your coordinates in the script
Lua:
local tpId = 5023
local tps = {
        ["Grand War Golem"] = {pos = {x=553, y=674, z=7}, toPos = {x=553, y=666, z=4}, time = 50},
}

function removeTp(tp)
        local t = getTileItemById(tp.pos, tpId)
        if t then
                doRemoveItem(t.uid, 1)
                doSendMagicEffect(tp.pos, CONST_ME_POFF)
        end
end

function onDeath(cid)
        local tp = tps[getCreatureName(cid)]
        if tp then
                doCreateTeleport(tpId, tp.toPos, tp.pos)
                doCreatureSay(cid, "Teleport will dissapear in "..tp.time.." seconds.", TALKTYPE_ORANGE_1)
                addEvent(removeTp, tp.time*1000, tp)
        end
        return TRUE
end

and in creaturescripts.xml:
XML:
<event type="death" name="deadwargolem" event="script" value="deadwargolem.lua"/>
 
Can you maybe try this, but change your coordinates in the script
Lua:
local tpId = 5023
local tps = {
        ["Grand War Golem"] = {pos = {x=553, y=674, z=7}, toPos = {x=553, y=666, z=4}, time = 50},
}

function removeTp(tp)
        local t = getTileItemById(tp.pos, tpId)
        if t then
                doRemoveItem(t.uid, 1)
                doSendMagicEffect(tp.pos, CONST_ME_POFF)
        end
end

function onDeath(cid)
        local tp = tps[getCreatureName(cid)]
        if tp then
                doCreateTeleport(tpId, tp.toPos, tp.pos)
                doCreatureSay(cid, "Teleport will dissapear in "..tp.time.." seconds.", TALKTYPE_ORANGE_1)
                addEvent(removeTp, tp.time*1000, tp)
        end
        return TRUE
end

and in creaturescripts.xml:
XML:
<event type="death" name="deadwargolem" event="script" value="deadwargolem.lua"/>

Didnt work, and no errors in console either...
Post automatically merged:

Some bosses ??

Here's working example for 1.3

data/creaturescripts/scripts/nin.lua
Lua:
local enemyNames = {
    [1] = "Bazir",
    [2] = "Bazir's dad"
}

local function removeTeleport(position)
    local spawnedTeleport = Tile(position):getItemById(17868)
    if spawnedTeleport then
        spawnedTeleport:remove()
        position:sendMagicEffect(CONST_ME_POFF)
    end
  
    return true
end

local function formatString(s)
    s = string.gsub(s, "[%d%p%c%s]", "")
    s = s:lower()
  
    return s
end

function onKill(creature, target)
    if not target or not target:isMonster() then
        return true
    end
  
    local f = false
    local t = formatString(target:getName())
    for _, v in ipairs(enemyNames) do
        if t == formatString(v) then
            f = true
        end
    end
  
    if not f then
        return true
    end

    local teleportSpawn = Position(2181, 1220, 7) -- Position for teleport to spawn
    removeTeleport(teleportSpawn)
    teleportSpawn:sendMagicEffect(CONST_ME_TELEPORT)
  
    local item = Game.createItem(17868, 1, teleportSpawn)
    if item:isTeleport() then
        local teleportTo = Position(2177, 1222, 7) -- Teleport destination
        item:setDestination(teleportTo)
    end

    target:say('Take the teleport before it/s too late!', TALKTYPE_MONSTER_SAY, 0, 0, teleportSpawn)
    addEvent(removeTeleport, 60000, teleportSpawn)
  
    return true
end

data/creaturescripts/scripts/login.lua
Lua:
function onLogin(player)
    local loginStr = "Welcome to " .. configManager.getString(configKeys.SERVER_NAME) .. "!"
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. " Please choose your outfit."
        player:sendOutfitWindow()
    else
        if loginStr ~= "" then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end

        loginStr = string.format("Your last visit was on %s.", os.date("%a %b %d %X %Y", player:getLastLoginSaved()))
    end
    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

    -- Stamina
    nextUseStaminaTime[player.uid] = 0

    -- Promotion
    local vocation = player:getVocation()
    local promotion = vocation:getPromotion()
    if player:isPremium() then
        local value = player:getStorageValue(PlayerStorageKeys.promotion)
        if not promotion and value ~= 1 then
            player:setStorageValue(PlayerStorageKeys.promotion, 1)
        elseif value == 1 then
            player:setVocation(promotion)
        end
    elseif not promotion then
        player:setVocation(vocation:getDemotion())
    end

    -- Events
    player:registerEvent("PlayerDeath")
    player:registerEvent("DropLoot")
    player:registerEvent("nin")
    return true
end


data/creaturescripts/creaturescripts.xml (Add at the top after '<creaturescripts>' line)
XML:
<event type="kill" name="nin" script="nin.lua" />

Now all of a sudden the script works!! Thanks
 
Last edited:
Hello guys, tested the second script, works for TFS 1.4.

Someone could help to add more monsters and more portal locations?, so one script can open portals in diferent places for diferent bosses.

thanks for the script :0

Didnt work, and no errors in console either...
Post automatically merged:



Now all of a sudden the script works!! Thanks
 
Back
Top