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.

[SOLVED] Adding a property to an object

Featured Replies

Is there an easy way to add a another property to a Ped? Like creating a new class, using the existing Ped object and adding some stuff to it.

public class XPed
    {
        
        public bool HasBeenReleased { get; set; }
       
        public XPed(Ped ped, bool released)
        {
            XPed = ped;
            HasBeenReleased = released;
        }

something like this (doesn't work obviously)

Edited by khorio

You have to create a class that inherits from the Ped class, then you can add any methods or properties to that class. And instead of using 'new Ped()' in your code you use 'new MyPed()'
Example from RPH:

Spoiler

namespace PedAndVehicleInheritance
{
    using Rage;

    public class MyPed : Ped
    {
        public MyPed(Model model, Vector3 position, float heading) : base(model, position, heading)
        {
        }

        public MyPed(Vector3 position) : base(position)
        {
        }

        private MyPed(PoolHandle handle) : base(handle)
        {
        }

        /// <summary>
        /// Turns this <see cref="MyPed"/> into fireworks.
        /// </summary>
        public void TurnIntoFireworks()
        {
            this.Velocity = Vector3.WorldUp * 30f;
            GameFiber.Wait(500);
            World.SpawnExplosion(this.Position, 16, 3f, true, false, 3f);
        }
    }
}

 

 

What he said. I posted an example of this on the LSPDFR-API repository on GitHub.

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!

If you just need to store extra data about the ped, it might be simpler to just stuff it in the Metadata. Eg:

if (somethingBadHappened) { //imaginary bool for demo purposes :P
	myPed.Metadata.ReallyDead=1;
}

// other code

if (myPed.Exists() && myPed.Metadata.ReallyDead == 1)
{
	Game.DisplayNotification("~b~" + myOfficer.OfficerName + "~w~: Patient is DOA, notifying coroner.");
	End();
}

 

My YouTube Channel: Darkmyre Gaming (Australian LSPDFR patrols, plugins in development, and other games)

My Discord Server | AusGamer Network

 

Please do not PM me for technical support or bug reports, use the appropriate forum or plugin's comments instead.

  • Author
2 minutes ago, Darkmyre said:

If you just need to store extra data about the ped, it might be simpler to just stuff it in the Metadata. Eg:

 

That's good to know :)

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.