• 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 create TP when monster die

qban

RazorsEdge
Joined
Feb 19, 2010
Messages
145
Reaction score
15
Location
Sanok, Poland
Hi,
I'm using TFS 0.4 [3671 rev] and I need a script which creates teleport when somebody kill a monster.
There is a lot of such scripts on our forum but there's no one which works on my server.
I think that scripts are well made, but I'm doing something wrong... but I don't know what.
So... could someone tell me what's the point?
For example:
I'm creating new .lua document called "rzrtp.lua"
Code:
local m = {
   [COLOR="red"] ["Razor The Destroyer"][/COLOR] = {
        message = "Escape through the teleport quickly before it closes!",
        cfg = 
        {
            {
                [COLOR="red"]time = 15,
                to = {x = 111, y = 16, z = 11},
                tp = {x = 67, y = 31, z = 12}[/COLOR]
            }
        }
    }
}
 
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
Where:
["Razor The Destroyer"] -- monster
time = 15, -- time to remove tp (multipled by 1000)
to = {x = 111, y = 16, z = 11}, -- teleport destination
tp = {x = 67, y = 31, z = 12} -- here tp appears

then I'm adding this:
Code:
<event type="[COLOR="#8b0000"]kill[/COLOR]" name="[COLOR="red"]rzrtp[/COLOR]" script="[COLOR="red"]rzrtp.lua[/COLOR]"/>
also tried with
Code:
<event type="[COLOR="#8b0000"]death[/COLOR]" name="inquisitionPortals" script="rzrtp.lua"/>

after I'm adding this:
Code:
<script> 
	<event name="[COLOR="red"]rzrtp[/COLOR]"/> 
</script>

so it's looking like this:
Code:
 [COLOR="lime"]...[/COLOR]    <flag runonhealth="0"/>
    </flags>
[COLOR="red"]<script> 
	<event name="rzrtp"/> 
</script>[/COLOR]
    <attacks>
        <attack name="melee" interval="2000" skill="230" attack="200"/>
[COLOR="lime"]...[/COLOR]

But when monster dies, nothing happens... it's just like before. There are no errors in the console too...
So... if somebody has a minute, I'll be glad if he could help me. ;)

Regards and thanks in advance,
Qban
 
Remove
Code:
<script> 
	<event name="rzrtp"/> 
</script>
from monster(s)

And add this into login.lua:
Code:
	registerCreatureEvent(cid, "rzrtp")
 
Back
Top