Jump to content

Give a ped a specific model


epicmrjuan

Recommended Posts

And do you now how to spawn a ped or car behind the suspect

somthing like this but than working

Cop = new Ped("s_m_y_cop_01", SpawnPoint + 12f, 90f);

i found it myself

Cop = new Ped("s_m_y_cop_01", (Suspect.GetOffsetPosition(new Vector3(0, 5f, 0))), 180f);

 

Edited by epicmrjuan

Thank you

Link to comment
Share on other sites

I'd like to add in a few things here just so you can look back on this when you are further into coding and want to know this and that about spawning Ped's/Vehicle's so you don't have to start a new topic later on, as the answer will be right here :)

First, you have your simple spawning of your Ped.

//myCopPed1 is the name of the ped you will use throughout your code, I used myCopPed1 as 1) it's a cop, 2) I have another cop Ped which is named myCopPed2.

//= new Ped creates the Ped, and then you can sift through the arrow keys up and down to find (Model model, SpawnPoint spawnpoint, float heading);

// under Model model you can put whatever model ID you want, so in my case I want a police officer, so I did "s_m_y_cop_01".

// I have set my SpawnPoint as SpawnPointmyCopPed1.Position, yours could be called just plain SpawnPoint, but mine is from a more complex callout.

// and then, I believe (never used it), float heading is ho high or low the ped is. Generally you would want your Ped at 0.0f unless you have some weird callout that spawns the guy in the air lol (Suicidal Guy Jumped off Building? CALLOUT IDEA! :) )

myCopPed1 = new Ped("s_m_y_cop_01", SpawnPointmyCopPed1.Position, 0.0f);

Now, you may be wondering later on.. can I list off a few different models and just get it to randomly pick from that list/string of models? Yes, you can! It's pretty simple too..

// Okay, in this example I'm using a Vehicle style, same thing as Ped but spawning a Vehicle.

// We use Model[] VehicleModels = new Model[] to start off and initialise it, and then we do { }; and inside those brackets we list off in strings what models we want spawned. So since I want a cop car, I could put any cop car models in there, which I have done.

Model[] VehicleModels = new Model[]
            {
                "POLICE", "POLICE2", "POLICE3", "POLICE4", "FBI"
            };

// Here, we're just doing the same thing we did for our CopPed. we do myCopCar1 to start it off, = new Vehicle to tell the code we're creating a new Vehicle, then (VehicleModels[new Random().Next(VehicleModels.Length)] okay that might sound confusing, but it's just taking the VehicleModels we created, creating a new Random generator type of sorts, and creating the next vehicle to spawn, except randomly. Then we have SpawnPointmyCopCar1.Position to tell it where to spawn the car, again, yours could be as simple as "SpawnPoint".

myCopCar1 = new Vehicle(VehicleModels[new Random().Next(VehicleModels.Length)], SpawnPointmyCopCar1.Position);

Hope this helped or helps you in the future, if you need any further explaining or have some questions let me know! I'm always here :)

Edited by ToastinYou
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...