• 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 Animated Text in lua

bayview

Banned User
Joined
Jan 25, 2018
Messages
611
Solutions
25
Reaction score
324
I don't like to mess with the sources if i don't have to and i seen this thread
Animated Text Support for OT Client 10.98/99 - TFS 1.3

I already know its possible to do this in lua without a source edit but how can it be done for both clients? Here is my working code.
Lua:
-- is not compatible for regular tibia clients (atm)
local function sendColorText(message, color, pos, send, cid)
    local player = Player(cid)
    if not player then
        return
    end
    local clientid = player:getClient()['os']
    if clientid > 3 then
        local msg = NetworkMessage()
        msg:addByte(0x84)
        msg:addPosition(pos)
        msg:addByte(color)
        msg:addString(message)
        if send and next(send) then
            for i = 1, #send do
                if pos:getDistance(send[i]:getPosition()) <= 7 then
                    msg:sendToPlayer(send[i])
                end
            end
        end
    else
        player:say(message, TALKTYPE_MONSTER_SAY, false, nil, pos)
    end
end
--[[
    CLIENTOS_NONE = 0,

    CLIENTOS_LINUX = 1,
    CLIENTOS_WINDOWS = 2,
    CLIENTOS_FLASH = 3,

    CLIENTOS_OTCLIENT_LINUX = 10,
    CLIENTOS_OTCLIENT_WINDOWS = 11,
    CLIENTOS_OTCLIENT_MAC = 12,
]]

function Creature:sendColorText(message, pos, color, interval, canSee)
    --// Creature:sendColorText(message, position, color[, interval[, canSee]])
  
    local specs = Game.getSpectators(pos, false, true, 0, 8, 0, 6)
    local send = {}
    for i = 1, #specs do
        -- send to specific names
        if (canSee and next(canSee)) and isInArray(canSee, specs[i]:getName()) then
            send[#send+1] = specs[i]
        else
            -- or send it to everyone
            send[#send+1] = specs[i]
        end
    end
    send = (next(send) and send) or specs
    interval = type(color) == 'table' and #color or interval
    for x = 1, interval do
        if type(color) == 'table' then
            addEvent(sendColorText, 1000 * x, message, color[x], pos, send, self:getId())
        else
            addEvent(sendColorText, 1000 * x, message, color, pos, send, self:getId())
        end
    end
    return true
end
I've tested this and when if 1 client is tibia client and the other is otclient then the regular tibia client crashes while the otclient does not.

The issue here is I would like the animated text to appear as colored texted only for otclient and monster say or monster text for only the tibia client.

I posted this in Mods & Lua as is until I guess I can find a solution other than not sending animated text to the regular client.
 
Last edited:
Back
Top