Blip disappears after you reach a certain distance

function createBlip(id)
	ped = GetPlayerPed(id)
	lastUnit = GetVehiclePedIsIn(GetPlayerPed(id), true)
	blip = GetBlipFromEntity(lastUnit)
	
	if not DoesBlipExist(blip) then -- Add blip and create head display on player
	if IsPedInAnyVehicle(ped) and GetPedInVehicleSeat(lastUnit, -1) == ped then
		blip = AddBlipForEntity(lastUnit)
		SetBlipSprite(blip, 225) -- Blip Sprite
		SetBlipColour(blip, 1)
		Citizen.InvokeNative(0x5FBCA48327B914DF, blip, true) -- Player Blip indicator
		SetBlipRotation(blip, math.ceil(GetEntityHeading(veh))) -- update rotation
		SetBlipNameToPlayerName(blip, id) -- update blip name
		SetBlipScale(blip, 0.85) -- set scale
		SetBlipAsShortRange(blip, true)
		
		table.insert(blipsCops, blip) -- add blip to array so we can remove it later
			end
		end
end

Here is my function to create a blip. I canā€™t seem to figure out why the blip is removed from the map after you get a certain distance away. The end goal here is that players can see this blip from anywhere on the map, regardless of how far away from it they are.

Any help would be much appreciated. I tried to find blip documentation in regards to: SetBlipAsShortRange(blip, true) but there does not seem to be much available.

See up. This is the reason.

@zr0iq Thanks for the fast response. What do you mean ā€œThisā€ is the reason? Could you go into more detail for me? I have tried modifying the bool to false and that yields the same result.

Set it to false or remove the function. It should do what you want. Setting it to true means that it disappears when it is outside the minimap range.

1 Like

@zr0iq When I set it to false or remove it - It STILL disappears.

Well then the issue is very likely not within these lines. But you apparently copied some code. Make sure you understand what you copy.

Whatā€™s the goal with the snippet of code above? Itā€™s doing something more than just placing a blip on the map.

@SaltyGrandpa

Yeah, Its a vehicle GPS that is can only be made active when a player is sitting in the front seat (drivers) of a vehicle.
IE) GetPedInVehicleSeat(lastUnit, -1)

The end game goal is that players that have these GPS units will be able to see each other on the map no matter where they are. Currently it is broken in the sense that the blip disappears after you drive 0.60 miles away from the other players marker.

I do understand what I copied. To my knowledge:

SetBlipAsShortRange(blip, true)

Is merely a way to determine if the blip is short range or not. Iā€™ve tried both ā€œTrueā€ and ā€œFalseā€ and the result is the same. That means Iā€™m either using this incorrectly OR something else is broken. Which is why I posted here to see if anyone could offer any insight into the issue.

For anyone that comes across this post. I have not yet been able to solve my problem. But I was able to determine that:

SetBlipAsShortRange(blip, true)

Is actually what governs if the blip is displayed while in range of your minimap radar. Not the range of the player/entity itself.

How many game units in distance exist between the player vehicle and the player in this scenario? Might it be the case that the vehicle simply isnā€™t cloned anymore on the faraway player? :open_mouth:

(actually, yes, thereā€™s a hard cap of at most 600 units for a vehicle to clone unless some other condition is met that restricts the vehicle from being not-cloned based on distance, such as the player controlling a passenger, and a few other restrictions. funnily, R* made a flag to disable distance restrictions on vehicles, but never set it anywhere)

Actuallyā€¦ _SET_NETWORK_ID_SYNC_TO_PLAYER is more like ā€˜force existence on this playerā€™. Thereā€™s some preconditions for execution of this native to succeed, I think a script using this needs to be using the network script manifest version.

This might actually be what the problem is. Iā€™m going to have to do a little more research on SET_NETWORK_ID_SYNC_TO_PLAYER Could be the issue Iā€™ve been facing the entire time. I have seen other servers using a similar GPS style tracking system for their emergency services - I never imagined it would be this difficult to actually get it running.

In follow-up I did test out your theory and you are CORRECT. Vehicle blips de-spawn from the map after a certain distance. The blips have to be set to a player (ped) or entity other than a vehicle. (passenger, etc)

Thanks so much guys! This solved my issue 100% :smiley:
@neptunium

In case anyone else stumbles upon the same issue I had, there is a native client function, when you attach a blip to a vehicle it is only visible to other clients for a distance of roughly 500 units (0.60 miles) after that it is despawned and brought out of sync with the client.

To circumvent this I had no choice but to attach my blip to the entity inside the vehicle. (player) I did a check to make sure they were in the drivers seat of a vehicle prior to actually creating the blip.

if not DoesBlipExist(blip) then -- Add blip and create head display on player
	if IsPedInAnyVehicle(ped) and GetPedInVehicleSeat(lastUnit, -1) == ped then
                       --------------------
                -- Insert your blip stuff here --
                       --------------------

Anyways, thanks to everyone who tried to help and I hope that if there is someone out there who is having the same issue as me, they will stumble upon my solution.

TLDR - You need to attach blips to player peds if you want them to be visible at any distance on the map, if you attach to a vehicle it will disappear after 0.60 miles.

2 Likes

I am looking for a function the other way around: Make a playerblip disappear when you come closer like 50 m or so, good for chases, you have a general idea where the other one is but when you get close you have to rely on your senses :wink: Any chance one can do that?

PS And no, I have no idea how to do it, I am also not too lazy to figure it out just completely aware that until I am able to do it GTA 6 is out.

Could you inform how you made the correction?

I have the same problem in 2021

Opa eu porso jogar meu id 6963

MEU JOGO NAO ESTA ENTRANDO MEU ID 16617
ME AJUDEMemphasized text

bom dia queria ta entrando na city meu nome e bruno
meu id e 26951

bom dia queria muito conhecer a cidade e fazer amizades pode ta me liberando id- 34343