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

Teleport when kill monster TFS 0.4

homarwh

Just a Milan fan.
Joined
Dec 29, 2012
Messages
93
Reaction score
2
Location
Mexico
Well i been used a LOT of scripts on the server and no one works, this is what i have till now.

Script:
Code:
 local m = {
    ["energy overlord"] = {
        message = "The teleport to the FINAL room has been created.",
        cfg =
        {
            {
                time = 10,
                to = {x = 1145, y = 1342, z = 7},
                tp = {x = 1139, y = 1376, z = 7}
            }
        }
    }
}
function onKill(cid, target)
    if isPlayer(target) then
        return true
    end
    local monster = m[getCreatureName(target)]
    if monster then
        for i = 1, #monster.cfg do
            local c = monster.cfg[i]
                local function deleteTeleport()
                local teleport = getTileItemById(c.tp, 1387).uid
                    if(teleport > 0) then
                        doRemoveItem(teleport)
                        doSendMagicEffect(c.tp, CONST_ME_POFF)
                    end
                    return true
                end
            doCreateTeleport(1387, c.to, c.tp)
            doSendMagicEffect(c.tp, CONST_ME_ENERGYAREA)
            addEvent(deleteTeleport, c.time * 1000)
        end
        doCreatureSay(cid, monster.message, TALKTYPE_ORANGE_1)
    end
    return true
end

On creaturecripts.xml
Code:
<event type="kill" name="Killer" event="script" value="elementboss.lua"/>

Login.lua
Code:
registerCreatureEvent(cid, "Killer")


Why it doesnt work?
 
there is difference between "energy overlord" and "Energy Overlord"
try this(it changes text to small letters):
Code:
local monster = m[getCreatureName(target):lower()]
 
there is difference between "energy overlord" and "Energy Overlord"
try this(it changes text to small letters):
Code:
local monster = m[getCreatureName(target):lower()]

You can't use :lower insted [] you have to use [string.lower(string)], atleast on tfs 1.0.
 
Code:
local test = "Energy Overlord"
print(test:lower(), string.lower(test))

Output: energy overlord    energy overlord
TFS version doesn't matter
 
TFS 1.0
Code:
local m = {
   ["limos"] = {q = 1, w = 10}
}
local x = m[getPlayerName(cid):lower()]
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "W: "..x.w..".")
kG5Uxr4.png


It also works on other versions, lower is Lua, so it doesn't matter which version you use.
 
Last edited:
Code:
local test = "Energy Overlord"
print(test:lower(), string.lower(test))

Output: energy overlord    energy overlord
TFS 1.0
Code:
local m = {
   ["limos"] = {q = 1, w = 10}
}
local x = m[getPlayerName(cid):lower()]
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "W: "..x.w..".")
kG5Uxr4.png


It also works on other versions, I almost always do it like this, same goes for alot of other scripts that are released on otland.

Weird diden't work on tfs 1.0 atleast when I used rev 915 version 10.31 it threw the same error as lua demo did.
You learn everyday ;)
 
Maybe you added the string directly?
This works:
Code:
local name = "Limos"
local x = m[name:lower()]
Code:
local x = m[getPlayerName(cid):lower()]

This doesn't:
Code:
local x = m["Limos":lower()]
 
Maybe you added the string directly?
This works:
Code:
local name = "Limos"
local x = m[name:lower()]
Code:
local x = m[getPlayerName(cid):lower()]

This doesn't:
Code:
local x = m["Limos":lower()]

No I only use those for targets like this:
Code:
if(killingInTheNameOfTable[monster:getName():lower()]) then
 
Back
Top Bottom