RegisterServerEvent('chat:init') RegisterServerEvent('chat:addTemplate') RegisterServerEvent('chat:addMessage') RegisterServerEvent('chat:addSuggestion') RegisterServerEvent('chat:removeSuggestion') RegisterServerEvent('_chat:messageEntered') RegisterServerEvent('chat:clear') RegisterServerEvent('__cfx_internal:commandFallback') AddEventHandler('_chat:messageEntered', function(author, color, message) if not message or not author then return end TriggerEvent('chatMessage', source, author, message) if not WasEventCanceled() then --TriggerClientEvent('chatMessage', -1, 'OOC | '..author, false, message) end end) AddEventHandler('__cfx_internal:commandFallback', function(command) local name = GetPlayerName(source) TriggerEvent('chatMessage', source, name, '/' .. command) if not WasEventCanceled() then TriggerClientEvent('chatMessage', -1, name, false, '/' .. command) end CancelEvent() end) -- player join messages AddEventHandler('chat:init', function() --TriggerClientEvent('chatMessage', -1, '', { 255, 255, 255 }, '^2* ' .. GetPlayerName(source) .. ' joined.') end) AddEventHandler('playerDropped', function(reason) --TriggerClientEvent('chatMessage', -1, '', { 255, 255, 255 }, '^2* ' .. GetPlayerName(source) ..' left (' .. reason .. ')') end) -- command suggestions for clients local function refreshCommands(player) if GetRegisteredCommands then local registeredCommands = GetRegisteredCommands() local suggestions = {} for _, command in ipairs(registeredCommands) do if IsPlayerAceAllowed(player, ('command.%s'):format(command.name)) then table.insert(suggestions, { name = '/' .. command.name, help = '' }) end end TriggerClientEvent('chat:addSuggestions', player, suggestions) end end AddEventHandler('chat:init', function() refreshCommands(source) end) AddEventHandler('onServerResourceStart', function(resName) Wait(500) for _, player in ipairs(GetPlayers()) do refreshCommands(player) end end) -- QBCore.Commands.Add('police', 'Police message.', {}, false, function(source, args) -- -- If From Console -- if source == 0 then -- TriggerClientEvent('chat:addMessage', -1, { -- template = '
{0} Police
', -- args = { args } -- }) -- TriggerEvent('barbaronn:SendWebhookDiscordMsg', Config.Logs, "CONSOLE", "```[Police] " .. args .. "```" ) -- return -- end -- -- Emojis Stuff -- args = table.concat(args, ' ') -- args = args:gsub("%:heart:", "❤️") -- args = args:gsub("%:smile:", "🙂") -- args = args:gsub("%:thinking:", "🤔") -- args = args:gsub("%:check:", "✅") -- args = args:gsub("%:hot:", "🥵") -- args = args:gsub("%:sad:", "😦") -- -- Permmisions Stuff -- local xPlayer = QBCore.Functions.GetPlayer(source) -- if xPlayer.PlayerData.job ~= nil and xPlayer.PlayerData.job.name == 'police' then -- TriggerClientEvent('chat:addMessage', -1, { -- template = '
Police {0}
', -- args = { args } -- }) -- else -- TriggerClientEvent('chat:addMessage', source, { -- template = '
ADMIN You are not a police officer
', -- args = {} -- }) -- end -- -- Logs Stuff -- TriggerEvent('barbaronn:SendWebhookDiscordMsg', Config.Logs, GetPlayerName(source) .. " | " .. GetPlayerIdentifiers(source)[1], "```[Police] " .. args .. "```" ) -- end) -- QBCore.Commands.Add('ems', 'EMS Message.', {}, false, function(source, args) -- -- If From Console -- if source == 0 then -- TriggerClientEvent('chat:addMessage', -1, { -- template = '
{0} EMS
', -- args = { args } -- }) -- TriggerEvent('barbaronn:SendWebhookDiscordMsg', Config.Logs, "CONSOLE", "```[Police] " .. args .. "```" ) -- return -- end -- -- Emojis Stuff -- args = table.concat(args, ' ') -- args = args:gsub("%:heart:", "❤️") -- args = args:gsub("%:smile:", "🙂") -- args = args:gsub("%:thinking:", "🤔") -- args = args:gsub("%:check:", "✅") -- args = args:gsub("%:hot:", "🥵") -- args = args:gsub("%:sad:", "😦") -- -- Permmisions Stuff -- local xPlayer = QBCore.Functions.GetPlayer(source) -- if xPlayer.PlayerData.job ~= nil and xPlayer.PlayerData.job.name == 'ambulance' then -- TriggerClientEvent('chat:addMessage', -1, { -- template = '
EMS {0}
', -- args = { args } -- }) -- else -- TriggerClientEvent('chat:addMessage', source, { -- template = '
ADMIN You are not an EMS employer
', -- args = {} -- }) -- end -- -- Logs Stuff -- TriggerEvent('barbaronn:SendWebhookDiscordMsg', Config.Logs, GetPlayerName(source) .. " | " .. GetPlayerIdentifiers(source)[1], "```[Police] " .. args .. "```" ) -- end) -- RegisterCommand('staff', function(source, args, rawCommand) -- -- If From Console -- if source == 0 then -- TriggerClientEvent('chat:addMessage', -1, { -- template = '
ADMIN: {0}
', -- args = { args } -- }) -- return -- end -- -- Emojis Stuff -- args = table.concat(args, ' ') -- args = args:gsub("%:heart:", "❤️") -- args = args:gsub("%:smile:", "🙂") -- args = args:gsub("%:thinking:", "🤔") -- args = args:gsub("%:check:", "✅") -- args = args:gsub("%:hot:", "🥵") -- args = args:gsub("%:sad:", "😦") -- -- Permmisions Stuff -- local xPlayerGroup = QBCore.Functions.GetPermission(source) -- if xPlayerGroup ~= nil and xPlayerGroup ~= "user" then -- TriggerClientEvent('chat:addMessage', -1, { -- template = '
ADMIN: {0}
', -- args = { args } -- }) -- else -- TriggerClientEvent('chat:addMessage', source, { -- template = '
ADMIN You are not a staff member
', -- args = {} -- }) -- end -- -- Logs Stuff -- TriggerEvent('barbaronn:SendWebhookDiscordMsg', Config.Logs, GetPlayerName(source) .. " | " .. GetPlayerIdentifiers(source)[1], "```[Police] " .. args .. "```" ) -- end, false)