Code Monkey home page Code Monkey logo

gmod-discord-rpc's Introduction

GDiscord

Discord Rich Presence for Garry's Mod

This addon provides Discord RPC support for Garry's Mod, through the use of a binary module. For this addon to work, a Lua script is required on servers to sync information, and a binary module is required on clients.

In June 2018, Discord broke updating this through HTTP; so any Lua-based implementations of this are no longer possible. However, it is still possible (however impractical for servers) to use Rich Presence by using a binary module.

For Clients

Download the latest version of the GDiscord module from the releases page. The module you need depends on what OS and version you're running (eg. Windows on 32-bit should download gmcl_gdiscord_win32.dll). If you're running the 64-bit beta, make sure you download the 64.dll!

Copy this into lua/bin/. That's all!

With this module installed, your Discord status should automatically update when playing on supported servers.

For Servers

Please note that for this to work, all clients will need to install the binary module.

Download the latest version of cl_discord.lua from the releases page.

Copy this into lua/autorun/client.

Configuration

For best results, server owners need to edit cl_discord.lua for server-specific configuration.

You should not edit or rename the binary module. Please keep this as gdiscord, so clients can use one module across all supported servers!

Setting up an Application

The first step is to set up a Discord application so you can slightly customise the display. This application contains the map images that will be displayed in Discord.

Create an application over at https://discordapp.com/developers/

Go into Rich Presence > Art Assets and upload images of each map you want, along with an optional default image. Ensure that each map is named correctly.

Copy the Client ID from General Information.

Lua File

Open up the .lua file and change the following variables as needed:

  • discord_id should be the Client ID you obtained earlier
  • refresh_time should be how frequently you want the display to update

Default Map Image

To display a default map image, the script needs to know which maps you have specific icons for. There's no way for the Lua script to know what you've uploaded to Discord, so this is a manual process. Sorry.

Put all the maps you have images for into the map_list table. Once that's done, change map_restrict to true, and set map_default to the name of whatever the default icon should be.

If you have images uploaded for every map in your rotation, you don't need to worry about this step.

gmod-discord-rpc's People

Contributors

cborac avatar kesefon avatar rafraser avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gmod-discord-rpc's Issues

Please add a license

Under the current license (or lack thereof) no one is technically allowed to fork, modify or redistribute it.

Better console messages if module is missing

At current, there is some basic handling Lua side where the addon bails out if the module isn't installed at all.

if file.Find("lua/bin/gmcl_gdiscord_*.dll", "GAME")[1] == nil then return end

I just accidentally launched 64bit Garry's Mod with the 32bit version of this module installed, and there were a couple Lua errors. Woops!

There's a couple of improvements I think we can make to this:

  • Check for the specific .dll file for the appropriate version of the game. This would stop errors if someone installs the wrong version!
  • If the module isn't found at all, maybe we could display a console message saying something like "This server supports Discord Rich Presence - if you're interested, install the module"

If anyone has thoughts on this sort of stuff, let me know.

Error

`[discord] addons/discord/lua/autorun/client/cl_discord.lua:52: attempt to call global 'DiscordUpdateRPC' (a nil value)

  1. DiscordUpdate - addons/discord/lua/autorun/client/cl_discord.lua:52
  2. fn - addons/discord/lua/autorun/client/cl_discord.lua:58
    3. unknown - addons/ulib/lua/ulib/shared/hook.lua:109`

The .dll module is located in lua/bin. I hope this error can be corrected

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.