Skip to content

Conversation

@0x416c69
Copy link
Contributor

As discussed in #721 I've implemented it.

There is a new library added to the mta path, called discord_game_sdk.dll
I think there should be client verification for this, I'm not sure.

Also it's best to request Discord for the official MTA:SA game so we can use spectate feature too.

My friend @Deihim007 suggested this in the first place.

Ali Gerami.

std::lock_guard<std::mutex> guardian(m_threadSafety);
m_storedActivity.SetDetails("Retrieving server name...");
m_storedActivity.GetAssets().SetSmallText(SString("Connected to %s:%i", *ipaddr, port));
m_storedActivity.GetAssets().SetSmallImage("a-server"); // TODO: Maybe contact with MTA:SA servers and check if this ip is a premium one containing a small image to set using this function
Copy link
Contributor Author

@0x416c69 0x416c69 Jul 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe from https://mtasa.com/toplist/ ?

Discord have a limit of 150 images that you can upload.

@patrikjuvonen patrikjuvonen added the enhancement New feature or request label Jul 24, 2019
Copy link
Contributor

@jushar jushar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for the pull request! Overall, it looks very good.

I commented on a few minor issues, but haven't fully reviewed it yet.

CLuaArguments Arguments;
Arguments.PushBoolean(true);
Arguments.PushString(joinSecret);
Player.CallEvent("onPlayerDiscordJoin", Arguments);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd maybe generalize this a bit to something like onPlayerMessengerJoin to be not too tightly coupled to Discord.

The signature may be something like: string messengerType, bool justConnected, string secret.

Copy link
Contributor

@qaisjp qaisjp Jul 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the third argument could be a table that can change depending on the "messenger"? Is "messenger" correct terminology here? Not sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onPlayerExternalJoin maybe?


CDiscordManager::~CDiscordManager()
{
m_bSuicide = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This look very hacky. Not sure how to do this more nicely though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only other way is signals I guess

@0x416c69
Copy link
Contributor Author

0x416c69 commented Jul 30, 2019

So as you guys stopped reviewing this, I'll adjust the necessary modifications to the PR.

Edit: There you have it.

@qaisjp
Copy link
Contributor

qaisjp commented Aug 18, 2019

Seems to work well, with a few minor catches!

Doesn't seem to compile on Windows without modification (i.e. copying a lib file from https://dl-game-sdk.discordapp.net/latest/discord_game_sdk.zip into vendor/discordgsdk/lib).

Please can you fix this?

Things that worked great

  • activity message when loading game / in menu
  • activity message when joining a server
  • activity message when ingame
  • activity message disappears when you disable rich presence whilst ingame
  • activity message disappears when you disable rich presence whilst in menu

Something odd

The discord activity message does not reappear after you enable rich presence, it only appears when you join a server. (Does not say "In Main Menu" when you disconnect from a server either!)

@0x416c69
Copy link
Contributor Author

0x416c69 commented Aug 18, 2019

The discord activity message does not reappear after you enable rich presence, it only appears when you join a server.

Well, it will be enabled in 15 seconds or less, it will use the "reconnecting" feature for reappearing which will be done in every 15 sec. (Thought it's better to prevent user spamming enable/disable)

(Does not say "In Main Menu" when you disconnect from a server either!)

Are you sure? It works for me.

Please can you fix this?

Why not.

Also things that you may have missed:

  • Closing and opening discord after the game is opened
  • Backward compatibility check

@qaisjp
Copy link
Contributor

qaisjp commented Aug 18, 2019

Well, it will be enabled in 15 seconds or less, it will use the "reconnecting" feature for reappearing which will be done in every 15 sec. (Thought it's better to prevent user spamming enable/disable)

Okay!

(Does not say "In Main Menu" when you disconnect from a server either!)

I meant after you turned the feature off and on again. So this doesn't matter anymore.

Also things that you may have missed:

  • Closing and opening discord after the game is opened
  • Backward compatibility check

Yep, can confirm the first one works. Haven't tried backwards compat.

@0x416c69
Copy link
Contributor Author

0x416c69 commented Jan 31, 2020

156cdf9 should have done the job.

Can you test it for once more?

@0x416c69
Copy link
Contributor Author

@qaisjp I confirm that the bug you reported is now fixed. (Thanks to @StrixG)

0x416c69 and others added 5 commits February 12, 2020 00:05
Also disallow to use party max than the max players value
Also do not download discord again when it is already up to date
Copy link
Contributor

@qaisjp qaisjp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks ready to merge.

The Lua API will need changing but I'm happy for us to say something like this on the wiki:

This is function is experimental and you should first check that the function exists before using it. The function can be removed at any time.

if onPlayerDiscordJoin then
    onPlayerDiscordJoin(...)
end

I'll give it a little bit of time for one of @multitheftauto/blue-collaborators to send a secondary approval, because it's many lines of code.

If someone merges this, please squash merge, a couple of large files have been deleted and shouldn't end up in master.

if os.isfile(archive_path) and os.md5_file(archive_path) == DISCORD_MD5 then
print("Discord Game SDK is up to date.")
download_discord = false
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was like this before, but I found that if you delete the other files but keep the .zip, it won't re-add the other files.

I think CEF has the same issue, so I don't mind if both do.

@qaisjp qaisjp requested a review from a team February 29, 2020 15:51
@Lpsd Lpsd mentioned this pull request Mar 6, 2020
@qaisjp
Copy link
Contributor

qaisjp commented Mar 14, 2020

repeating for loudness

If someone merges this, please squash merge, a couple of large files have been deleted and shouldn't end up in master.

@qaisjp
Copy link
Contributor

qaisjp commented Mar 22, 2020

I am merging this in 1 week if nobody else reviews this

@qaisjp qaisjp modified the milestones: 1.6, Backlog Mar 23, 2020
@ghost
Copy link

ghost commented Mar 25, 2020

@qaisjp The PR looks good. Let's go for the merge!

@qaisjp qaisjp changed the title Discord Game SDK Integration (Rich Presence & Join features for now) Add initial Discord Game SDK Integration Mar 25, 2020
@qaisjp qaisjp merged commit 850c76d into multitheftauto:master Mar 25, 2020
@qaisjp qaisjp removed the request for review from sbx320 March 25, 2020 18:54
@qaisjp qaisjp mentioned this pull request Mar 30, 2020
@Deihim007 Deihim007 mentioned this pull request Mar 22, 2022
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants