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

GlobalEvent [TFS 1.0/1.1] TP room text/effects

zbizu

Legendary OT User
Joined
Nov 22, 2010
Messages
3,323
Solutions
26
Reaction score
2,693
Location
Poland
Text and effects for tp room written in classic style so script should work on other TFS versions too(non-metatables version is in a spoiler below).

globalevents.xml:
Code:
<globalevent name="text" interval="3500" script="text.lua"/>

text.lua:
TFS 1.1:
Code:
local effects = {
    {position = Position(995, 100, 7), text = 'Teleports', effect = CONST_ME_GROUNDSHAKER},
    {position = Position(281, 254, 8), text = 'TP Room'}, -- text only
    {position = Position(307, 254, 1), text = 'Event', effect = CONST_ME_GROUNDSHAKER},
}

function onThink(interval)
    for i = 1, #effects do
        local settings = effects[i]
        local spectators = Game.getSpectators(settings.position, false, true, 7, 7, 5, 5)
        if #spectators > 0 then
            if settings.text then
                for i = 1, #spectators do
                    spectators[i]:say(settings.text, TALKTYPE_MONSTER_SAY, false, spectators[i], settings.position)
                end
            end
            if settings.effect then
                settings.position:sendMagicEffect(settings.effect)
            end
        end
    end
   return true
end

non-metatables version for older servers:
Code:
local fields = {
{x = 995, y = 1000, z = 7, text = "Teleports", eff = CONST_ME_GROUNDSHAKER},
{x = 281, y = 254, z = 8, text = "TP Room"}, -- text only
{x = 307, y = 254, z = 15, text = "Event", eff = CONST_ME_GROUNDSHAKER},
}

function onThink(interval)
   for i = 1, #fields do
     local pos = fields[i]
     local people = getSpectators(pos, 7, 5, false, true)
     if people then
       if pos.text then
         doCreatureSay(people[1], pos.text, TALKTYPE_ORANGE_1, false, 0, pos)
       end
       if pos.eff then
         doSendMagicEffect(pos, pos.eff)
       end
     end
   end
   return true
end
 
Last edited by a moderator:
Getting this error in console
auxMNka.png
 
Using new functions, if you do not mind.

Code:
local effects = {
    {position = Position(995, 100, 7), text = 'Teleports', effect = CONST_ME_GROUNDSHAKER},
    {position = Position(281, 254, 8), text = 'TP Room'}, -- text only
    {position = Position(307, 254, 1), text = 'Event', effect = CONST_ME_GROUNDSHAKER},
}

function onThink(interval)
    for i = 1, #effects do
        local settings = effects[i]
        local spectators = Game.getSpectators(settings.position, false, true, 7, 7, 5, 5)
        if #spectators > 0 then
            if settings.text then
                for i = 1, #spectators do
                    spectators[i]:say(settings.text, TALKTYPE_MONSTER_SAY, false, spectators[i], settings.position)
                end
            end
            if settings.effect then
                settings.position:sendMagicEffect(settings.effect)
            end
        end
    end
   return true
end
 
Last edited:
@Summ
In your script "Send" functions are in a loop. What if there will be 20 spectators in that range? Effect and message will be executed 20 times. My script avoids this and sends message and effect only once.
 
@zbizu
Edited my script, forgot to set the target parameter.
 
Awesome, ima gona use it for written "soundeffects"
 
@Summ
first post updated
I'll keep non-metatables version as the script was intended to work on all TFS.
 
Would it be possible to make it instead of having an interval just staying permanently?
 
@tibia10gogo I just tested on TFS 1.2 can confirm it works, all I did was change the function a lil and add an extra bracket after local....if you still need this you can just copy the fixes here:
Code:
local effects = {
    {position = Position(32341, 32220, 7), text = 'Raid Boss Starter!', effect = CONST_ME_FIREWORK_RED, 
    {position = Position(281, 254, 8), text = 'TP Room'}, -- text only
    {position = Position(307, 254, 1), text = 'Event', effect = CONST_ME_GROUNDSHAKER},
}}

function onThink(creature, interval)
    for i = 1, #effects do
        local settings = effects[i]
        local spectators = Game.getSpectators(settings.position, false, true, 7, 7, 5, 5)
        if #spectators > 0 then
            if settings.text then
                for i = 1, #spectators do
                    spectators[i]:say(settings.text, TALKTYPE_MONSTER_SAY, false, spectators[i], settings.position)
                end
            end
            if settings.effect then
                settings.position:sendMagicEffect(settings.effect)
            end
        end
    end
   return true
end
@zbizu Great work as always, you can switch this to green in your TFS 1.x Scripts if you're still updating that
 
@doit,

used your script on my tfs 1.2 only the first one showed up..

messed around with it and this makes it show all 3

Code:
local effects = {
    {position = Position(1531, 180, 6), text = 'Paramore', effect = CONST_ME_FIREWORK_RED},
    {position = Position(1533, 180, 6), text = 'AshPort'},
    {position = Position(1534, 184, 6), text = 'Ravenia', effect = CONST_ME_FIREWORK_RED},
}

function onThink(creature, interval)
    for i = 1, #effects do
        local settings = effects[i]
        local spectators = Game.getSpectators(settings.position, false, true, 7, 7, 5, 5)
        if #spectators > 0 then
            if settings.text then
                for i = 1, #spectators do
                    spectators[i]:say(settings.text, TALKTYPE_MONSTER_SAY, false, spectators[i], settings.position)
                end
            end
            if settings.effect then
                settings.position:sendMagicEffect(settings.effect)
            end
        end
    end
   return true
end
 
Back
Top