I haven't managed to make this work for the regular tibia client but that doesn't mean it shouldn't be released because it can be used for otclient and without editing the sources.
Place this in data\lib\core\creature.lua at the bottom of the page.
Place this in data\lib\core\creature.lua at the bottom of the page.
Lua:
--[[
CLIENTOS_NONE = 0,
CLIENTOS_LINUX = 1,
CLIENTOS_WINDOWS = 2,
CLIENTOS_FLASH = 3,
CLIENTOS_OTCLIENT_LINUX = 10,
CLIENTOS_OTCLIENT_WINDOWS = 11,
CLIENTOS_OTCLIENT_MAC = 12,
]]
local function sendColorText(message, color, pos, send, cid)
local player = Player(cid)
if not player then
return
end
-- this could also be handled inside of the calling function instead
local clientid = player:getClient()['os']
-- if the player is using otclient
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
end
end
function Creature:sendColorText(message, pos, color, interval, canSee)
-- Creature:sendColorText(message, position, color[, interval[, canSee]])
if not self then
return
end
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