Skip to content
View in the app

A better way to browse. Learn more.

LCPDFR.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Array of Blips

Featured Replies

Evening,

 

Forgive me for my lack of knowledge on this subject, coming from Self Taught programming. Trying to create an array of Blips for my Suspects. How would I go about initializing this Array so it does not return a NULL value when I want to use them?

 

Thanks,

 

cmPLX

 

Create my Blip Array

private Blip[] SuspectBlips;

Then when I create the Peds, I'm using this.

SuspectBlips[i] = this.drivebys[i].AttachBlip();

 

Edited by cmPLX

Use a List, not an array. Lists are meant to have things added to them all the time. 

 

The way I'd do it is something like this:

 

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

for(var driveby in drivebys)
{
  Blip b = driveby.AttachBlip();
  b.Color = whatever;
  b.Name = whatever;
  blips.Add(b);
}

 

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

Parks is right, in most cases when you don't know the actual runtime lenght of an array you should use another data structure. Your example doesn't work because you did not initialize your array = it doesn't have any values.

http://stackoverflow.com/questions/32290879/meanings-of-declaring-instantiating-initializing-and-assigning-an-object

Also, it seems to me you should replace AttachBlip() with a Blip constructor and pass an entity to it.

It should look this way:

private Blip[] SuspectBlips = new Blip[1];
SuspectBlips[0] = new Blip(drivebys[i]);

Array is fine when you know the lenght of your collection and/or write high performance code.

Edited by LtFlash

  • Author
6 hours ago, LtFlash said:

Parks is right, in most cases when you don't know the actual runtime lenght of an array you should use another data structure. Your example doesn't work because you did not initialize your array = it doesn't have any values.

http://stackoverflow.com/questions/32290879/meanings-of-declaring-instantiating-initializing-and-assigning-an-object

Also, it seems to me you should replace AttachBlip() with a Blip constructor and pass an entity to it.

It should look this way:


private Blip[] SuspectBlips = new Blip[1];
SuspectBlips[0] = new Blip(drivebys[i]);

Array is fine when you know the lenght of your collection and/or write high performance code.


Thanks PNWParksFan and LtFlash, this helped me a lot. I only have a max length of 3 for the array due to limited passenger seats. 

Edited by cmPLX

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.