Skip to content

Commit

Permalink
Added Default Prefix (v1.2.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
69u committed Dec 2, 2022
1 parent 6c41a39 commit f4b9b23
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
4 changes: 3 additions & 1 deletion config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ config = {}

config.identity = false --If you are using esx_identity then make it true to get rp names on chat

config.DiscordWebhook = false -- Set to your Discord Webhook URL (https://discord.com/api/webhooks/xxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
config.DiscordWebhook = false -- Set to your Discord Webhook URL (https://discord.com/api/webhooks/xxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)

config.DefaultPrefix = 'ooc' -- Set this to the registered command name you want to use as your default chat prefix, you can set this to false to disable
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version '1.1.1'
version '1.2.0'
author 'Concept Collective'
description 'A FiveM RP Chat resource utilising cc-chat.'

Expand Down
19 changes: 19 additions & 0 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@ AddEventHandler('onResourceStart', function(resourceName)
print('^1================^0')
end
end, 'GET', '')
if config.DefaultPrefix then
AddEventHandler('chatMessage', function(source, name, message)
local playerName
if config.identity then
playerName = xPlayer.getName()
else
playerName = GetPlayerName(source)
end
if config.DefaultPrefix == 'ooc' then
TriggerClientEvent('cc-rpchat:addMessage', -1, '#3498db', 'fa-solid fa-globe', 'OOC | '..playerName, message)
elseif config.DefaultPrefix == 'me' then
TriggerClientEvent('cc-rpchat:addMessage', -1, '#f39c12', 'fa-solid fa-person', 'Me | '..playerName, message)
elseif config.DefaultPrefix == 'do' then
TriggerClientEvent('cc-rpchat:addMessage', -1, '#2ecc71', 'fa-solid fa-person-digging', 'Do | '..playerName, message)
elseif config.DefaultPrefix == 'twt' then
TriggerClientEvent('cc-rpchat:addMessage', -1, '#2980b9', 'fa-brands fa-twitter', '@'..playerName, message)
end
end)
end
end)

RegisterCommand('ooc', function(source, args, rawCommand)
Expand Down

0 comments on commit f4b9b23

Please sign in to comment.