Blip disappears after you reach a certain distance


#1
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.


#2

See up. This is the reason.


#3

@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.


#4

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.


#5

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


#6

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


#7

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


#8

@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.


#9

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.


#10

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.


#11

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.


#12

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.


#13

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


#14

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.