58 lines
3.5 KiB
Lua
58 lines
3.5 KiB
Lua
local WaitTime = 5000 -- How often do you want to update the status (In MS)
|
|
|
|
local DiscordAppId = tonumber(GetConvar("RichAppId", "543866591079694346"))
|
|
local DiscordAppAsset = GetConvar("RichAssetId", "eg-blurple")
|
|
|
|
Citizen.CreateThread(function()
|
|
SetDiscordAppId(DiscordAppId)
|
|
SetDiscordRichPresenceAsset(DiscordAppAsset)
|
|
for _, v in pairs(Config.Buttons) do
|
|
SetDiscordRichPresenceAction(v.index, v.name, v.url)
|
|
end
|
|
while true do
|
|
local x,y,z = table.unpack(GetEntityCoords(PlayerPedId(),true))
|
|
local StreetHash = GetStreetNameAtCoord(x, y, z)
|
|
local onlinePlayers = GetNumberOfPlayers()
|
|
Citizen.Wait(WaitTime)
|
|
if StreetHash ~= nil then
|
|
miid = GetPlayerServerId(NetworkGetEntityOwner(GetPlayerPed(-1)))
|
|
StreetName = GetStreetNameFromHashKey(StreetHash)
|
|
if IsPedOnFoot(PlayerPedId()) and not IsEntityInWater(PlayerPedId()) then
|
|
if IsPedSprinting(PlayerPedId()) then
|
|
SetRichPresence("ID: "..miid.." | Players: "..onlinePlayers.." | Sprinting down "..StreetName)
|
|
elseif IsPedRunning(PlayerPedId()) then
|
|
SetRichPresence("ID: "..miid.." | Players: "..onlinePlayers.." | Running down "..StreetName)
|
|
elseif IsPedWalking(PlayerPedId()) then
|
|
SetRichPresence("ID: "..miid.." | Players: "..onlinePlayers.." | Walking down "..StreetName)
|
|
elseif IsPedStill(PlayerPedId()) then
|
|
SetRichPresence("ID: "..miid.." | Players: "..onlinePlayers.." | 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)
|
|
local VehName = GetLabelText(GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(PlayerPedId()))))
|
|
if MPH > 50 then
|
|
SetRichPresence("ID: "..miid.." | Players: "..onlinePlayers.." | Speeding down "..StreetName.." in a "..VehName)
|
|
elseif MPH <= 50 and MPH > 0 then
|
|
SetRichPresence("ID: "..miid.." | Players: "..onlinePlayers.." | Cruising down "..StreetName.." in a "..VehName)
|
|
elseif MPH == 0 then
|
|
SetRichPresence("ID: "..miid.." | Players: "..onlinePlayers.." | Parked on "..StreetName.." in a "..VehName)
|
|
end
|
|
elseif IsPedInAnyHeli(PlayerPedId()) or IsPedInAnyPlane(PlayerPedId()) then
|
|
local VehName = GetLabelText(GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(PlayerPedId()))))
|
|
if IsEntityInAir(GetVehiclePedIsUsing(PlayerPedId())) or GetEntityHeightAboveGround(GetVehiclePedIsUsing(PlayerPedId())) > 5.0 then
|
|
SetRichPresence("ID: "..miid.." | Players: "..onlinePlayers.." | Flying over "..StreetName.." in a "..VehName)
|
|
else
|
|
SetRichPresence("ID: "..miid.." | Players: "..onlinePlayers.." | Landed at "..StreetName.." in a "..VehName)
|
|
end
|
|
elseif IsEntityInWater(PlayerPedId()) then
|
|
SetRichPresence("ID: "..miid.." | Players: "..onlinePlayers.." | Swimming around")
|
|
elseif IsPedInAnyBoat(PlayerPedId()) and IsEntityInWater(GetVehiclePedIsUsing(PlayerPedId())) then
|
|
local VehName = GetLabelText(GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(PlayerPedId()))))
|
|
SetRichPresence("ID: "..miid.." | Players: "..onlinePlayers.." | Sailing around in a "..VehName)
|
|
elseif IsPedInAnySub(PlayerPedId()) and IsEntityInWater(GetVehiclePedIsUsing(PlayerPedId())) then
|
|
SetRichPresence("ID: "..miid.." | Players: "..onlinePlayers.." | In a yellow submarine")
|
|
end
|
|
end
|
|
end
|
|
end)
|