Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: drp and pause menu text #239

Merged
merged 6 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions client/discord.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
local playersConnected = GlobalState.PlayerCount

AddStateBagChangeHandler('PlayerCount', nil, function(bagName, _, value)
if bagName ~= 'global' or not value then return end
playersConnected = value
end)

CreateThread(function()
while true do
SetDiscordAppId(Config.Discord.AppId)
SetDiscordRichPresenceAsset(Config.Discord.LargeIcon.icon)
SetDiscordRichPresenceAssetText(Config.Discord.LargeIcon.text)
SetDiscordRichPresenceAssetSmall(Config.Discord.SmallIcon.icon)
SetDiscordRichPresenceAssetSmallText(Config.Discord.SmallIcon.text)
SetRichPresence(('Players %s/'..Config.MaxPlayers):format(playersConnected))
mafewtm marked this conversation as resolved.
Show resolved Hide resolved
SetDiscordRichPresenceAction(0, Config.Discord.FirstButton.text, Config.Discord.FirstButton.link)
SetDiscordRichPresenceAction(1, Config.Discord.SecondButton.text, Config.Discord.SecondButton.link)
Wait(60000)
mafewtm marked this conversation as resolved.
Show resolved Hide resolved
end
end)
6 changes: 6 additions & 0 deletions client/loops.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ CreateThread(function()
end
end
end)

CreateThread(function()
local mapText = Config.Server.PauseMapText
if mapText == '' or type(mapText) ~= 'string' then mapText = 'FiveM' end
Citizen.InvokeNative(joaat('ADD_TEXT_ENTRY'), 'FE_THDR_GTAO', mapText)
mafewtm marked this conversation as resolved.
Show resolved Hide resolved
end)
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
Loading