Log in to reply

Game crashing with this code. [C#]

  •         public static void RemoveVehicle(int id, bool removeFromInfo)
                if (SpawnedVehicles == null) return;
                Vehicle vehicle = SpawnedVehicles[id];
                if (!SpawnedVehicles.Contains(vehicle))
                if (vehicle.CurrentBlip != null)
                if (removeFromInfo == true)

    Game immediately crashes when I call this function. SpawnedVehicles is a List of Vehicles and the id is just the id of the car. I know the id is legit since I call this function from a for-loop which is going through all the contents of SpawnedVehicles.

    Ignore the removeFromInfo thing, it still crashes if I set it to false.

  • Where does it crash? Do you have an error in your SHV.NET log?

  • @Jitnaught I have no idea. And no, no log error.

  • @Jitnaught Figured it out. Crashes at this code:

    if (vehicle.CurrentBlip != null)

    But why? There is really no way it should crash...

  • @AHK1221
    I just tried a simple test to see what would happen if I just spawned a car, then tried to delete the blip if it's not null. I tried it twice, once without adding a blip, and once adding one. It didn't crash either time.
    Maybe you should add a check that the vehicle exists before you try to remove the blip? I dunno.

  • @Jitnaught I think it has something to do with my saving code since it crashes 500 ms after I press the key.


    @AHK1221 said in Game crashing with this code. [C#]:


    I recall reading somewhere that CurrentBlip.Remove () has actually never worked. I think ppl advised to just reassign the blip (or mask it).

  • @meimeiriver Worked for me.

  • @AHK1221 Use vehicle.CurrentBlip.Exists()

  • @xquist Will try, thanks.

Log in to reply

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.