From e62bd9d53cf1b61f8227e8384145666ab55b66b3 Mon Sep 17 00:00:00 2001 From: Joseph Unitt <43848673+unitt99@users.noreply.github.com> Date: Mon, 18 Nov 2024 16:52:45 +0000 Subject: [PATCH 1/5] Update .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 96bf815d..1e8f5b91 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,6 @@ banlist.xml # Personal .vscode +mods/deathmatch/libcrypto-3.dll +mods/deathmatch/libssl-3.dll +mods/deathmatch/mta_mysql.dll From e4e49b2bb696e6d901fadd8b8e5443e9ddca2a11 Mon Sep 17 00:00:00 2001 From: Joseph Unitt <43848673+unitt99@users.noreply.github.com> Date: Mon, 18 Nov 2024 19:00:16 +0000 Subject: [PATCH 2/5] Better Rich Presence Support. --- .../resources/account/s_characters.lua | 3 ++ .../resources/discord/c_discord.lua | 37 +++++++++++++++++++ mods/deathmatch/resources/discord/meta.xml | 6 +++ .../resources/discord/s_discord.lua | 20 ++++++++++ mods/deathmatch/settings.xml.bak | 3 ++ 5 files changed, 69 insertions(+) create mode 100644 mods/deathmatch/resources/discord/c_discord.lua create mode 100644 mods/deathmatch/resources/discord/meta.xml create mode 100644 mods/deathmatch/resources/discord/s_discord.lua diff --git a/mods/deathmatch/resources/account/s_characters.lua b/mods/deathmatch/resources/account/s_characters.lua index 4ef42545..e681e8c0 100644 --- a/mods/deathmatch/resources/account/s_characters.lua +++ b/mods/deathmatch/resources/account/s_characters.lua @@ -518,6 +518,9 @@ function spawnCharacter(characterID, remoteAccountID, theAdmin, targetAccountNam if freshSpawn then triggerEvent( "social:look", client, client, ":edit" ) end + + -- update discord + triggerClientEvent(client, "discord:updateRPC", client) end end addEventHandler("accounts:characters:spawn", getRootElement(), spawnCharacter) diff --git a/mods/deathmatch/resources/discord/c_discord.lua b/mods/deathmatch/resources/discord/c_discord.lua new file mode 100644 index 00000000..f98e1db4 --- /dev/null +++ b/mods/deathmatch/resources/discord/c_discord.lua @@ -0,0 +1,37 @@ +-- Update function. +function updateRPC() + if isDiscordRichPresenceConnected() then + local name = getPlayerName(localPlayer) + + local currentPlayers = getElementsByType("player") + local maxPlayers = getElementData(root, "server:Slots") or 1024 + + if getElementData(localPlayer, "loggedin") == 0 then + setDiscordRichPresenceDetails("Logging into OwlGaming...") + else + setDiscordRichPresenceDetails("Playing as: "..name:gsub("_", " ")) + end + + setDiscordRichPresenceState("Currently " .. #currentPlayers .. "/" .. maxPlayers .. " playing!") + end +end +addEvent("discord:updateRPC", true) +addEventHandler("discord:updateRPC", root, updateRPC) + +function connectRPC(appId) + -- reset + resetDiscordRichPresenceData() + + -- set discord ApplicationID + setDiscordApplicationID(appId) + + -- force an update. + updateRPC() +end +addEvent("discord:connectRPC", true) +addEventHandler("discord:connectRPC", root, connectRPC) + +-- prevents the rich presence bugging. +addEventHandler("onClientResourceStop", resourceRoot, function() + resetDiscordRichPresenceData() +end) \ No newline at end of file diff --git a/mods/deathmatch/resources/discord/meta.xml b/mods/deathmatch/resources/discord/meta.xml new file mode 100644 index 00000000..1d3f4233 --- /dev/null +++ b/mods/deathmatch/resources/discord/meta.xml @@ -0,0 +1,6 @@ + + + +