script_name("CLIST TO CHAT")
script_author("Meow Brightside")
local res = pcall(require, "lib.moonloader") assert(res, "Lib MOONLOADER not found!")
local res = pcall(require, 'lib.sampfuncs') assert(res, 'Lib SAMPFUNCS not found')
local res, hook = pcall(require, 'lib.samp.events') assert(res, 'Lib SAMP Events not found')
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
sampAddChatMessage("[Clist chat]: {FFFFFF}Loaded", 0xAE433D)
wait(-1)
end
function hook.onServerMessage(color, text)
if text:find("%w+_%w+%: .*") then
local nick = text:match("(%w+_%w+)%:")
local hexcolorchat = ("%06X"):format(bit.band(color, 0xFFFFFF))
local id = sampGetPlayerIdByNickname(nick)
local hexplayercolor = ("%06X"):format(bit.band(sampGetPlayerColor(id), 0xFFFFFF))
text = text:gsub(nick, "{"..string.upper(hexplayercolor).."}"..nick.."{"..string.upper(hexcolorchat).."}")
return {color, text}
end
end
function sampGetPlayerIdByNickname(nick)
local _, myid = sampGetPlayerIdByCharHandle(playerPed)
if tostring(nick) == sampGetPlayerNickname(myid) then return myid end
for i = 0, 1000 do if sampIsPlayerConnected(i) and sampGetPlayerNickname(i) == tostring(nick) then return i end end
end