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.
@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.
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.
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.
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?
(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% @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.
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 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.