I don’t know if i’ll get called a scum for reposting this but i worked on it for a while and thought i would share it. It combines the code from this post “Location Display for Discord Rich Presence” by @ IllusiveTea, the discord asset natives shown here and some touches of my own. .
UPDATE:
- Before if you where in a Add-On Vehicle it would display “NULL”, it now displays “Add-On Vehicle”.
- Simplified things when retrieving the VehName.
- Fixed the __resource.lua being empty when using the download at the bottom.
- Removed the comments after the 2nd Citizen.CreateThread.
- Reduced the update time from 15sec to 10sec
UPDATE #2:
- Instead of saying “Add-On Vehicle” it displays the text defined by in the vehicles.meta
(e.x. <“gameName”>2017_Ford_GT</“gameName”>, displays: 2017 Ford GT)
__resource.lua:
resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
client_script 'client.lua'
Client.lua:
Citizen.CreateThread(function()
while true do
SetDiscordAppId(123456789012345678) --Discord app id
SetDiscordRichPresenceAsset('Big_Picture') --Big picture asset name
SetDiscordRichPresenceAssetText('Big picture text.') --Big picture hover text
SetDiscordRichPresenceAssetSmall('small_picture') --Small picture asset name
SetDiscordRichPresenceAssetSmallText('Small picture text') --Small picture hover text
Citizen.Wait(600000) --How often should this script check for updated assets? (in MS)
end
end)
--No Need to mess with anything pass this point!
Citizen.CreateThread(function()
while true do
local VehName = GetLabelText(GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(PlayerPedId()))))
if VehName == "NULL" then VehName = GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(PlayerPedId()))) end
local x,y,z = table.unpack(GetEntityCoords(PlayerPedId(),true))
local StreetHash = GetStreetNameAtCoord(x, y, z)
local pId = GetPlayerServerId(PlayerId())
local pName = GetPlayerName(PlayerId())
Citizen.Wait(10000)
if StreetHash ~= nil then
StreetName = GetStreetNameFromHashKey(StreetHash)
if IsPedOnFoot(PlayerPedId()) and not IsEntityInWater(PlayerPedId()) then
if IsPedSprinting(PlayerPedId()) then
SetRichPresence("ID: "..pId.." | "..pName.." is sprinting down "..StreetName)
elseif IsPedRunning(PlayerPedId()) then
SetRichPresence("ID: "..pId.." | "..pName.." is running down "..StreetName)
elseif IsPedWalking(PlayerPedId()) then
SetRichPresence("ID: "..pId.." | "..pName.." is walking down "..StreetName)
elseif IsPedStill(PlayerPedId()) then
SetRichPresence("ID: "..pId.." | "..pName.." is standing on "..StreetName)
end
elseif GetVehiclePedIsUsing(PlayerPedId()) ~= nil and not IsPedInAnyHeli(PlayerPedId()) and not IsPedInAnyPlane(PlayerPedId()) and not IsPedOnFoot(PlayerPedId()) and not IsPedInAnySub(PlayerPedId()) and not IsPedInAnyBoat(PlayerPedId()) then
local MPH = math.ceil(GetEntitySpeed(GetVehiclePedIsUsing(PlayerPedId())) * 2.236936)
if MPH > 50 then
SetRichPresence("ID: "..pId.." | "..pName.." is speeding down "..StreetName.." at "..MPH.."MPH in a "..VehName)
elseif MPH <= 50 and MPH > 0 then
SetRichPresence("ID: "..pId.." | "..pName.." is cruising down "..StreetName.." at "..MPH.."MPH in a "..VehName)
elseif MPH == 0 then
SetRichPresence("ID: "..pId.." | "..pName.." is parked on "..StreetName.." in a "..VehName)
end
elseif IsPedInAnyHeli(PlayerPedId()) or IsPedInAnyPlane(PlayerPedId()) then
if IsEntityInAir(GetVehiclePedIsUsing(PlayerPedId())) or GetEntityHeightAboveGround(GetVehiclePedIsUsing(PlayerPedId())) > 5.0 then
SetRichPresence("ID: "..pId.." | "..pName.." is flying over "..StreetName.." in a "..VehName)
else
SetRichPresence("ID: "..pId.." | "..pName.." is landed at "..StreetName.." in a "..VehName)
end
elseif IsEntityInWater(PlayerPedId()) then
SetRichPresence("ID: "..pId.." | "..pName.." is swimming")
elseif IsPedInAnyBoat(PlayerPedId()) and IsEntityInWater(GetVehiclePedIsUsing(PlayerPedId())) then
SetRichPresence("ID: "..pId.." | "..pName.." is sailing in a "..VehName)
elseif IsPedInAnySub(PlayerPedId()) and IsEntityInWater(GetVehiclePedIsUsing(PlayerPedId())) then
SetRichPresence("ID: "..pId.." | "..pName.." is in a yellow submarine")
end
end
end
end)
5MDiscordRPv3.zip (1.1 KB)
Notice: Please allow up to 1 minute for the script to fully display the correct details