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.

[C#] Scripthook - Creating random ped?

Featured Replies

Firstly, I apologize if this doesn't belong here(I felt it'd make better sense to be in questions rather than the scripts showcase.. if I'm wrong I ask that this thread be moved.)

 

I'm finally getting the hang of using the C# scripthook, with just one problem stopping me at the moment. How does one spawn a random ped? Unfortunately I've been unable to find anything like CreateRandomPed() or a model.random flag for CreatePed, and for a bit I thought that World.GetRandomPed() would work, but I haven't been able to make it work properly. It seems to work sometimes, but most of the time it's just causing an error in my script and it's kind of annoying.

 

I also thought about holding an array of the different model names, and calling a random one, but I realized the list would probably be massive. After finding nothing useful on google, I decided to ask here.

 

So, those of you who are familiar with scripthook, what do you do to spawn random peds? 'Cause I'm lost.

  • Author

I think it's  

GTA.Native.Function.Call("Create_Random_Char")

It was a loooooong time ago I messed with that kind of coding. 

 

This would work, but the problem is that I need to interact with these peds by saving them to a variable, and the native calls don't return peds. Thanks though!

 

When not passing a model as argument, it will take a random one:

 

GTA.Ped ped = GTA.World.CreatePed(GTA.Vector3.Zero);

 

My favorite thing about programming.. here I've been jumping through hoops trying to make this work and it turns out the simplest solution is just to drop the model name. Thanks for the help, LMS! This works great!

This would work, but the problem is that I need to interact with these peds by saving them to a variable, and the native calls don't return peds. Thanks though!

 

 

My favorite thing about programming.. here I've been jumping through hoops trying to make this work and it turns out the simplest solution is just to drop the model name. Thanks for the help, LMS! This works great!

 

You can also pass GTA.Gender to it as well to limit to be a random female or male char.

"You tell me exactly what you want, and I will very carefully explain to you why it cannot be."

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

Similar Content

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.