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
Hey!
I hope someone can help me :).
My Problem is, it displays only Players nearby but it should show ALL Players on the Server.
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)
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