• 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 monster die.

Wason

UnKnow Member
Joined
Jan 12, 2015
Messages
1,249
Reaction score
255
Location
EgypT
hello otlanders,
there's someone help me when monster die please?!
i need when monster called "Exp Event" Dead players get out of arena so that's there's no block to exp event spawn :)
i hope someone help me with that.

auto teleport to temple when exp event dead.

tfs 0.3.6 //version 8.60
@Limos @Summ @Printer @Ninja (Help Me Guys)

Sorry for my bad english.
Wason
 
In creaturescripts.xml add:
Code:
    <event type="death" name="eventDead" event="script" value="eventDead.lua"/>

Open the XML file of that monster and add this to it:
Code:
    <script>
    <event name="eventDead"/>
    </script>

In creaturescripts/scripts/ make a script called eventDead.lua and put this in it
(make sure to edit the config part to fit your needs):

Code:
function onDeath(cid, corpse, deathList)
local config = {
monsterName = "rotworm", -- Name of the monster that triggers this script when it dies
centerPosition = {x= ,y= , z= }, -- Center position of the area affected by this script
rangex = 5,   -- Range of all affected horizontal tiles starting at the centerPosition
rangey = 5,   -- Range of all affected vertical tiles starting at the centerPosition
destination = {x=, y=, z= }, -- Destination where players will be teleported to
effect = 8 -- Effect that should be displayed when player is teleported
}

     if (string.lower(getCreatureName(cid)) == string.lower(config.monsterName)) then
        local players = getSpectators(config.centerPosition, config.rangex, config.rangey)
       
        for i = 1, #players do
            if isPlayer(players[i]) then
            doTeleportThing(cid, config.destination)
            doSendMagicEffect(config.destination, config.effect)
            end
        end
     end

     return true
end
 
Woops.
Try like this:

Code:
function onDeath(cid, corpse, deathList)
-- CONFIGURATION:
local config = {
monsterName = "rotworm",
rangex = 5,
rangey = 5,
effect = 8
}
local centerPosition = {x= ,y= , z= },
local destination = {x=, y=, z= },
------

     if (string.lower(getCreatureName(cid)) == string.lower(config.monsterName)) then
        local players = getSpectators(centerPosition, config.rangex, config.rangey)
      
        for i = 1, #players do
            if isPlayer(players[i]) then
            doTeleportThing(cid, destination)
            doSendMagicEffect(destination, config.effect)
            end
        end
     end

     return true
end
 
Shadowsong, i would done something like this. You do not need check the monster name, since the even is registered on that monster. Also move the tables outside the function, if it's not necessary to have them inside the function.
Code:
local config = {
    rangex = 10,
    rangey = 10,
    teleportTo = {x = 1000, y = 1000, z = 7}
}

function onDeath(cid, corpse, deathList)
    local spectators, spec = getSpectators(getCreaturePosition(cid), config.rangex, config.rangey)
    for i = 1, #spectators do
        spec = spectators[i]
        if isPlayer(spec) then
            doTeleportThing(spec, config.teleportTo)
            doSendMagicEffect(config.teleportTo, CONST_ME_TELEPORT)
        end
    end

    return true
end
 
local config = { rangex = 10, rangey = 10, teleportTo = {x = 1000, y = 1000, z = 7} } function onDeath(cid, corpse, deathList) local spectators, spec = getSpectators(getCreaturePosition(cid), config.rangex, config.rangey) for i = 1, #spectators do spec = spectators if isPlayer(spec) then doTeleportThing(spec, config.teleportTo) doSendMagicEffect(config.teleportTo, CONST_ME_TELEPORT) end end return true end

so i put it on
eventDead??
 
Shadowsong, i would done something like this. You do not need check the monster name, since the even is registered on that monster. Also move the tables outside the function, if it's not necessary to have them inside the function.
Code:
local config = {
    rangex = 10,
    rangey = 10,
    teleportTo = {x = 1000, y = 1000, z = 7}
}

function onDeath(cid, corpse, deathList)
    local spectators, spec = getSpectators(getCreaturePosition(cid), config.rangex, config.rangey)
    for i = 1, #spectators do
        spec = spectators[i]
        if isPlayer(spec) then
                    doTeleportThing(spec, config.teleportTo)
                    doSendMagicEffect(config.teleportTo, CONST_ME_TELEPORT)
                end
        end

         return true
end

Thanks for the tip. I'm not a pro scripter but I try to help with what I think I can make.
And you're right about that check. I keep all my onDeath scripts in 1 lua file, that's why I'm used to making that name check, I completely forgot haha


Paste this line from your edited script here.
Seems like something is wrong with the way you entered the monster's name. It should be:

monsterName = "Exp Event",
 
@Shadowsong, i noticed that you are now shining at helping people out and i'm really appricate it :) I was like you from the start could not script good aswell, but after taking alot of tips i got a good grasp about coding :D

But yeah, you can freakin map, draw and code. I can only code :(
 
@Shadowsong, i noticed that you are now shining at helping people out and i'm really appricate it :) I was like you from the start could not script good aswell, but after taking alot of tips i got a good grasp about coding :D

But yeah, you can freakin map, draw and code. I can only code :(

Thanks. Yeah I guess, but it's both a gift and a curse doing all these things at once. It's good fun for your brain though, until it explodes.
 
Any tips on how this script would work in TFS 1.5? If I have a boss room with for example Rahemos. When Rahemos dies, everyone in the room will get teleported to a new destination and get a storage value
 
Back
Top