Back to Main Page

This is some info on GTA V blips and why management is absolutely essential.


Blips - Management is essential

Blips, small word, small appearance, massive impact if you let them get out of control.

Believe it or not, blips can bring your game crashing down as fast as any asset in the game. Of all the times my game has become unstable, the most visual and catastrophic times, have been at the hands of blips.

For most people, blips are a simple case of:

Vector3 blipPosition = new Vector3(1000f, 1000f, 50f);
Blip myBlip = World.CreateBlip(blipPosition);

And that's fine... until you hit Insert to reload your script and because the newly reloaded script has no idea that Blip exists, it creates another one and when the next Script reset comes round, it does it again, and again etc...

Now imagine you have a mod that creates 10 blips, 50 blips or 100 blips and every time you hit Insert, it creates them again and again. You only need to get to 150 or so blips and things start to take effect, go higher than that and things start to really happen... bad things.

While I was creating my World Guide Mod I was effectively dealing with a potential of 1800+ blips that could be displayed while I was collecting locations and in one moment of complete lack of concentration, that's exactly what happened. I dumped every blip into the map and the game looked like it had been invaded by map eating aliens. There were things missing, things corrupted, everywhere... I am actually convinced they can cause more damage than mismanaged Props in a bad map mod (which is another place where the code I use below can be used, replace Blip with Prop and you can manage them in the same way)

So as a result, it was essential to keep a very tight grip on what was happening with the Blips, as I had to add and remove them constantly as I was driving around the map.

As you can see from this image, parts of the map had a very high density of blips. (Image opens in a new Tab)

The process of keeping your blips under control, is fairly simple:

Declare a collection for your blips in the declaration section at the top of your class:

List<Blip> BlipCollection = new List<Blip>();

That's your storage space for your blips. Your creation code is no different to what you have already:

Vector3 blipPosition = new Vector3(1000f, 1000f, 50f);
Blip myBlip = World.CreateBlip(blipPosition);

But here's the difference, after creating the blip, you add it to your collection:


By the time you have gone through your initialisation process, you will have a reference to every blip you have added to the map inside that collection.

The next thing you need to do, is add the event handler for the script reset event, which is the Script.Aborted event. Add this where you create the onTick event handler:

this.Aborted += myScript_Aborted;

And then finally, you add your myScript_Aborted event handler function. While you are typing the above line, if you are using Visual Studio it will begin the automatic event handler creation, where hitting Tab will add the event handler code to your project. In that instance, just add the foreach code loop inside that event handler function:

private void myScript_Aborted(object sender, EventArgs e)
    foreach (Blip existingblip in BlipList)
        if (existingblip.Exists()) existingblip.Remove();

What that will do now, is the minute you hit Insert to reload your scripts, it will unload any existing blips from the Pause Map ready for them to be re-created when your script runs.

The easiest way to tell if a script isn't managing blips, is to load the game and find a blip on the Pause Map. It will show something like MyBlip in the location list. Hit Insert and go back to the same blip. If it now shows something like MyBlip<1/2>, then you know that the blips are not being managed and you need to proceed with caution while you are using that script mod.

Here's an example of this in action, this is the OnlineInteriors mod. (Image opens in a new Tab)

The only thing I did is hit insert twice and every blip this mod displays is added again after each press of Insert. This mod adds quite a few blips to the map, so this is a definite issue with this mod. If anyone reads this, you need to make the author aware of this.

For anyone developing script mods while they have a mod like this active, they have to be even more careful, as corruption caused by mismanaged blips can be seen as bugs in your own mod, especially if you are unaware of the damage blips can cause. My advice is, remove the offending mod until your development is finished, or try and get the author of the mod to fix their error.

This simple process could be the difference between your mod working smoothly and your mod crashing someone's game, so it is critical that something like this is implemented if lots of map-based blips are part of your project.