How do I make it to if a blip moves it deletes the blip?

I have a script which creates a blip on a player if he presses a button, but I want it to remove if he moves
May someone help me?

Hmm, that’s unclear. Did you want the blip to disappear after the player moves?
Or did you want the blip to disappear after the player presses a button.

These are totally possible by the way!

I have a esx_ambulancejob customized to my liking and I added a moudle so if a player presses a button it notifies all the people who have the job “ambulance” and says “Injured person, look on the map and go to help them” and then it creates a blip on them but when they respawn it doesn’t delete the blip.
I just need to to remove itself if he revives.

Is that possible?

Hey @sourc3e - what you’re looking for is the native RemoveBlip().

How it works here (and in many other programming application) is that you’re going to use a function that returns a value (often called a “handle” - think of this as an identifier or in some cases, it can be a value of something). When creating a blip, that function returns a handle - An identifier that you can then use to do OTHER things with the blip.

You’ll have to come up with the logic yourself, however, the native you’re looking for is:

(and here’s a server version):

You can literally call this for any reason. Starts raining? You can call RemoveBlip - Random player dies? You can call RemoveBlip - In this case, you can track the player that either dies or gets revived and call it.

You’ll likely only need to add a case to your if statement that removes blips

Hope this helps!

Can you add it to the code?
Thanks for helping but I’m too dumb to realize how to do it…

You’re only as dumb as you allow yourself to be. Understand that no one knows everything, and the things you personally get stuck with are typically the things you remember most.

Regarding the “Remove blip” think of it as opening and closing a door.

When you open the door and walk through it, you have to close the door behind you.
The same applies here with creating and removing blips. When you create a blip, and do stuff, eventually (which can be in 3 miliseconds, or 1000 years) (or anything in between :wink: ) you’ll want to remove it.

So the sudocode will look like this:

EntityID = CreateEntity(could be player, vehicle, or object)
NameofblipID = CreateBlipForCreatedEntity(EntityID)
--Do magical stuff
--Magical stuff done
RemoveBlipfromentity(NameofblipID)

In the example sudocode, CreateBlipForCreatedEntity(EntityID) is the name of the “function” that creates a blip. This “function” returns an ID you can use for later to do stuff with!

Hopefully this makes sense but if it doesn’t please let me know. The idea is that you’re creating a blip to do stuff with, then destroying it!

Now in your case, you’re lucky because the blip already is created.
So for now, your goal is to search your code (use control + f if you’re in a popular / common text editor) and search for “blip” or “Blip”

Once you find it, you’ll be able to find the ID that’s associated with the blip. Then you can use RemoveBlip(Name_Of_Blip_ID_Variable) to remove the blip.

Note: If you’re going to add RemoveBlip(Name_Of_Blip_ID_Variable) right after your blip gets created, it may appear and disappear before you see it. I’d recommend adding Wait(3000) before you remove your blip (that way, the script waits for 3 seconds before getting rid of it).

Hope this helps!

Thanks, but I have a question,
Is it possible to make it to where if the player revives themselves or waits the minutes that clicks [E] the blip removes?

Also please answer my DM’s would be really nice

Yep! Thinking back to the analogy you can choose when to “close the door” but for now, just try to figure out how to close the door. Then I’ll help you walk through finding good times to close it.

(and I did, lol)

Can you make that into a code, I’m having trouble again

I won’t make it into code, but I will help you understand how to do it

Alright

Still didn’t understand how to do it

Sorry about the delay; No problem - Let’s do this; Go ahead and search in ALL of your code for the word “blip”