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

globalevents problem

vexler222

Active Member
Joined
Apr 22, 2012
Messages
714
Solutions
15
Reaction score
46
Hi, i have text animation in globalevents, and i make animation for text "Exp: X%" from boosted monster, but boosted monster its loading later than globalevents, and i got error "null value", after reload gobalevents by command all work normal, how to set/change by boosted monster loading faster than globalevents scripts?

OjToO5z.png
 
Last edited:
Code? TFS?

tfs 1.3, what a code u need? its default animated text for teleports

Code:
local effects = {
    {position = Position(1007, 994, 7), text = 'Exp +'.. boostCreature[1].exp ..'%', effect = CONST_ME_BATS, textcolor = 140},
    {position = Position(1009, 994, 7), text = 'Loot +'.. boostCreature[1].loot ..'%', effect = CONST_ME_BATS, textcolor = 140},
    {position = Position(1008, 993, 7), text = 'BOOSTED', effect = CONST_ME_BATS, textcolor = 140},
}

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
               Game.sendAnimatedText(settings.text, settings.position, settings.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
 
Try changing it to check if boosted creature exists, otherwise default to another value.

so change it from this
Lua:
text = 'Exp +'.. boostCreature[1].exp ..'%'
to this, for example
Lua:
text = 'Exp +'.. (boostCreature[1] and boostCreature[1].exp or 999) ..'%'
 
Try changing it to check if boosted creature exists, otherwise default to another value.

so change it from this
Lua:
text = 'Exp +'.. boostCreature[1].exp ..'%'
to this, for example
Lua:
text = 'Exp +'.. (boostCreature[1] and boostCreature[1].exp or 999) ..'%'

It work for error, but how to reload globalevents after? Cuz now it showing me everytime "999" :/
 
It work for error, but how to reload globalevents after? Cuz now it showing me everytime "999" :/
Try this instead, I guess.

Lua:
local loaded = false
local effects = {
    {position = Position(1007, 994, 7), text = 'Exp +'.. boostCreature[1].exp ..'%', effect = CONST_ME_BATS, textcolor = 140},
    {position = Position(1009, 994, 7), text = 'Loot +'.. boostCreature[1].loot ..'%', effect = CONST_ME_BATS, textcolor = 140},
    {position = Position(1008, 993, 7), text = 'BOOSTED', effect = CONST_ME_BATS, textcolor = 140},
}

function onThink(creature, interval)
    if not loaded then
        if not boostCreature[1] then
            print("boostCreature table is not populated. Effects disabled.")
            return true
        end
        print("boostCreature table is populated. Effects are now enabled.")
        loaded = true
    end
    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
                Game.sendAnimatedText(settings.text, settings.position, settings.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
 
Try this instead, I guess.

Lua:
local loaded = false
local effects = {
    {position = Position(1007, 994, 7), text = 'Exp +'.. boostCreature[1].exp ..'%', effect = CONST_ME_BATS, textcolor = 140},
    {position = Position(1009, 994, 7), text = 'Loot +'.. boostCreature[1].loot ..'%', effect = CONST_ME_BATS, textcolor = 140},
    {position = Position(1008, 993, 7), text = 'BOOSTED', effect = CONST_ME_BATS, textcolor = 140},
}

function onThink(creature, interval)
    if not loaded then
        if not boostCreature[1] then
            print("boostCreature table is not populated. Effects disabled.")
            return true
        end
        print("boostCreature table is populated. Effects are now enabled.")
        loaded = true
    end
    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
                Game.sendAnimatedText(settings.text, settings.position, settings.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

Not work, same error

4hgHZkC.png
 
Try this
@edit
Lua:
function onThink(creature, interval)
    local boostExperience = boostCreature[1].exp
    local boostLoot = boostCreature[1].loot
    if not boostExperience or not boostLoot then
        return true
    end

    local config = {
        {
            position = Position(1007, 994, 7),
            magicEffect = CONST_ME_BATS,
            animatedText = "Exp +"..boostExperience.."%",
            animatedTextColor = 140
        },
        {
            position = Position(1009, 994, 7),
            magicEffect = CONST_ME_BATS,
            animatedText = "Loot +"..boostLoot.."%",
            animatedTextColor = 140
        },
        {
            position = Position(1008, 993, 7),
            magicEffect = CONST_ME_BATS,
            animatedText = "BOOSTED",
            animatedTextColor = 140
        },
    }

    for i = 1, #config do
        local settings = config[i]
        if settings.magicEffect then
            settings.position:sendMagicEffect(settings.magicEffect)
        end

        if settings.animatedText and settings.animatedTextColor then
            settings.position:sendAnimatedText(settings.animatedText, settings.animatedTextColor)
        end
    end
    return true
end
 
Last edited:
Try this
@edit
Lua:
function onThink(creature, interval)
    local boostExperience = boostCreature[1].exp
    local boostLoot = boostCreature[1].loot
    if not boostExperience or not boostLoot then
        return true
    end

    local config = {
        {
            position = Position(1007, 994, 7),
            magicEffect = CONST_ME_BATS,
            animatedText = "Exp +"..boostExperience.."%",
            animatedTextColor = 140
        },
        {
            position = Position(1009, 994, 7),
            magicEffect = CONST_ME_BATS,
            animatedText = "Loot +"..boostLoot.."%",
            animatedTextColor = 140
        },
        {
            position = Position(1008, 993, 7),
            magicEffect = CONST_ME_BATS,
            animatedText = "BOOSTED",
            animatedTextColor = 140
        },
    }

    for i = 1, #config do
        local settings = config[i]
        if settings.magicEffect then
            settings.position:sendMagicEffect(settings.magicEffect)
        end

        if settings.animatedText and settings.animatedTextColor then
            settings.position:sendAnimatedText(settings.animatedText, settings.animatedTextColor)
        end
    end
    return true
end

No errors but it showing only bats effect on first position in config
Post automatically merged:

o wait i have errors

EfStBJR.png
 
Last edited:
Back
Top