From ea8282558d30f7a7d26d844511539278d5caadc0 Mon Sep 17 00:00:00 2001 From: Matthew <22198949+MafewTM@users.noreply.github.com> Date: Sun, 12 Nov 2023 23:09:44 -0500 Subject: [PATCH] feat: moved discord rich precense and pause menu text from smallresources into core * feat: drp and pause menu text * fix: invoke native directly * fix: drp * fix: native * fix: var --------- Co-authored-by: Manason --- client/discord.lua | 13 +++++++++++++ client/main.lua | 4 ++++ config.lua | 20 ++++++++++++++++++++ fxmanifest.lua | 1 + 4 files changed, 38 insertions(+) create mode 100644 client/discord.lua diff --git a/client/discord.lua b/client/discord.lua new file mode 100644 index 000000000..095fa10f0 --- /dev/null +++ b/client/discord.lua @@ -0,0 +1,13 @@ +AddStateBagChangeHandler('PlayerCount', nil, function(bagName, _, value) + if bagName ~= 'global' or not value then return end + local players = 'Players %s/' .. Config.MaxPlayers + SetRichPresence((players):format(value)) +end) + +SetDiscordAppId(Config.Discord.AppId) +SetDiscordRichPresenceAsset(Config.Discord.LargeIcon.icon) +SetDiscordRichPresenceAssetText(Config.Discord.LargeIcon.text) +SetDiscordRichPresenceAssetSmall(Config.Discord.SmallIcon.icon) +SetDiscordRichPresenceAssetSmallText(Config.Discord.SmallIcon.text) +SetDiscordRichPresenceAction(0, Config.Discord.FirstButton.text, Config.Discord.FirstButton.link) +SetDiscordRichPresenceAction(1, Config.Discord.SecondButton.text, Config.Discord.SecondButton.link) diff --git a/client/main.lua b/client/main.lua index e50cb9a7d..c829527f9 100644 --- a/client/main.lua +++ b/client/main.lua @@ -59,3 +59,7 @@ end) lib.callback.register('qbx_core:client:setHealth', function(health) SetEntityHealth(cache.ped, health) end) + +local mapText = Config.Server.PauseMapText +if mapText == '' or type(mapText) ~= 'string' then mapText = 'FiveM' end +AddTextEntry('FE_THDR_GTAO', mapText) \ No newline at end of file diff --git a/config.lua b/config.lua index 4d5da8f21..9d0d23d20 100644 --- a/config.lua +++ b/config.lua @@ -109,9 +109,29 @@ Config.Server.PVP = true -- Enable or disable pvp on the server (Ability to shoo Config.Server.Discord = "" -- Discord invite link Config.Server.CheckDuplicateLicense = true -- Check for duplicate rockstar license on join Config.Server.Permissions = { 'god', 'admin', 'mod' } -- Add as many groups as you want here after creating them in your server.cfg +Config.Server.PauseMapText = 'Powered by Qbox' -- Text shown above the map when ESC is pressed. If left empty 'FiveM' will appear Config.NotifyPosition = 'top-right' -- 'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left' +Config.Discord = {} -- Discord Rich Presence config +Config.Discord.AppId = '' -- This is the Application ID (Replace this with you own) +Config.Discord.LargeIcon = { -- To set this up, visit https://forum.cfx.re/t/how-to-updated-discord-rich-presence-custom-image/157686 + icon = 'logo_name', -- Here you will have to put the image name for the 'large' icon. + text = 'This is a large icon with text', -- Here you can add hover text for the 'large' icon. +} +Config.Discord.SmallIcon = { + icon = 'logo_name', -- Here you will have to put the image name for the 'small' icon. + text = 'This is a small icon with text', -- Here you can add hover text for the 'small' icon. +} +Config.Discord.FirstButton = { + text = 'First Button!', + link = 'fivem://connect/localhost:30120', +} +Config.Discord.SecondButton = { + text = 'Second Button!', + link = 'fivem://connect/localhost:30120', +} + ---@alias TableName string ---@alias ColumnName string diff --git a/fxmanifest.lua b/fxmanifest.lua index ed738de41..890f89606 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -19,6 +19,7 @@ client_scripts { 'client/loops.lua', 'client/events.lua', 'client/character.lua', + 'client/discord.lua', 'bridge/qb/client/drawtext.lua', 'bridge/qb/client/events.lua', }