Jump to content

Detecting what type of ped I get from an array


Fiskey111

Recommended Posts

Hi guys!

I want to pull a specific ped from an array (like detect nearby cops or specific peds [like a s_m_y_cop_01]) but I'm not sure how to do that using rage or natives.  Any ideas/help?

Specifically, I'd like to include them so I can use them in my code later (like take a nearby cop and force him to do what I want).

Thanks!

Edit: Note the array I'm talking about is "Ped[] GetNearbyPeds()"

Edited by fiskey111
defined my array

 

 

Link to comment
Share on other sites

You should look up LINQ queries for c#.

Without LINQ you'd have to manually iterate through the array and conditionally select the desired ped. With LINQ you deal with streams so you can intelligently filter your list.

You can also convert your Ped array into a List<Ped>

You get the model of the ped by checking ped.Model when performing the LINQ query

Link to comment
Share on other sites

List<Ped> PedsWithSpecificModel = (from x in Game.LocalPlayer.Character.GetNearbyPeds(16) where x.Model.Name.ToUpper() == "S_M_Y_COP_01" select x).ToList<Ped>();

Also make sure you have a using System.Linq; statement at the top (should be default).

 

My YouTube: Click here. 

My Discord Server - https://discord.gg/0taiZvBSiw5qGAXU

Useful post? Let me and others know by clicking the Like button.
Check out my many script modifications! 
Having issues? LSPDFR Troubleshooter by Albo1125.

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...