I was wondering if someone could help me/teach me Lua so that I could make a script that would do this function
Citizen | Text Chat Here
Police | Text Chat Here
So if you were a cop it would show that youre a cop when texting in the chat and if youre a citizen then do the same thing but i would eventually want it to be more advanced so i could put custom roles i.e.
Store Clerk | Text Chat Here
State Trooper | Text Chat Here
Police Officer | Text Chat Here
AddEventHandler('chatMessage', function(s, n, m)
if GetPlayerIdentifiers(s)[1] == 'steam:11000011865d06f' then
TriggerClientEvent('chatMessage', -1, 'Citizen | ' .. n, { 255, 0, 0 }, m)
CancelEvent()
end
end)
If you want anyone joining to have civ title then find
if not WasEventCanceled() then
TriggerClientEvent('chatMessage', -1, name, color, message)
end
and change it to
if not WasEventCanceled() then
TriggerClientEvent('chatMessage', -1, 'Citizen | ' name, color, message)
end
Otherwise use for custom titles⌠Thereâs easier way to use this but itâs simple. so.
AddEventHandler('chatMessage', function(s, n, m)
if GetPlayerIdentifiers(s)[1] == 'steam:11000011865d06f' then
TriggerClientEvent('chatMessage', -1, 'Owner | ' .. n, { 255, 0, 0 }, m)
CancelEvent()
end
end)
Just put the code into a .lua along with a __resource.lua that says it is server side code. Then add it to your list of auto start resources.
Code
local groupOne = {"steam:XXXXXXX", "steam:XXXXXXX", "steam:XXXXXXX"}
local groupTwo = {"steam:XXXXXXX", "steam:XXXXXXX", "steam:XXXXXXX"}
local sent
AddEventHandler('chatMessage', function(s, n, m)
CancelEvent()
sent = false
for i=1, #groupOne do
if GetPlayerIdentifiers(s)[1] == groupOne[i] then
TriggerClientEvent('chatMessage', -1, "GroupOne | " .. n, { 255, 0, 0 }, m)
elseif GetPlayerIdentifiers(s)[1] == groupTwo[i] then
TriggerClientEvent('chatMessage', -1, "GroupTwo | " .. n, { 255, 0, 0 }, m)
elseif sent == false
TriggerClientEvent('chatMessage', -1, "None | " .. n, { 255, 0, 0 }, m)
sent = true
end
end
end)
When you use a command such as the ones in the EssentialMode admin plugin, the command works but it shows the command after. Is there a way to fix this?
When you use a command such as the ones in the EssentialMode admin plugin, the command works but it shows the command after. Is there a way to fix this? <
Try adding CancelEvent() somewhere in the code that handles the commands.
local Director = {âsteam:XXXXXXXâ, âsteam:XXXXXXXâ, âsteam:XXXXXXXâ}
local Rockwall County Sheriffs Office = {âsteam:XXXXXXXâ, âsteam:XXXXXXXâ, âsteam:XXXXXXXâ}
local Rockwall Police Department = {âsteam:XXXXXXXâ, âsteam:XXXXXXXâ, âsteam:XXXXXXXâ}
local Texas Department of Public Safety = {âsteam:XXXXXXXâ, âsteam:XXXXXXXâ, âsteam:XXXXXXXâ}
local Civilian = {âsteam:XXXXXXXâ, âsteam:XXXXXXXâ, âsteam:XXXXXXXâ}
local sent
AddEventHandler(âchatMessageâ, function(s, n, m)
CancelEvent()
sent = false
for i=1, #groupOne do
if GetPlayerIdentifiers(s)[1] == groupOne[i] then
TriggerClientEvent(âchatMessageâ, -1, "GroupOne | " ⌠n, { 255, 0, 0 }, m)
elseif GetPlayerIdentifiers(s)[1] == groupTwo[i] then
TriggerClientEvent(âchatMessageâ, -1, "GroupTwo | " ⌠n, { 255, 0, 0 }, m)
elseif sent == false
TriggerClientEvent(âchatMessageâ, -1, "None | " ⌠n, { 255, 0, 0 }, m)
sent = true
end
end
end)
Well the variable names canât have spaces, so Director is fine but Rockwall County Sherrifs Office would need to be changed to something like RCSO or Rockwall_County⌠Same for the other names.
Then just change: if GetPlayerIdentifiers(s)[1] == groupOne[i] then
to if GetPlayerIdentifiers(s)[1] == Director[i] then
and add more elseif statements which have your other tables.
Also just to make sure, you gotta change âsteam:XXXXXXâ to actual steam IDs in that format