[HELP] IsTrackedPedVisible

Hello, I have a trouble with IsTrackedPedVisible.

Here’s my code.

ped = GetPlayerPed(id) -- this is in for loop, so it's 100% working, because I use it in to display Players Nicknames 
Citizen.InvokeNative(0x7D7A2E43E74E2EB8, Citizen.PointerValueIntInitialized(ped)) -- Track Ped Visibility
if IsTrackedPedVisible(ped) then
    Citizen.Trace("Visible")
end

In reference I’ve found this:

BOOL IS_TRACKED_PED_VISIBLE(Ped ped) // 91C8E617F64188AC 33248CC1
returns whether or not a ped is visible within your FOV, not this check auto's to false after a certain distance.

~ Lynxaa


Target needs to be tracked.. won't work otherwise.
-THEAETIK

and this:

PED::_0x7D7A2E43E74E2EB8(ped);// TRACK_PED_VISIBILITY
if (PED::IS_TRACKED_PED_VISIBLE(ped))
{

}

Am I doing something wrong? Please, help me if you can.

EDIT:
I’m trying to do this, because I want to make player nickname dissapear when other player is invisible in my FOV.

I just tried it and it is working for me. I just used a spawned ped, because I had no one to test.

-- CLIENTSIDED --
local ped
local count

Citizen.CreateThread(function() --Creating Ped And Setting As Tracked
	while true do
		Citizen.Wait(1)

		if count ~= 1 then
			Citizen.Wait(2500)
			RequestModel(GetHashKey("a_c_chimp"))
			while not HasModelLoaded(GetHashKey("a_c_chimp")) do
				Citizen.Wait(1)
			end
			ped = CreatePed(4, GetHashKey("a_c_chimp"), GetEntityCoords(GetPlayerPed(-1), true), 0.0, 0, 1)
			Citizen.InvokeNative(0x7D7A2E43E74E2EB8, ped)
			count = 1
		end
	end
end)

Citizen.CreateThread(function() --Checking If Ped Is Visible Or Not
	while true do
		Citizen.Wait(1)

		if IsTrackedPedVisible(ped) then
			Citizen.Trace("Ped Visible")
		else
			Citizen.Trace("Ped Invisible")
		end
	end
end)
1 Like

Great!
What I changed Citizen.InvokeNative(0x7D7A2E43E74E2EB8, Citizen.PointerValueIntInitialized(ped)) to Citizen.InvokeNative(0x7D7A2E43E74E2EB8, ped) it’s working now!
Thanks again.

No Problem, I am glad it is working now :slight_smile:

1 Like