• 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 (OTHIRE) Monster die and transform in a teleport

massuco

Brazilian, sorry for my bad english XD
Joined
Feb 17, 2013
Messages
199
Solutions
8
Reaction score
22
Location
Brasil
Hello, as the tittle says, I have one monster and want to when he dies, he transform on one teleport, not on a corpse.

I am using OTHire and get this script.
Lua:
local bosses = {
        ["rat"] = { x = 1146, y = 981, z = 7 }                
}
local time = 30 -- Seconds
function onKill(cid, target, lastHit, fromPosition)
        for name, pos in pairs(bosses) do
                if (name == getCreatureName(target):lower()) then
                       
                        doCreateTeleport(1387, pos[1], getThingPos(uid))
                        addEvent(doRemoveItem, tpTime * 1000, getTileItemById(pos[2], 1387).uid, 1)
                end
        end
        return true
end

I have registered on login.lua of creaturescripts and on the monster script, but on the monster die, I get the error:
Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/monsterPortals.lua:onKill

LuaScriptInterface::luaGetThingPos(). Thing not found

Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/monsterPortals.lua:onKill

attempt to index a nil value
stack traceback:
        [C]: in function 'doCreateTeleport'
        data/creaturescripts/scripts/monsterPortals.lua:10: in function <data/creaturescripts/scripts/monsterPortals.lua:6>
I dont know how to make this line works:
Lua:
doCreateTeleport(1387, pos[1], getThingPos(uid))

I know that the function doCreateTeleport on OThire have the params:
Lua:
doCreateTeleport(teleportID, positionToGo, createPosition)
teleportID = 1387
positionToGo is the position configured on the script
createPosition is the position that monster died.

Any ideias?
 
these are the problems i see

doCreateTeleport(1387, pos[1], getThingPos(uid))

addEvent(doRemoveItem, tpTime * 1000, getTileItemById(pos[2], 1387).uid, 1)
 
these are the problems i see

doCreateTeleport(1387, pos[1], getThingPos(uid))

addEvent(doRemoveItem, tpTime * 1000, getTileItemById(pos[2], 1387).uid, 1)
I know that this lines have problem, but I dont know how to fix it xD
 
doCreateTeleport(1387, pos, getThingPos(target.uid))
addEvent(doRemoveItem, tpTime * 1000, getTileItemById(getThingPos(target.uid), 1387).uid, 1)
 
doCreateTeleport(1387, pos, getThingPos(target.uid))
addEvent(doRemoveItem, tpTime * 1000, getTileItemById(getThingPos(target.uid), 1387).uid, 1)
Dont work, then Ive changed getThingPos(target.uid) for getThingPos(target), And worked!

But the teleport dont disappear after the time
I got this error:
Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/monsterPortals.lua:onKill

data/creaturescripts/scripts/monsterPortals.lua:11: attempt to perform arithmetic on global 'tpTime' (a nil value)
stack traceback:
        data/creaturescripts/scripts/monsterPortals.lua:11: in function <data/creaturescripts/scripts/monsterPortals.lua:6>
 
uids are constantly being changed
this should work (not tested)
Lua:
local function remove(pos, itemId)
    local item = getTileItemById(pos, itemId)
    if (item.uid > 0) then
        doRemoveItem(item.uid, 1)
    end
end

local bosses = {
        ["rat"] = { x = 1146, y = 981, z = 7 }              
}

local time = 30 -- Seconds
function onKill(cid, target, lastHit, fromPosition)
        for name, pos in pairs(bosses) do
                if (name == getCreatureName(target):lower()) then
                     
                        doCreateTeleport(1387, pos[1], getThingPos(uid))
                        addEvent(remove, tpTime * 1000, pos[2], 1387)
                end
        end
        return true
end
 
What is the current script you got and the error?
error:
Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/monsterPortals.lua:onKill

data/creaturescripts/scripts/monsterPortals.lua:11: attempt to perform arithmetic on global 'tpTime' (a nil value)
stack traceback:
        data/creaturescripts/scripts/monsterPortals.lua:11: in function <data/creaturescripts/scripts/monsterPortals.lua:6>

script:
Lua:
local bosses = {
        ["rat"] = { x = 1146, y = 981, z = 7 }                
}
local time = 1 -- Seconds
function onKill(cid, target, lastHit, fromPosition)
        for name, pos in pairs(bosses) do
                if (name == getCreatureName(target):lower()) then
                       
                     doCreateTeleport(1387, pos, getThingPos(target))
                    addEvent(doRemoveItem, tpTime * 1000, getTileItemById(getThingPos(target), 1387).uid, 1)
                end
        end
        return true
end
uids are constantly being changed
this should work (not tested)
Lua:
local function remove(pos, itemId)
    local item = getTileItemById(pos, itemId)
    if (item.uid > 0) then
        doRemoveItem(item.uid, 1)
    end
end

local bosses = {
        ["rat"] = { x = 1146, y = 981, z = 7 }             
}

local time = 30 -- Seconds
function onKill(cid, target, lastHit, fromPosition)
        for name, pos in pairs(bosses) do
                if (name == getCreatureName(target):lower()) then
                    
                        doCreateTeleport(1387, pos[1], getThingPos(uid))
                        addEvent(remove, tpTime * 1000, pos[2], 1387)
                end
        end
        return true
end
dont worked nothing joe rod
 
Lua:
local bosses = {
        ["rat"] = { x = 1146, y = 981, z = 7 }               
}

local function remove(position, id)
   local item = getTileItemById(position, id)
   if item.uid > 0 then
       doRemoveItem(item.uid, 1)
   end
end

local tpTime = 30 -- Seconds
function onKill(cid, target, lastHit, fromPosition)
        for name, pos in pairs(bosses) do
                if (name == getCreatureName(target):lower()) then
                   local targetPos = getThingPos(target)  
                   doCreateTeleport(1387, pos, targetPos)
                   addEvent(remove, tpTime * 1000, targetPos, 1387)
                end
        end
        return true
end
 
you guys define time as "time" and then use tpTime as variable, thats damnnn :/
Yeah, ive already changed this.

My code now:
Lua:
local bosses = {
        ["rat"] = { x = 1146, y = 981, z = 7 }                
}
local tptime = 1 -- Seconds
function onKill(cid, target, lastHit, fromPosition)
        for name, pos in pairs(bosses) do
                if (name == getCreatureName(target):lower()) then
                       
                     doCreateTeleport(1387, pos, getThingPos(target))
                    addEvent(doRemoveItem, tpTime, getTileItemById(getThingPos(target), 1387).uid, 1)
                end
        end
        return true
end

and the error:
Code:
Lua Script Error: [CreatureScript Interface]
in a timer event called from:
data/creaturescripts/scripts/monsterPortals.lua:onKill

LuaScriptInterface::luaDoRemoveItem(). Item not found
 
Yeah, ive already changed this.

My code now:
Lua:
local bosses = {
        ["rat"] = { x = 1146, y = 981, z = 7 }               
}
local tptime = 1 -- Seconds
function onKill(cid, target, lastHit, fromPosition)
        for name, pos in pairs(bosses) do
                if (name == getCreatureName(target):lower()) then
                      
                     doCreateTeleport(1387, pos, getThingPos(target))
                    addEvent(doRemoveItem, tpTime, getTileItemById(getThingPos(target), 1387).uid, 1)
                end
        end
        return true
end

and the error:
Code:
Lua Script Error: [CreatureScript Interface]
in a timer event called from:
data/creaturescripts/scripts/monsterPortals.lua:onKill

LuaScriptInterface::luaDoRemoveItem(). Item not found
try the code in my last post
 
to clear up some confusion regarding your usage of pos[1] and pos[2], it might be helpful to read this
xEzVtHd.png

What about this? when the monster transform into a teleport, the teleport stay below the stones or borders on map.
Its not related to client because when I put the teleport on the map with RME, it apper on the top always

bump
 
Last edited by a moderator:
I mean, what do you want us to do about that?
Just take the pebbles out of the boss arena and put something that doesn't have a higher layer value then the portal
 
I mean, what do you want us to do about that?
Just take the pebbles out of the boss arena and put something that doesn't have a higher layer value then the portal
Right, and, I wanted to change something, I wanted that the tp teleport you next to the boss, its possible?
example: when you enter the teleport, you will be teleported to the monster name (just gonna have a monster with the name)
 
Last edited:
Back
Top