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.

Removing weapon instead of dropping it

Featured Replies

I'm looking for a native function that will delete a weapon from the player's inventory as opposed to dropping it on the ground.

 

I've been using this:

foreach(WeaponDescriptor weapon in playerPed.Inventory.Weapons)
            {
                uint hash = weapon.Asset.Hash;
                if (weaponsList.Contains(hash))
                {
                    weapon.Drop();
                }
            }

But it creates a pickup of the weapon on the floor.

 

Any idea how else I could do this?

Thanks.

You could use the `REMOVE_WEAPON_FROM_PED` native:

 

foreach(WeaponDescriptor weapon in playerPed.Inventory.Weapons)
            {
                uint hash = weapon.Asset.Hash;
                if (weaponsList.Contains(hash))
                {
                    NativeFunction.Natives.x4899CB088EDF59B8(playerPed, weapon.Asset.Hash);
                    // the hash of the native comes from http://www.dev-c.com/nativedb/func/info/4899cb088edf59b8
                }
            }

 

As you might guess, I make PeterUCallouts. I love working to bring LSPDFR players the kind of callouts that strike a good balance between realism and fun and are stable & varied!

Unfortunately I cannot offer support via PM -- please use the forums, so that others may benefit from your solutions!

  • 2 weeks later...

You can use the "WeaponDescriptorCollection.Remove" method too, you can pass a WeaponHash or a WeaponDescriptor.

playerPed.Inventory.Weapons.Remove(WeaponHash.AdvancedRifle);


// in your case, given that "weaponsList" is a list/array of uint
foreach (uint hash in weaponsList)
{
    playerPed.Inventory.Weapons.Remove((WeaponHash)hash);
}

 

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.