• 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 how to make Text and Effects over teleports TFS 1.4.2

Solution
1698240733355.png

data/scripts/creaturescripts/tileeffect.lua
Lua:
local effects = {
    {position = Position(1000, 1000, 7), text = 'WELCOME', effect = CONST_ME_ENERGYAREA, oneEffect = false},
    {position = Position(1002, 1000, 7), text = 'TEST', effect = CONST_ME_ENERGYAREA, oneEffect = true},
}

local tileeffect = GlobalEvent("Tile Effect")

function tileeffect.onThink(interval)
    for _, tileeffects in pairs(effects) do
        local spectators = Game.getSpectators(tileeffects.position, false, true, 7, 7, 5, 5)
        if #spectators > 0 then
            for i = 1, #spectators do
                spectators[i]:say(tileeffects.text, TALKTYPE_MONSTER_SAY, false, spectators[i], tileeffects.position)
            end
        end
        if...
1698240733355.png

data/scripts/creaturescripts/tileeffect.lua
Lua:
local effects = {
    {position = Position(1000, 1000, 7), text = 'WELCOME', effect = CONST_ME_ENERGYAREA, oneEffect = false},
    {position = Position(1002, 1000, 7), text = 'TEST', effect = CONST_ME_ENERGYAREA, oneEffect = true},
}

local tileeffect = GlobalEvent("Tile Effect")

function tileeffect.onThink(interval)
    for _, tileeffects in pairs(effects) do
        local spectators = Game.getSpectators(tileeffects.position, false, true, 7, 7, 5, 5)
        if #spectators > 0 then
            for i = 1, #spectators do
                spectators[i]:say(tileeffects.text, TALKTYPE_MONSTER_SAY, false, spectators[i], tileeffects.position)
            end
        end
        if tileeffects.oneEffect then
            tileeffects.position:sendMagicEffect(tileeffects.effect)
        else
            tileeffects.position:sendMagicEffect(math.random(1, 70))
        end
    end
    return true
end
tileeffect:interval(1000)
tileeffect:register()

if OneEffect is false it will send random effect from 1 to 70
if OneEffect is true it will send only the effect which is registed here:
1698240949449.png

if Game.sendAnimatedText exists in your source then you can use custom colors
Lua:
local effects = {
    {position = Position(1000, 1000, 7), text = 'WELCOME', effect = CONST_ME_ENERGYAREA, color = TEXTCOLOR_BLUE, oneEffect = false, oneColor = false},
    {position = Position(1002, 1000, 7), text = 'TEST', effect = CONST_ME_ENERGYAREA, color = TEXTCOLOR_BLUE, oneEffect = true, oneColor = true},
}

local tileeffect = GlobalEvent("Tile Effect")

function tileeffect.onThink(interval)
    for _, tileeffects in pairs(effects) do
        if tileeffects.oneColor then
            Game.sendAnimatedText(tileeffects.text, tileeffects.position, tileeffects.color)
        else
            Game.sendAnimatedText(tileeffects.text, tileeffects.position, math.random(1, 256))
        end
        if tileeffects.oneEffect then
            tileeffects.position:sendMagicEffect(tileeffects.effect)
        else
            tileeffects.position:sendMagicEffect(math.random(1, 70))
        end
    end
    return true
end

tileeffect:interval(1000)
tileeffect:register()

If oneColor is true = send the only color which is registed in effects table if its false it will send any color from 1 to 256
1698243029262.png

if you want to use as example just two colors you can add a table for it as example like:

Lua:
local colors = {TEXTCOLOR_GREEN, TEXTCOLOR_BLUE}
Lua:
Game.sendAnimatedText(tileeffects.text, tileeffects.position, colors[math.random(#colors)])
 
Last edited:
Solution
I have a script that displays random colored text and visual effects... Try it here!
Lua:
local textcolors = {5, 30, 35, 95, 108, 129, 143, 155, 180, 198, 210, 215}

local effects = {
    {position = Position(721, 599, 7), text = 'Welcome!', effect = CONST_ME_BATS},
    {position = Position(723, 594, 8), text = 'Addon!', effect = CONST_ME_GIANTICE},
}

local globalevent = GlobalEvent("Animated Text")

function globalevent.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
                local textcolor = textcolors[math.random(#textcolors)]
                Game.sendAnimatedText(settings.text, settings.position, textcolor)
            end
            if settings.effect then
                settings.position:sendMagicEffect(settings.effect)
            end
            if settings.effect2 then
                settings.position:sendMagicEffect(settings.effect2)
            end
        end
    end
    return true
end

globalevent:interval(1000)
globalevent:register()
If your font doesn't have 'animated text' installed, simply make changes to your font. If you don't want to, you can use Levi's script... :)
 
i
Post automatically merged:

I have a script that displays random colored text and visual effects... Try it here!
Lua:
local textcolors = {5, 30, 35, 95, 108, 129, 143, 155, 180, 198, 210, 215}

local effects = {
    {position = Position(721, 599, 7), text = 'Welcome!', effect = CONST_ME_BATS},
    {position = Position(723, 594, 8), text = 'Addon!', effect = CONST_ME_GIANTICE},
}

local globalevent = GlobalEvent("Animated Text")

function globalevent.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
                local textcolor = textcolors[math.random(#textcolors)]
                Game.sendAnimatedText(settings.text, settings.position, textcolor)
            end
            if settings.effect then
                settings.position:sendMagicEffect(settings.effect)
            end
            if settings.effect2 then
                settings.position:sendMagicEffect(settings.effect2)
            end
        end
    end
    return true
end

globalevent:interval(1000)
globalevent:register()
If your font doesn't have 'animated text' installed, simply make changes to your font. If you don't want to, you can use Levi's script... :)
View attachment 79484

data/scripts/creaturescripts/tileeffect.lua
Lua:
local effects = {
    {position = Position(1000, 1000, 7), text = 'WELCOME', effect = CONST_ME_ENERGYAREA, oneEffect = false},
    {position = Position(1002, 1000, 7), text = 'TEST', effect = CONST_ME_ENERGYAREA, oneEffect = true},
}

local tileeffect = GlobalEvent("Tile Effect")

function tileeffect.onThink(interval)
    for _, tileeffects in pairs(effects) do
        local spectators = Game.getSpectators(tileeffects.position, false, true, 7, 7, 5, 5)
        if #spectators > 0 then
            for i = 1, #spectators do
                spectators[i]:say(tileeffects.text, TALKTYPE_MONSTER_SAY, false, spectators[i], tileeffects.position)
            end
        end
        if tileeffects.oneEffect then
            tileeffects.position:sendMagicEffect(tileeffects.effect)
        else
            tileeffects.position:sendMagicEffect(math.random(1, 70))
        end
    end
    return true
end
tileeffect:interval(1000)
tileeffect:register()

if OneEffect is false it will send random effect from 1 to 70
if OneEffect is true it will send only the effect which is registed here:
View attachment 79485
worked thanks dude
Post automatically merged:

I have a script that displays random colored text and visual effects... Try it here!
Lua:
local textcolors = {5, 30, 35, 95, 108, 129, 143, 155, 180, 198, 210, 215}

local effects = {
    {position = Position(721, 599, 7), text = 'Welcome!', effect = CONST_ME_BATS},
    {position = Position(723, 594, 8), text = 'Addon!', effect = CONST_ME_GIANTICE},
}

local globalevent = GlobalEvent("Animated Text")

function globalevent.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
                local textcolor = textcolors[math.random(#textcolors)]
                Game.sendAnimatedText(settings.text, settings.position, textcolor)
            end
            if settings.effect then
                settings.position:sendMagicEffect(settings.effect)
            end
            if settings.effect2 then
                settings.position:sendMagicEffect(settings.effect2)
            end
        end
    end
    return true
end

globalevent:interval(1000)
globalevent:register()
If your font doesn't have 'animated text' installed, simply make changes to your font. If you don't want to, you can use Levi's script... :)
i'll try it ty
 
i
Post automatically merged:



worked thanks dude
Post automatically merged:


i'll try it ty

Keep in mind Game.sendAnimatedText works only if you use OTC otherwise it wont and it will crash your client :D
I have updated my script aswell with animatedTextSupport
 
Tenha em mente que Game.sendAnimatedText funciona apenas se você usar OTC, caso contrário, não funcionará e travará seu cliente:D
Também atualizei meu script com animadoTextSupport
o.o, I didn't know that the cip client crashed with animated text.. thanks.. good to know hehehe
 
Back
Top