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.

Deriving class frrom Ped

Featured Replies

I need to do something that seems like it should be simple but I'm having a tough time doing it.  The end goal is to attach some properties to a Ped, for example a string that contains what is in the ped's pocket.  So say, a ped was searched for the first time so I generate a string of what is in that ped's pocket and somehow save it to that ped so that if we searched the same ped again, you would get the same string. 

The way I have been trying to do this is by creating a class that inherits the Ped class and adding the properties to this class.  The problem is if I search a ped on the street they aren't the class I created, they are a normal Ped class, so they don't have this property.

This is where I'm stuck.  Is it possible to clone this Ped as an object of my derived class? Or is there a simply way entirely to keep track of properties that are specific to a pedestrian?

 

Thanks for any help.  I'm not too familiar with Rage yet.

I have done this. I'm not near my computer at the moment, but I'll post again here sometime tonight or tomorrow with an example. 

Stealth22
LSPDFR Tester | Plugin Developer
My Plugins: Code 3 Callouts | Traffic Control | Keep Calm | ALPR+

Please do not PM me for any kind of technical support.
I unfortunately do not have enough free time to answer every PM that I get. For issues with my plugins, please post in the comments section of the file, or it's forum thread. You'll get a much quicker response from me there than if you send me a PM; I do my best to respond to every question in the comments sections. For API/programming questions, please post them in the API Development forum, so all developers can benefit from the answer as well. Thanks!

What I did for my Ped Search plugin is check if a ped was in an array of peds, and if not, add them to the array using a Dictionary<Ped, string[]>. The string array would contain the items you found, and if you had already searched the ped (if they were already in the array) I just displayed the items you had found. This is the same as how I did it for Vehicle Search as well. Might not be the most efficient method (still learning) but it works.

 

You can also set the Default Ped Type the peds in the world spawn as. At the top, where your plugin info is, you can add DefaultPedType = YourPedClass and each Ped in the world will be that class. YourPedClass needs to inherit from the Rage.Ped class, and also needs these constructors:

 

public YourPedClass(Model model, Vector3 position, float heading) 
            :base(model, position, heading)
{
    // stuff
}

public YourPedClass(Model model, Vector3 position) 
    :base(model, position)
{
    // stuff
}

protected internal YourPedClass(PoolHandle handle) 
    :base(handle)
{
    // stuff
}

 

  • Author

Thanks for the help everyone. I'm going to try out a couple methods and see which one I like better. 

There is an extensive example on this in the examples folder of ragepluginhooksdk which helped me out a lot. 

I looked at that example and it helped with inheritance a lot but it only showed spawning new peds of the MyPed type instead of working with what is already there. 

 At the top, where your plugin info is, you can add DefaultPedType = YourPedClass and each Ped in the world will be that class

I like this idea but would it may it incompatible with any plugin that also wanted to change the default Ped type?

I can't find the code where I was doing something similar. I'll need to search for it to see what I did.

But for your purposes, you could store a global Dictionary object...use Rage.PoolHandle for the key, and a String (Or a List<String>, for multiple things) that would store what is in that ped's pocket. Then, when you do a ped search, just search your Dictionary for that ped's handle to find the String (or String List) for what is in their pocket.

Stealth22
LSPDFR Tester | Plugin Developer
My Plugins: Code 3 Callouts | Traffic Control | Keep Calm | ALPR+

Please do not PM me for any kind of technical support.
I unfortunately do not have enough free time to answer every PM that I get. For issues with my plugins, please post in the comments section of the file, or it's forum thread. You'll get a much quicker response from me there than if you send me a PM; I do my best to respond to every question in the comments sections. For API/programming questions, please post them in the API Development forum, so all developers can benefit from the answer as well. Thanks!

Thanks for the help everyone. I'm going to try out a couple methods and see which one I like better. 

I looked at that example and it helped with inheritance a lot but it only showed spawning new peds of the MyPed type instead of working with what is already there. 

I like this idea but would it may it incompatible with any plugin that also wanted to change the default Ped type?

Probably, which is why I'm using the first method I described.

  • 2 weeks later...

Probably, which is why I'm using the first method I described.

I don't think it does. I did this for one of my plugins and I haven't run into any conflicts yet. 

I don't think it does. I did this for one of my plugins and I haven't run into any conflicts yet. 

Well theoretically, it'd only conflict if someone else's plugin was doing the same thing.

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.