Custom Roles In Text Chat

dam wow wish id could help but i am playing with your script now… no luck

So when I add this:

AddEventHandler('chatMessage', function(s, n, m)
        TriggerClientEvent('chatMessage', -1, 'Citizen | ' .. n, { 255, 0, 0 }, m)
	CancelEvent()
    end
end)

It only pops up saying Citizen | : whatevertheysaid in chat. it doesnt preffix the persons actual name, just replaces it 0.o
the admin and owner ones work flawlessly though…?

Can this be done with IP’s and not Steam ID?

Steam ids are for only when you use steam. ips are for when steam is not running but some servers require steam. but yes, you can use both.

@Al_Rib Yeah I don’t require Steam for my server I wanted to assign them by IP, However I am not get any of this code to work " Most likely something on my end" I just didn’t know how to implement ip… would it be

local Sheriff = {“ip:0.0.0.0”} Or local Sheriff = {“IP:0.0.0.0”} ?

“ip:x.x.x.x” I never got the script to work, but you can try

Following this thread - where you have function(s, n, m) where are the parameters passed in? Is this handled by the framework or…?

Hey can u add me on discord to help me set up a server please?

discord: helicopter#6991

I had this error:

Error parsing script sv_chat.lua in resource chatholes: sv_chat.lua:19: ‘then’ expected near ‘TriggerClientEvent’

So I put “then” after “false” in line 13

elseif sent == false then” like that.

As a newbie programmer, i dont know if it is right. But it worked.

Anyone know how to fix this? Error thrown by mychat roles which worked perfectly on CFX.

Error running system event handling function for resource chatrole: citizen:/scripting/lua/scheduler.lua:41: Failed to execute thread: mychat.lua:84: bad argument #1 to ‘for iterator’ (table expected, got nil)
[ 958656] stack traceback:
[ 958656] [C]: in for iterator ‘for iterator’
[ 958672] mychat.lua:84: in function ‘has_value’
[ 958672] mychat.lua:54: in upvalue ‘handler’
[ 958672] citizen:/scripting/lua/scheduler.lua:163: in function citizen:/scripting/lua/scheduler.lua:162
[ 958672] stack traceback:
[ 958672] [C]: in function ‘error’
[ 958672] citizen:/scripting/lua/scheduler.lua:41: in field ‘CreateThreadNow’
[ 958672] citizen:/scripting/lua/scheduler.lua:162: in function citizen:/scripting/lua/scheduler.lua:131

@NYKILLA1127 If you show the code that you used, especially the parts around line 84, then we can check what’s wrong.

https://pastebin.com/fv0ykXme

Change this (around line 82)

function has_value (tab, val)
    for index, value in ipairs(tab) do

to this:

function has_value (tab, val)
    for index, value in pairs(tab) do

I think that should fix your problem.

May i ask, why hardcode the steam id’s? You already have a DB with roles defined, why not use them?

their is a chat script that all you do it enter the steams

this is a old topic. this code was not optimized for FXServer that I know of. i wouldnt use it if i were you.

How i can make this script to use for groups? (ex: superadmin)

I did this

— DO NOT REMOVE ME FROM THE CONFIG, ITS THERE TO GIVE ME CREDIT WHEN I JOIN SERVERS.
— DO NOT REMOVE ME FROM THE CONFIG, ITS THERE TO GIVE ME CREDIT WHEN I JOIN SERVERS.
— DO NOT REMOVE ME FROM THE CONFIG, ITS THERE TO GIVE ME CREDIT WHEN I JOIN SERVERS.
— DO NOT REMOVE ME FROM THE CONFIG, ITS THERE TO GIVE ME CREDIT WHEN I JOIN SERVERS.
— DO NOT REMOVE ME FROM THE CONFIG, ITS THERE TO GIVE ME CREDIT WHEN I JOIN SERVERS.
— IP’S ARE BROKEN DO NOT USE
— IP’S ARE BROKEN DO NOT USE
— IP’S ARE BROKEN DO NOT USE
— IP’S ARE BROKEN DO NOT USE
— IP’S ARE BROKEN DO NOT USE

local Founders = {“steam:”, “steam:”}
local Director = {"", “”}
local CoDirector = {"", “”}
local Communitymanager = {"", “”}
local HeadAdministrator = {"", “”}
local Admin = {"", “” ,"", “” , “”}
local HighwayPatrol = {""}
local Fire = {""}
local LSPD = {""}
local Sheriff = {""}
local Moderator = {""}
local StateTroopers = {""}
local Test = {""}
local ScriptCreator = {“steam:110000108ce69e8”}

AddEventHandler(‘chatMessage’, function(Source, Name, Msg)
args = stringsplit(Msg, " ")
CancelEvent()
if string.find(args[1], “/”) then
local cmd = args[1]
table.remove(args, 1)
else
local player = GetPlayerIdentifiers(Source)[1]
if has_value(Founders, player) then
TriggerClientEvent(‘chatMessage’, -1, "Founders | " … Name, { 255, 0, 0 }, Msg)
elseif has_value(Admin, player) then
if has_value(Director, player) then
TriggerClientEvent(‘chatMessage’, -1, "Director | " … Name, { 255, 0, 0 }, Msg)
elseif has_value(Admin, player) then
if has_value(Co-Director, player) then
TriggerClientEvent(‘chatMessage’, -1, "CoDirector | " … Name, { 255, 0, 0 }, Msg)
elseif has_value(Admin, player) then
if has_value(Community-manager, player) then
TriggerClientEvent(‘chatMessage’, -1, "Communitymanager | " … Name, { 255, 0, 0 }, Msg)
elseif has_value(Admin, player) then
TriggerClientEvent(‘chatMessage’, -1, "Admin | " … Name, { 255, 0, 0 }, Msg)
if has_value(Head-Administrator, player) then
TriggerClientEvent(‘chatMessage’, -1, "HeadAdministrator | " … Name, { 255, 0, 0 }, Msg)
elseif has_value(Admin, player) then
if has_value(Admin, player) then
TriggerClientEvent(‘chatMessage’, -1, "Admin | " … Name, { 255, 0, 0 }, Msg)
elseif has_value(Admin, player) then
elseif has_value(SAST, player) then
TriggerClientEvent(‘chatMessage’, -1, "SAST | " … Name, { 0, 0, 255 }, Msg)
elseif has_value(LSFD, player) then
TriggerClientEvent(‘chatMessage’, -1, "LSFD | " … Name, { 0, 0, 255 }, Msg)
elseif has_value(LSPD, player) then
TriggerClientEvent(‘chatMessage’, -1, "LSPD | " … Name, { 0, 0, 255 }, Msg)
elseif has_value(BCSO, player) then
TriggerClientEvent(‘chatMessage’, -1, "BCSO | " … Name, { 0, 0, 255 }, Msg)
elseif has_value(Moderator, player) then
TriggerClientEvent(‘chatMessage’, -1, "Moderator | " … Name, { 0, 255, 247 }, Msg)
elseif has_value(ScriptCreator, player) then
TriggerClientEvent(‘chatMessage’, -1, "Chat Roles Creator | " … Name, { 0, 255, 43 }, Msg)
else
TriggerClientEvent(‘chatMessage’, -1, "Civilian | " … Name, { 235, 214, 51 }, Msg)
end

end

end)

function has_value (tab, val)
for index, value in ipairs(tab) do
if value == val then
return true
end
end

return false

end

function stringsplit(inputstr, sep)
if sep == nil then
sep = “%s”
end
local t={} ; i=1
for str in string.gmatch(inputstr, “([^”…sep…"]+)") do
t[i] = str
i = i + 1
end
return t
end

—ALLOWS YOU TO CHECK VERSIONS IN GAME

AddEventHandler(‘chatMessage’, function(source, name, msg)
if msg:sub(1, 1) == “/” then
sm = stringsplit(msg, " ");
if sm[1] == “/fversion” then
CancelEvent()
TriggerClientEvent(‘chatMessage’, source, “^0[^1RolesFX Script Version Check^0]”, {30, 144, 255}, " ^2Version 1.1.0 | RolesFX By Jay Gatsby!^0 ) " … string.sub(msg,11)
end
end

end)

—PRINTS THIS CODE BELOW TO THE CONSOLE

print(‘Jays Roles FX has loaded in to the server! Type in chat to test it out!’)

— IP’S ARE BROKEN DO NOT USE
— IP’S ARE BROKEN DO NOT USE
— IP’S ARE BROKEN DO NOT USE
— IP’S ARE BROKEN DO NOT USE
— IP’S ARE BROKEN DO NOT USE
— IP’S ARE BROKEN DO NOT USE
— IP’S ARE BROKEN DO NOT USE
— IP’S ARE BROKEN DO NOT USE
— IP’S ARE BROKEN DO NOT USE
— IP’S ARE BROKEN DO NOT USE
— IP’S ARE BROKEN DO NOT USE
but get this error and don’t see it

Creating script environments for rolesFX
Error parsing script @rolesFX/sv_chat.lua in resource rolesFX: @rolesFX/sv_chat.lua:74: unexpected symbol near ‘)’
Failed to load script sv_chat.lua.

This script has what you are looking for [Release] FiveM Chat | NCCPack | FiveM Chat With Changeable Name & More! (Non-ESX)