[How-to] [Updated] Discord rich presence Custom Image 🏞

I have a problem, that when I click them, nothing is happening. Everything is set up fine, but no success.

SetDiscordRichPresenceAction(0, "CsatlakozĂĄs a szerverre!", "fivem://connect/ip:30120") -- Button 1, config: 0 = number of button 0-1 / Button Text / Link that opens when you click button

SetDiscordRichPresenceAction(1, "CsatlakozĂĄs a Discord szerverre!", "https://dsc.gg/lsrp") --  Button 2, config: 0 = number of button 0-1 / Button Text / Link that opens when you click button

I keep getting script error, even tho my fx_version is set correctly and not to gta5.

Imgur: The magic of the Internet (I know I need to fill in discord ID, but took it away for a sec)

You have fxmanifest.lua in script folder? :grinning:

They will work fine. You can’t click your own buttons!

How I can add buttons?

1 Like

What’s wrong with You? There’s literally code in post.

SetDiscordRichPresenceAction(0, "First Button!", "your link1")
SetDiscordRichPresenceAction(1, "Second Button!", "your link2")

Hey!
I hope someone can help me :).
My Problem is, it displays only Players nearby but it should show ALL Players on the Server.

Inked2021-03-19 02_24_14-#ticket-0067 - Discord_LI

I already tried ALL of the tips here, fxserver version is on v1.0.0.3559.

Client looks like that:

Citizen.CreateThread(function()
	while true do
        --This is the Application ID (Replace this with you own)
		SetDiscordAppId(left out for this post)

        --Here you will have to put the image name for the "large" icon.
		SetDiscordRichPresenceAsset('left out for this post')
        
        --(11-11-2018) New Natives:

        --Here you can add hover text for the "large" icon.
        SetDiscordRichPresenceAssetText('left out for this post')
       
        --Here you will have to put the image name for the "small" icon.
        SetDiscordRichPresenceAssetSmall('left out for this post')

        --Here you can add hover text for the "small" icon.
        SetDiscordRichPresenceAssetSmallText('left out for this post')

        -- Amount of online player (Don't touch)
        local playerCount = #GetActivePlayers()

        -- Your own playername (Don't touch)
        local playerName = GetPlayerName(PlayerId())

        -- Set here the amount of slots you have (Edit if needed)
        local maxPlayerSlots = 64

        -- Sets the string with variables as RichPresence (Don't touch)
        SetRichPresence(string.format("%s - %s/%s", playerName, playerCount, maxPlayerSlots))

        --It updates every one minute just in case.
		Citizen.Wait(60000)
	end
end)

Best Greets!

I can guarantee the action buttons work on stable builds now, as of March 15th.

1 Like

When using OneSync infinity only the server know’s the total amount of players.
You can add a NUI callback function with JS that requests the server players.json, or a bit eiser is to add a server Event to call back the amount of players from the server.

client.lua:

local playerCount = 0
RegisterNetEvent('GetActivePlayers:CB')
AddEventHandler('GetActivePlayers:CB', function(count)
    playerCount = count
end)

Citizen.CreateThread(function()
	while true do
        --This is the Application ID (Replace this with you own)
		SetDiscordAppId(left out for this post)

        --Here you will have to put the image name for the "large" icon.
		SetDiscordRichPresenceAsset('left out for this post')
        
        --(11-11-2018) New Natives:

        --Here you can add hover text for the "large" icon.
        SetDiscordRichPresenceAssetText('left out for this post')
       
        --Here you will have to put the image name for the "small" icon.
        SetDiscordRichPresenceAssetSmall('left out for this post')

        --Here you can add hover text for the "small" icon.
        SetDiscordRichPresenceAssetSmallText('left out for this post')

        -- Amount of online player (Don't touch)
        -- local playerCount = #GetActivePlayers()
        TriggerServerEvent('GetActivePlayers')

        -- Your own playername (Don't touch)
        local playerName = GetPlayerName(PlayerId())

        -- Set here the amount of slots you have (Edit if needed)
        local maxPlayerSlots = 64

        -- Sets the string with variables as RichPresence (Don't touch)
        SetRichPresence(string.format("%s - %s/%s", playerName, playerCount, maxPlayerSlots))

        --It updates every one minute just in case.
		Citizen.Wait(60000)
	end
end)

server.lua:

RegisterServerEvent('GetActivePlayers')
AddEventHandler('GetActivePlayers', function()
    local count = GetNumPlayerIndices()
    -- Callback to client
    TriggerClientEvent('GetActivePlayers:CB', source, count)
end)

Add the server.lua to the fxmanifest.lua as a server script :wink:

1 Like

Hey, thanks for your help!
So sorry to bother you.
I did what you said, but now it shows 0/64.
Any ideas? :confused:

Amazing job man! 1 issue, it just says invalid as the person’s name. Know how to fix? Great release!

Hi! How to put players name and players ID in small icon?

how to use direct links Screenshot - 6a769f339bd537dbd1cd76d752df5d4a - Gyazo

Nice tutorial, thank you.

You save me dude thks :grinning:

hello, would I be able to make this work with a discord fan server invite link?

Good job, thanks

You can use GetPlayerName() and GetPlayerServerId()

A discord invite link will work.
Good to know is that you cannot click your own discord status buttons in case you are going to test it.

1 Like

To Do Upload Large Logo . Which Shows in Pc .