Skip to content

Commit

Permalink
feat: moved discord rich precense and pause menu text from smallresou…
Browse files Browse the repository at this point in the history
…rces into core

* feat: drp and pause menu text

* fix: invoke native directly

* fix: drp

* fix: native

* fix: var

---------

Co-authored-by: Manason <clanerp@gmail.com>
  • Loading branch information
mafewtm and Manason authored Nov 13, 2023
1 parent ab8e061 commit ea82825
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
13 changes: 13 additions & 0 deletions client/discord.lua
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 4 additions & 0 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
20 changes: 20 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
Expand Down

0 comments on commit ea82825

Please sign in to comment.