Jump to content
RAGE Multiplayer Community

[PHP][Discord] Show Player Count directly in Discord 1.0.0

   (3 reviews)

1 Screenshot

About This File

In this file I will get you started on how you can use Discord to show your current player count.

 

First step is to create an application at:

https://discord.com/developers/applications

Once created click Bot on the left hand side.

Click "Add Bot" and then "Yes, do it!"

Change your Icon to something more pretty

Click "COPY" underneath "Click to reveal token"

Open the file in the ZIP.

Install PHP composer if not already installed.

Run composer require team-reflex/discord-php

Edit the example_rage.php file and change the "Discord Token here" to the token you copied earlier

Change line 17 IP:PORT to your Server IP and Port

When ready run the file with php -q example_rage.php

This script must always be running for it to appear on the Discord member section. Therefore I would recommend running Linux Screen and running the php -q command then detaching the screen to run it in the background.

The script uses the Discord Heartbeat to keep it active within the list. It will also only poll the server after running the heartbeat 5 times which is every 42 seconds.

 

To set it up with your Discord server you must do the following:

Take the link you were at to setup your bot - it should look like: https://discord.com/developers/applications/IDHERE/bot

Where it says IDHERE - take it and insert it here: https://discord.com/api/oauth2/authorize?client_id=IDHERE&scope=bot&permissions=1

Once this page loads - select your discord server that you are an admin of. 

This will authorize your bot to submit to your server.

 

To make your bot appear at the top of the list, simply create a new permission role called Server

Give it permission to send messages

Set it a nice colour

Drag it to the top of your list

Go to the User that is now in your Member list showing player details and give the role of the server you just created

 

Have fun!

 

Edited by Wdoyle
Removed my ID


What's New in Version 1.0.0   See changelog

Released

  • Made the script detect if you have edited variables or if you attempt to run it on Localhost (Already been asked)
  • It also casts the Server details and checks if they are available, this is to detect if the server is missing from the Masterlist
  • Token and IP:Port details moved to the variables at the top
  • Like 1

User Feedback

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest

Guest yup

   1 of 1 member found this review helpful 1 / 1 member

y use a middle man to get the player count when u could grab it from the server itself and then run a discord bot from the RAGEMP server to modify the bot's presence? it's just additional overhead to grab the player count from the rage masterlist no?

Response from the author:

I use the middleman as some server developers have seperate teams so getting someone to implement a player counter API mechanism from your own server might not be possible.

Your is still a valid suggestion so if you maybe change the section that uses cdn.rage to your own method it would work. No need to mark down the rating as this bot would still work for your idea

Link to comment
×
×
  • Create New...