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

how to display effect above the teleport

kaparzo231

New Member
Joined
Mar 22, 2022
Messages
29
Solutions
1
Reaction score
4
Location
Poland
GitHub
XxX
Hey,

I need a script to display the string above the teleport
I was looking for a script for a long time, but none of it worked for me.


I usually get this error:

[C]: in function 'debugPrint'
data/lib/compat/compat.lua:406: in function 'doSendAnimatedText'

in data/lib/compat/compat.lua:406 i have this:

function doSendAnimatedText() debugPrint("Deprecated function.") return true end

Engine: theforgottenserver-v1.2-win64
Tibia 10.98
Windows 10


sorry for my english i use translator :D


I will be grateful for finding / writing a working script
 
Solution
try this way in compat.lua:
Lua:
function doPlayerSendTextMessage(cid, type, text, ...) local p = Player(cid) return p ~= nil and p:sendTextMessage(type, text, ...) or false end
function doSendAnimatedText() debugPrint("Deprecated function.") return true end
function doSendAnimatedText(pos, text, color, player) Game.sendAnimatedText(text, pos, color, player) return true end
function doPlayerAddExp(cid, exp, useMult, ...)
    local player = Player(cid)
    if player == nil then
        return false
    end

    if useMult then
        exp = exp * Game.getExperienceStage(player:getLevel())
    end
    return player:addExperience(exp, ...)
end

and this way in game.lua:


Lua:
function Game.broadcastMessage(message, messageType)
    if...
thanks for the answer.

I am not familiar with the subject so could you please explain to me on this example?

In data/globalevents/globalevents.xml adds this:

<globalevent name="Support" interval="2000" script="efekty.lua"/>


Then it creates the file in: data/globalevents/scripts/efekty.lua

Script:

Lua:
local pozycje = {
    {pos = {x=996, y=1002, z=7}, tekst = "Trainers"},
    {pos = {x=1001, y=1001, z=7}, tekst = "Tp Room 1"},
    {pos = {x=1002, y=1001, z=7}, tekst = "Tp Room 2"},
    {pos = {x=1003, y=999, z=7}, tekst = "Quest 1"},
    {pos = {x=1003, y=998, z=7}, tekst = "Quest 2"},
    {pos = {x=1038, y=995, z=7}, tekst = "Trainers"},
    {pos = {x=995, y=994, z=7}, tekst = "Temple"},
    {pos = {x=995, y=1001, z=7}, tekst = "House"},
    {pos = {x=995, y=999, z=7}, tekst = "House 2"},
    {pos = {x=995, y=996, z=7}, tekst = "Npc's"},
    {pos = {x=1028, y=995, z=7}, tekst = "Temple"}
    }
    
local config = {
    kolor = TEXTCOLOR_YELLOW, -- kolor napisu
    efekt = CONST_ME_HOLYDAMAGE, -- efekt
    }

function onThink(interval, lastExecution)
    for i, v in pairs(pozycje) do
        doSendMagicEffect(v.pos, config.efekt)
        doSendAnimatedText(v.pos, v.tekst, config.kolor)
    end
    return true
end

I have this error:
[C]: in function 'debugPrint'
data/lib/compat/compat.lua:406: in function 'doSendAnimatedText'
data/globalevents/scripts/effect.lua:23: in function <data/globalevents/scripts/effect.lua:20>

Lua Script Error: [GlobalEvent Interface]
data/globalevents/scripts/effect.lua:eek:nThink
LuaScriptInterface::luaDebugPrint(). Deprecated function.
stack traceback:

What do I have to change for it to work?

 
Thanks for answer :)

Now it pops up:
[C]: in function 'say'
data/globalevents/scripts/effect.lua:13: in function <data/globalevents/scripts/effect.lua:10>
[Error - GlobalEvents::think] Failed to execute event: Support

Lua Script Error: [GlobalEvent Interface]
data/globalevents/scripts/effect.lua:eek:nThink
data/globalevents/scripts/effect.lua:13: attempt to call method 'say' (a nil value)
stack traceback:
Post automatically merged:

I change script:

Lua:
local pozycje = {
    {pos = {x=99, y=359, z=6}, tekst = "Temple"},
    }
    
local config = {
    kolor = TEXTCOLOR_YELLOW, -- kolor napisu
    efekt = CONST_ME_HOLYDAMAGE, -- efekt
    }

function onThink(interval, lastExecution)
    for i, v in pairs(pozycje) do
        doSendMagicEffect(v.pos, config.efekt)
        v.pos:say(v.tekst, TALKTYPE_MONSTER_SAY)
    end
    return true
end
 
Last edited:
if it's for newer tibia version it's not possible cause animated text was removed, but in older versions you can still use
Game.sendAnimatedText(

like this one:

Code:
local color = 5
local effects = {
    {position = Position(1085, 1216, 7), text = '[Quests]'}
}

 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
                Game.sendAnimatedText(settings.text, settings.position, color)
             end
          end
       end
    end
    return true
 end

it works in my TFS 1.4 Nekiro downgrade 8.6 ot
 
Thanks for answer :)

still not working, but the error does not pop up right away, only when the player is close to the teleport

Error:
[C]: in function 'sendAnimatedText'
data/globalevents/scripts/effect.lua:13: in function <data/globalevents/scripts/effect.lua:6>
[Error - GlobalEvents::think] Failed to execute event: Support
 
Do u have the src? Search function in const.cpp any about text animation.
Or copy animate text action script from potions.
 
OP said that he's using TFS 1.2 so I checked here in TFS 1.2 github and I didn't find it in sources, I think that you'll need to add animated text function in your source to use it, ":say" also isn't an option cause it need a creature to be called.

EDIT:

I found out this PR from EPuncker that add back this function with no need to change sources: Adding back sendAnimatedText if client version is lower than 9 by EPuncker · Pull Request #3117 · otland/forgottenserver (https://github.com/otland/forgottenserver/pull/3117/files)
 
Last edited:
Do u have the src? Search function in const.cpp any about text animation.
Or copy animate text action script from potions.
Thanks for answer :)

if you mean a folder or a file called scr. I don't have one.

found something like this in: data\actions\scripts\other\constructionkits

Lua:
local constructionKits = {
    [3901] = 1666, [3902] = 1670, [3903] = 1652, [3904] = 1674, [3905] = 1658,
    [3906] = 3813, [3907] = 3817, [3908] = 1619, [3909] = 12799, [3910] = 2105,
    [3911] = 1614, [3912] = 3806, [3913] = 3807, [3914] = 3809, [3915] = 1716,
    [3916] = 1724, [3917] = 1732, [3918] = 1775, [3919] = 1774, [3920] = 1750,
    [3921] = 3832, [3922] = 2095, [3923] = 2098, [3924] = 2064, [3925] = 2582,
    [3926] = 2117, [3927] = 1728, [3928] = 1442, [3929] = 1446, [3930] = 1447,
    [3931] = 2034, [3932] = 2604, [3933] = 2080, [3934] = 2084, [3935] = 3821,
    [3936] = 3811, [3937] = 2101, [3938] = 3812, [5086] = 5046, [5087] = 5055,
    [5088] = 5056, [6114] = 6111, [6115] = 6109, [6372] = 6356, [6373] = 6371,
    [8692] = 8688, [9974] = 9975, [11126] = 11127, [11133] = 11129, [11124] = 11125,
    [11205] = 11203, [14328] = 1616, [14329] = 1615, [16075] = 16020, [16099] = 16098,
    [20254] = 20295, [20255] = 20297, [20257] = 20299
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local kit = constructionKits[item.itemid]
    if not kit then
        return false
    end

    if fromPosition.x == CONTAINER_POSITION then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "Put the construction kit on the floor first.")
    elseif not Tile(fromPosition):getHouse() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You may construct this only inside a house.")
    else
        item:transform(kit)
        fromPosition:sendMagicEffect(CONST_ME_POFF)
    end
    return true
end

potions
Lua:
local ultimateHealthPot = 8473
local greatHealthPot = 7591
local greatManaPot = 7590
local greatSpiritPot = 8472
local strongHealthPot = 7588
local strongManaPot = 7589
local healthPot = 7618
local manaPot = 7620
local smallHealthPot = 8704
local antidotePot = 8474
local greatEmptyPot = 7635
local strongEmptyPot = 7634
local emptyPot = 7636

local antidote = Combat()
antidote:setParameter(COMBAT_PARAM_TYPE, COMBAT_HEALING)
antidote:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
antidote:setParameter(COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
antidote:setParameter(COMBAT_PARAM_AGGRESSIVE, false)
antidote:setParameter(COMBAT_PARAM_DISPEL, CONDITION_POISON)

local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, (configManager.getNumber(configKeys.EX_ACTIONS_DELAY_INTERVAL) - 100))
-- 1000 - 100 due to exact condition timing. -100 doesn't hurt us, and players don't have reminding ~50ms exhaustion.

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if target == nil or not target:isPlayer() then
        return true
    end

    if player:getCondition(CONDITION_EXHAUST_HEAL) then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
        return true
    end

    local itemId = item:getId()
    if itemId == antidotePot then
        if not antidote:execute(target, numberToVariant(target:getId())) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
        item:remove(1)
        player:addItem(emptyPot, 1)
    elseif itemId == smallHealthPot then
        if not doTargetCombatHealth(0, target, COMBAT_HEALING, 60, 90, CONST_ME_MAGIC_BLUE) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
        item:remove(1)
        player:addItem(emptyPot, 1)
    elseif itemId == healthPot then
        if not doTargetCombatHealth(0, target, COMBAT_HEALING, 125, 175, CONST_ME_MAGIC_BLUE) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
        item:remove(1)
        player:addItem(emptyPot, 1)
    elseif itemId == manaPot then
        if not doTargetCombatMana(0, target, 75, 125, CONST_ME_MAGIC_BLUE) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
        item:remove(1)
        player:addItem(emptyPot, 1)
    elseif itemId == strongHealthPot then
        if (not isInArray({3, 4, 7, 8}, target:getVocation():getId()) or target:getLevel() < 50) and not getPlayerFlagValue(player, PlayerFlag_IgnoreSpellCheck) then
            player:say("This potion can only be consumed by paladins and knights of level 50 or higher.", TALKTYPE_MONSTER_SAY)
            return true
        end

        if not doTargetCombatHealth(0, target, COMBAT_HEALING, 250, 350, CONST_ME_MAGIC_BLUE) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
        item:remove(1)
        player:addItem(strongEmptyPot, 1)
    elseif itemId == strongManaPot then
        if (not isInArray({1, 2, 3, 5, 6, 7}, target:getVocation():getId()) or target:getLevel() < 50) and not getPlayerFlagValue(player, PlayerFlag_IgnoreSpellCheck) then
            player:say("This potion can only be consumed by sorcerers, druids and paladins of level 50 or higher.", TALKTYPE_MONSTER_SAY)
            return true
        end

        if not doTargetCombatMana(0, target, 115, 185, CONST_ME_MAGIC_BLUE) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
        item:remove(1)
        player:addItem(strongEmptyPot, 1)
    elseif itemId == greatSpiritPot then
        if (not isInArray({3, 7}, target:getVocation():getId()) or target:getLevel() < 80) and not getPlayerFlagValue(player, PlayerFlag_IgnoreSpellCheck) then
            player:say("This potion can only be consumed by paladins of level 80 or higher.", TALKTYPE_MONSTER_SAY)
            return true
        end

        if not doTargetCombatHealth(0, target, COMBAT_HEALING, 250, 350, CONST_ME_MAGIC_BLUE) or not doTargetCombatMana(0, target, 100, 200, CONST_ME_MAGIC_BLUE) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
        item:remove(1)
        player:addItem(greatEmptyPot, 1)
    elseif itemId == greatHealthPot then
        if (not isInArray({4, 8}, target:getVocation():getId()) or target:getLevel() < 80) and not getPlayerFlagValue(player, PlayerFlag_IgnoreSpellCheck) then
            player:say("This potion can only be consumed by knights of level 80 or higher.", TALKTYPE_MONSTER_SAY)
            return true
        end

        if not doTargetCombatHealth(0, target, COMBAT_HEALING, 425, 575, CONST_ME_MAGIC_BLUE) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
        item:remove(1)
        player:addItem(greatEmptyPot, 1)
    elseif itemId == greatManaPot then
        if (not isInArray({1,2,5,6}, target:getVocation():getId()) or target:getLevel() < 80) and not getPlayerFlagValue(player, PlayerFlag_IgnoreSpellCheck) then
            player:say("This potion can only be consumed by sorcerers and druids of level 80 or higher.", TALKTYPE_MONSTER_SAY)
            return true
        end

        if not doTargetCombatMana(0, target, 150, 250, CONST_ME_MAGIC_BLUE) then
            return false
        end
        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
        item:remove(1)
        player:addItem(greatEmptyPot, 1)
    elseif itemId == ultimateHealthPot then
        if (not isInArray({4, 8}, target:getVocation():getId()) or target:getLevel() < 130) and not getPlayerFlagValue(player, PlayerFlag_IgnoreSpellCheck) then
            player:say("This potion can only be consumed by knights of level 130 or higher.", TALKTYPE_MONSTER_SAY)
            return true
        end

        if not doTargetCombatHealth(0, target, COMBAT_HEALING, 650, 850, CONST_ME_MAGIC_BLUE) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
        item:remove(1)
        player:addItem(greatEmptyPot, 1)
    end
    return true
end

Maybe this will help you with something
Post automatically merged:

OP said that he's using TFS 1.2 so I checked here in TFS 1.2 github and I didn't find it in sources, I think that you'll need to add animated text function in your source to use it, ":say" also isn't an option cause it need a creature to be called.

EDIT:

I found out this PR from EPuncker that add back this function with no need to change sources: Adding back sendAnimatedText if client version is lower than 9 by EPuncker · Pull Request #3117 · otland/forgottenserver (https://github.com/otland/forgottenserver/pull/3117/files)

should I replace the red item and add the rest?
 
Last edited:
Thanks for answer :)

if you mean a folder or a file called scr. I don't have one.

found something like this in: data\actions\scripts\other\constructionkits

Lua:
local constructionKits = {
    [3901] = 1666, [3902] = 1670, [3903] = 1652, [3904] = 1674, [3905] = 1658,
    [3906] = 3813, [3907] = 3817, [3908] = 1619, [3909] = 12799, [3910] = 2105,
    [3911] = 1614, [3912] = 3806, [3913] = 3807, [3914] = 3809, [3915] = 1716,
    [3916] = 1724, [3917] = 1732, [3918] = 1775, [3919] = 1774, [3920] = 1750,
    [3921] = 3832, [3922] = 2095, [3923] = 2098, [3924] = 2064, [3925] = 2582,
    [3926] = 2117, [3927] = 1728, [3928] = 1442, [3929] = 1446, [3930] = 1447,
    [3931] = 2034, [3932] = 2604, [3933] = 2080, [3934] = 2084, [3935] = 3821,
    [3936] = 3811, [3937] = 2101, [3938] = 3812, [5086] = 5046, [5087] = 5055,
    [5088] = 5056, [6114] = 6111, [6115] = 6109, [6372] = 6356, [6373] = 6371,
    [8692] = 8688, [9974] = 9975, [11126] = 11127, [11133] = 11129, [11124] = 11125,
    [11205] = 11203, [14328] = 1616, [14329] = 1615, [16075] = 16020, [16099] = 16098,
    [20254] = 20295, [20255] = 20297, [20257] = 20299
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local kit = constructionKits[item.itemid]
    if not kit then
        return false
    end

    if fromPosition.x == CONTAINER_POSITION then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "Put the construction kit on the floor first.")
    elseif not Tile(fromPosition):getHouse() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You may construct this only inside a house.")
    else
        item:transform(kit)
        fromPosition:sendMagicEffect(CONST_ME_POFF)
    end
    return true
end

potions
Lua:
local ultimateHealthPot = 8473
local greatHealthPot = 7591
local greatManaPot = 7590
local greatSpiritPot = 8472
local strongHealthPot = 7588
local strongManaPot = 7589
local healthPot = 7618
local manaPot = 7620
local smallHealthPot = 8704
local antidotePot = 8474
local greatEmptyPot = 7635
local strongEmptyPot = 7634
local emptyPot = 7636

local antidote = Combat()
antidote:setParameter(COMBAT_PARAM_TYPE, COMBAT_HEALING)
antidote:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
antidote:setParameter(COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
antidote:setParameter(COMBAT_PARAM_AGGRESSIVE, false)
antidote:setParameter(COMBAT_PARAM_DISPEL, CONDITION_POISON)

local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, (configManager.getNumber(configKeys.EX_ACTIONS_DELAY_INTERVAL) - 100))
-- 1000 - 100 due to exact condition timing. -100 doesn't hurt us, and players don't have reminding ~50ms exhaustion.

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if target == nil or not target:isPlayer() then
        return true
    end

    if player:getCondition(CONDITION_EXHAUST_HEAL) then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
        return true
    end

    local itemId = item:getId()
    if itemId == antidotePot then
        if not antidote:execute(target, numberToVariant(target:getId())) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
        item:remove(1)
        player:addItem(emptyPot, 1)
    elseif itemId == smallHealthPot then
        if not doTargetCombatHealth(0, target, COMBAT_HEALING, 60, 90, CONST_ME_MAGIC_BLUE) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
        item:remove(1)
        player:addItem(emptyPot, 1)
    elseif itemId == healthPot then
        if not doTargetCombatHealth(0, target, COMBAT_HEALING, 125, 175, CONST_ME_MAGIC_BLUE) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
        item:remove(1)
        player:addItem(emptyPot, 1)
    elseif itemId == manaPot then
        if not doTargetCombatMana(0, target, 75, 125, CONST_ME_MAGIC_BLUE) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
        item:remove(1)
        player:addItem(emptyPot, 1)
    elseif itemId == strongHealthPot then
        if (not isInArray({3, 4, 7, 8}, target:getVocation():getId()) or target:getLevel() < 50) and not getPlayerFlagValue(player, PlayerFlag_IgnoreSpellCheck) then
            player:say("This potion can only be consumed by paladins and knights of level 50 or higher.", TALKTYPE_MONSTER_SAY)
            return true
        end

        if not doTargetCombatHealth(0, target, COMBAT_HEALING, 250, 350, CONST_ME_MAGIC_BLUE) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
        item:remove(1)
        player:addItem(strongEmptyPot, 1)
    elseif itemId == strongManaPot then
        if (not isInArray({1, 2, 3, 5, 6, 7}, target:getVocation():getId()) or target:getLevel() < 50) and not getPlayerFlagValue(player, PlayerFlag_IgnoreSpellCheck) then
            player:say("This potion can only be consumed by sorcerers, druids and paladins of level 50 or higher.", TALKTYPE_MONSTER_SAY)
            return true
        end

        if not doTargetCombatMana(0, target, 115, 185, CONST_ME_MAGIC_BLUE) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
        item:remove(1)
        player:addItem(strongEmptyPot, 1)
    elseif itemId == greatSpiritPot then
        if (not isInArray({3, 7}, target:getVocation():getId()) or target:getLevel() < 80) and not getPlayerFlagValue(player, PlayerFlag_IgnoreSpellCheck) then
            player:say("This potion can only be consumed by paladins of level 80 or higher.", TALKTYPE_MONSTER_SAY)
            return true
        end

        if not doTargetCombatHealth(0, target, COMBAT_HEALING, 250, 350, CONST_ME_MAGIC_BLUE) or not doTargetCombatMana(0, target, 100, 200, CONST_ME_MAGIC_BLUE) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
        item:remove(1)
        player:addItem(greatEmptyPot, 1)
    elseif itemId == greatHealthPot then
        if (not isInArray({4, 8}, target:getVocation():getId()) or target:getLevel() < 80) and not getPlayerFlagValue(player, PlayerFlag_IgnoreSpellCheck) then
            player:say("This potion can only be consumed by knights of level 80 or higher.", TALKTYPE_MONSTER_SAY)
            return true
        end

        if not doTargetCombatHealth(0, target, COMBAT_HEALING, 425, 575, CONST_ME_MAGIC_BLUE) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
        item:remove(1)
        player:addItem(greatEmptyPot, 1)
    elseif itemId == greatManaPot then
        if (not isInArray({1,2,5,6}, target:getVocation():getId()) or target:getLevel() < 80) and not getPlayerFlagValue(player, PlayerFlag_IgnoreSpellCheck) then
            player:say("This potion can only be consumed by sorcerers and druids of level 80 or higher.", TALKTYPE_MONSTER_SAY)
            return true
        end

        if not doTargetCombatMana(0, target, 150, 250, CONST_ME_MAGIC_BLUE) then
            return false
        end
        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
        item:remove(1)
        player:addItem(greatEmptyPot, 1)
    elseif itemId == ultimateHealthPot then
        if (not isInArray({4, 8}, target:getVocation():getId()) or target:getLevel() < 130) and not getPlayerFlagValue(player, PlayerFlag_IgnoreSpellCheck) then
            player:say("This potion can only be consumed by knights of level 130 or higher.", TALKTYPE_MONSTER_SAY)
            return true
        end

        if not doTargetCombatHealth(0, target, COMBAT_HEALING, 650, 850, CONST_ME_MAGIC_BLUE) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
        item:remove(1)
        player:addItem(greatEmptyPot, 1)
    end
    return true
end

Maybe this will help you with something
Post automatically merged:



should I replace the red item and add the rest?
yeah you replace the red and add green, then try to use like in my example before Game.sendAnimatedText(settings.text, settings.position, color), it should work
 
I added and there is still an error:

Lua Script Error: [Main Interface]
data/global.lua
data/lib/core/game.lua:70: attempt to call field 'getClientVersion' (a nil value)
stack traceback:
[C]: in function 'getClientVersion'
data/lib/core/game.lua:70: in main chunk
[C]: in function 'dofile'
data/lib/core/core.lua:4: in main chunk
[C]: in function 'dofile'
data/lib/lib.lua:2: in main chunk
[C]: in function 'dofile'
data/global.lua:1: in main chunk
[Warning - ScriptingManager::loadScriptSystems] Can not load data/global.lua
 
I already had this similar problem, but you have to configure the text animate to see the position, in which case you need another function inside.
{pos = {x=996, y=1002, z=7}, itemid = 1234, tekst = "Trainers"},
doSendAnimatedText(getTileItemById(v.pos, v.itemid ), v.pos, kolor)
 
Last edited:
You can check if I added correctly:

data/lib/compat/compat.lua

Lua:
function doPlayerSendTextMessage(cid, type, text, ...) local p = Player(cid) return p ~= nil and p:sendTextMessage(type, text, ...) or false end
function doSendAnimatedText() debugPrint("Deprecated function.") return true end
if Game.getClientVersion().min < 900 then
    function doSendAnimatedText(pos, text, color, player) Game.sendAnimatedText(text, pos, color, player) return true end
else
    function doSendAnimatedText() debugPrint("Deprecated function.") return true end
end
function doPlayerAddExp(cid, exp, useMult, ...)
    local player = Player(cid)
    if player == nil then
        return false
    end

    if useMult then
        exp = exp * Game.getExperienceStage(player:getLevel())
    end
    return player:addExperience(exp, ...)
end

data/lib/core/game.lua

Lua:
function Game.broadcastMessage(message, messageType)
    if messageType == nil then
        messageType = MESSAGE_STATUS_WARNING
    end

    for _, player in ipairs(Game.getPlayers()) do
        player:sendTextMessage(messageType, message)
    end
end

function Game.convertIpToString(ip)
    local band = bit.band
    local rshift = bit.rshift
    return string.format("%d.%d.%d.%d",
        band(ip, 0xFF),
        band(rshift(ip, 8), 0xFF),
        band(rshift(ip, 16), 0xFF),
        rshift(ip, 24)
    )
end

function Game.getReverseDirection(direction)
    if direction == WEST then
        return EAST
    elseif direction == EAST then
        return WEST
    elseif direction == NORTH then
        return SOUTH
    elseif direction == SOUTH then
        return NORTH
    elseif direction == NORTHWEST then
        return SOUTHEAST
    elseif direction == NORTHEAST then
        return SOUTHWEST
    elseif direction == SOUTHWEST then
        return NORTHEAST
    elseif direction == SOUTHEAST then
        return NORTHWEST
    end
    return NORTH
end

function Game.getSkillType(weaponType)
    if weaponType == WEAPON_CLUB then
        return SKILL_CLUB
    elseif weaponType == WEAPON_SWORD then
        return SKILL_SWORD
    elseif weaponType == WEAPON_AXE then
        return SKILL_AXE
    elseif weaponType == WEAPON_DISTANCE then
        return SKILL_DISTANCE
    elseif weaponType == WEAPON_SHIELD then
        return SKILL_SHIELD
    end
    return SKILL_FIST
end

if not globalStorageTable then
    globalStorageTable = {}
end

function Game.getStorageValue(key)
    return globalStorageTable[key]
end

function Game.setStorageValue(key, value)
    globalStorageTable[key] = value
end

if Game.getClientVersion().min < 900 then
    function Game.sendAnimatedText(message, position, color, player)
        local msg = NetworkMessage()
        msg:addByte(0x84)
        msg:addPosition(position)
        msg:addByte(color)
        msg:addString(message)

        local spectators = nil
        if player ~= nil then
            spectators = {player}
        else
            spectators = Game.getSpectators(position, false, true, 8, 8, 6, 6)
        end

        for i = 1, #spectators do
            msg:sendToPlayer(spectators[i])
        end
        msg:delete()
    end
end
Post automatically merged:

I already had this similar problem, but you have to configure the text animate to see the position, in which case you need another function inside.
doSendAnimatedText(getTileItemById(v.pos, item id on position), v.pos, kolor)
I will be grateful if you write where exactly I should insert it :)
 
try this way in compat.lua:
Lua:
function doPlayerSendTextMessage(cid, type, text, ...) local p = Player(cid) return p ~= nil and p:sendTextMessage(type, text, ...) or false end
function doSendAnimatedText() debugPrint("Deprecated function.") return true end
function doSendAnimatedText(pos, text, color, player) Game.sendAnimatedText(text, pos, color, player) return true end
function doPlayerAddExp(cid, exp, useMult, ...)
    local player = Player(cid)
    if player == nil then
        return false
    end

    if useMult then
        exp = exp * Game.getExperienceStage(player:getLevel())
    end
    return player:addExperience(exp, ...)
end

and this way in game.lua:


Lua:
function Game.broadcastMessage(message, messageType)
    if messageType == nil then
        messageType = MESSAGE_STATUS_WARNING
    end

    for _, player in ipairs(Game.getPlayers()) do
        player:sendTextMessage(messageType, message)
    end
end

function Game.convertIpToString(ip)
    local band = bit.band
    local rshift = bit.rshift
    return string.format("%d.%d.%d.%d",
        band(ip, 0xFF),
        band(rshift(ip, 8), 0xFF),
        band(rshift(ip, 16), 0xFF),
        rshift(ip, 24)
    )
end

function Game.getReverseDirection(direction)
    if direction == WEST then
        return EAST
    elseif direction == EAST then
        return WEST
    elseif direction == NORTH then
        return SOUTH
    elseif direction == SOUTH then
        return NORTH
    elseif direction == NORTHWEST then
        return SOUTHEAST
    elseif direction == NORTHEAST then
        return SOUTHWEST
    elseif direction == SOUTHWEST then
        return NORTHEAST
    elseif direction == SOUTHEAST then
        return NORTHWEST
    end
    return NORTH
end

function Game.getSkillType(weaponType)
    if weaponType == WEAPON_CLUB then
        return SKILL_CLUB
    elseif weaponType == WEAPON_SWORD then
        return SKILL_SWORD
    elseif weaponType == WEAPON_AXE then
        return SKILL_AXE
    elseif weaponType == WEAPON_DISTANCE then
        return SKILL_DISTANCE
    elseif weaponType == WEAPON_SHIELD then
        return SKILL_SHIELD
    end
    return SKILL_FIST
end

if not globalStorageTable then
    globalStorageTable = {}
end

function Game.getStorageValue(key)
    return globalStorageTable[key]
end

function Game.setStorageValue(key, value)
    globalStorageTable[key] = value
end

    function Game.sendAnimatedText(message, position, color, player)
        local msg = NetworkMessage()
        msg:addByte(0x84)
        msg:addPosition(position)
        msg:addByte(color)
        msg:addString(message)

        local spectators = nil
        if player ~= nil then
            spectators = {player}
        else
            spectators = Game.getSpectators(position, false, true, 8, 8, 6, 6)
        end

        for i = 1, #spectators do
            msg:sendToPlayer(spectators[i])
        end
        msg:delete()
    end

this way you should be able to use Game.sendAnimatedText
 
Solution
Lua:
local pozycje = {
    {pos = {x=996, y=1002, z=7}, itemid = 1234, tekst = "Trainers"},
    {pos = {x=1001, y=1001, z=7}, itemid = 1234, tekst = "Tp Room 1"},
    {pos = {x=1002, y=1001, z=7}, itemid = 1234, tekst = "Tp Room 2"},
    {pos = {x=1003, y=999, z=7}, itemid = 1234, tekst = "Quest 1"},
    {pos = {x=1003, y=998, z=7}, itemid = 1234, tekst = "Quest 2"},
    {pos = {x=1038, y=995, z=7}, itemid = 1234, tekst = "Trainers"},
    {pos = {x=995, y=994, z=7}, itemid = 1234, tekst = "Temple"},
    {pos = {x=995, y=1001, z=7}, itemid = 1234, tekst = "House"},
    {pos = {x=995, y=999, z=7}, itemid = 1234, tekst = "House 2"},
    {pos = {x=995, y=996, z=7}, itemid = 1234, tekst = "Npc's"},
    {pos = {x=1028, y=995, z=7}, itemid = 1234, tekst = "Temple"}
    }
   
local config = {
    kolor = TEXTCOLOR_YELLOW, -- kolor napisu
    efekt = CONST_ME_HOLYDAMAGE, -- efekt
    }

function onThink(interval, lastExecution)
    for i, v in pairs(pozycje) do
        doSendMagicEffect(v.pos, config.efekt)
        doSendAnimatedText(getTileItemById(v.pos, v.itemid), v.pos, kolor)
    end
    return true
end
 
The animation works and no bugs are popping up. I am impressed with how you solved it and that you took a lot of time for me to do it.

There must be a special place in heaven for such people 😁

Thank you so much to you and to the rest who tried to help.

If you had any nice scripts that could work for me, I would love to use it, but now it's time to rest a bit.
 
Back
Top