Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

[RESOLVED] Scripthookv.net - not dropping weapon


waynieoaks
 Share

Recommended Posts

[EDIT]: Seems to be only in my dev install and not other installs - so there must be a problem with my install. Will go back and try to work out what it is. Code seems to be good. 

 

For some reason, my code is no longer dropping the weapon (I am sure it use to work). 

 

I am using: 

 

Function.Call(Hash.SET_PED_DROPS_WEAPON, Game.Player.Character);

 

What seems to happen at the moment is the weapon is put away rather than dropped. I cannot for the life of me workout why. Has anybody seen this before? 

 

Many thanks. 

Edited by waynieoaks
Link to comment
Share on other sites

9 hours ago, waynieoaks said:

[EDIT]: Seems to be only in my dev install and not other installs - so there must be a problem with my install. Will go back and try to work out what it is. Code seems to be good. 

 

For some reason, my code is no longer dropping the weapon (I am sure it use to work). 

 

I am using: 

 

Function.Call(Hash.SET_PED_DROPS_WEAPON, Game.Player.Character);

 

What seems to happen at the moment is the weapon is put away rather than dropped. I cannot for the life of me workout why. Has anybody seen this before? 

 

Many thanks. 

 

I don't fully understand what you mean, but I think it's that you want your generated ped to drop weapons when they die. You could try this.

 

Function.Call(Hash.SET_PED_DROPS_WEAPONS_WHEN_DEAD, pedname, true);

 

9 hours ago, waynieoaks said:

[EDIT]: Seems to be only in my dev install and not other installs - so there must be a problem with my install. Will go back and try to work out what it is. Code seems to be good. 

 

For some reason, my code is no longer dropping the weapon (I am sure it use to work). 

 

I am using: 

 

Function.Call(Hash.SET_PED_DROPS_WEAPON, Game.Player.Character);

 

What seems to happen at the moment is the weapon is put away rather than dropped. I cannot for the life of me workout why. Has anybody seen this before? 

 

Many thanks. 

You can do the same

 

pedname.DropsWeaponsOnDeath(get; set:);

 

Link to comment
Share on other sites

Why your generated ped did not drop weapons, you first have not given your generated ped weapons, if not then will not drop weapons, on the contrary, if given weapons, regardless of whether there is no code written about dropping weapons upon death, it will drop, this is the rule of the game.

Link to comment
Share on other sites

Thank you @leihebi

 

That is not quite what I am trying to do unfortunately. I am trying to drop the weapon while alive. 

 

My code is to allow you to surrender to police if you have more than one star and does the following: 

 

1. If in a vehicle, get out of the vehicle

2. If holding a weapon, drop the weapon to the ground

3. Put hands up until busted OR you change your mind and run

 

It seems to work fine on one of my installs, but was not working on my Dev install. 

Dev is a clean install of GTA V with Rage Plugin Hook, Scripthookv and Scripthookv.net 

 

The other environment has several mods for gameplay including some combat / weapons ones. When I rename the mods folder to disable them, it stops working - So I think there is something in the mods folder of my other installs making it work. 

 

I am now going to try copying the mods folder to Dev to see if my code then works on dev. If it does I will then look at what mods there are to work out which one is making it work. 

 

I may reinstall Dev just to ensure I haven't corrupted a vanilla file somewhere along the way. 

 

I have a feeling the drop weapon function may not work properly but few people if any have tried using it? Maybe?

 

Like everything I do, something simple seems to be complicated 🙂

Link to comment
Share on other sites

41 minutes ago, waynieoaks said:

Thank you @leihebi

 

That is not quite what I am trying to do unfortunately. I am trying to drop the weapon while alive. 

 

My code is to allow you to surrender to police if you have more than one star and does the following: 

 

1. If in a vehicle, get out of the vehicle

2. If holding a weapon, drop the weapon to the ground

3. Put hands up until busted OR you change your mind and run

 

It seems to work fine on one of my installs, but was not working on my Dev install. 

Dev is a clean install of GTA V with Rage Plugin Hook, Scripthookv and Scripthookv.net 

 

The other environment has several mods for gameplay including some combat / weapons ones. When I rename the mods folder to disable them, it stops working - So I think there is something in the mods folder of my other installs making it work. 

 

I am now going to try copying the mods folder to Dev to see if my code then works on dev. If it does I will then look at what mods there are to work out which one is making it work. 

 

I may reinstall Dev just to ensure I haven't corrupted a vanilla file somewhere along the way. 

 

I have a feeling the drop weapon function may not work properly but few people if any have tried using it? Maybe?

 

Like everything I do, something simple seems to be complicated 🙂

 

The following determines whether the player or ped is arrested, and if so can write a new event

 

Checks whether the specified player has a Ped, the Ped is not dead, is not injured and is not arrested.

Function.Call(Hash.IS_PLAYER_PLAYING, Player player);

 

Return true while player is being arrested / busted.

If atArresting is set to 1, this function will return 1 when player is being arrested (while player is putting his hand up, but still have control)

If atArresting is set to 0, this function will return 1 only when the busted screen is shown.

Function.Call(Hash.IS_PLAYER_BEING_ARRESTED, Player player, BOOL atArresting);

 

Returns the time since the character was arrested in (ms) milliseconds.

example

var time = Function.call<int>(Hash.GET_TIME_SINCE_LAST_ARREST();

UI.DrawSubtitle(time.ToString());

if player has not been arrested, the int returned will be -1.  

 

 

I'm not sure if you want the player to perform these events, or if you want the specified ped to perform them?

Link to comment
Share on other sites

player
  if (Game.Player.Character.IsSittingInVehicle())
{
         //Events
}

ped
  if (ped.IsSittingInVehicle())
{
        //Events
}

 

Link to comment
Share on other sites

Thank you - yes - I already have these working 🙂

 

It is just the dropping weapon part that is not working (before) being arrested. 

Link to comment
Share on other sites

Worked out what to do and wanted to share here in case anybody else looks for this in the future. 

 

To get your main character to drop the weapon they are holding use SET_PED_DROPS_INVENTORY_WEAPON instead of SET_PED_DROPS_WEAPON

 

void SET_PED_DROPS_INVENTORY_WEAPON(Ped ped, Hash weaponHash, float xOffset, float yOffset, float zOffset, int ammoCount);

 

Example: 

Function.Call(Hash.SET_PED_DROPS_INVENTORY_WEAPON, Game.Player.Character, Game.Player.Character.Weapons.Current.Hash, 0.4, 0.7, -0.1, -1);

 

As an added bonus, to not select a different weapon automatically you can also follow up with: 

Function.Call(Hash.SET_CURRENT_PED_WEAPON, Game.Player.Character, 0xA2719263, true);

Which will change current weapon to none. 

 

 

Link to comment
Share on other sites

2 hours ago, waynieoaks said:

Worked out what to do and wanted to share here in case anybody else looks for this in the future. 

 

To get your main character to drop the weapon they are holding use SET_PED_DROPS_INVENTORY_WEAPON instead of SET_PED_DROPS_WEAPON

 

void SET_PED_DROPS_INVENTORY_WEAPON(Ped ped, Hash weaponHash, float xOffset, float yOffset, float zOffset, int ammoCount);

 

Example: 

Function.Call(Hash.SET_PED_DROPS_INVENTORY_WEAPON, Game.Player.Character, Game.Player.Character.Weapons.Current.Hash, 0.4, 0.7, -0.1, -1);

 

As an added bonus, to not select a different weapon automatically you can also follow up with: 

Function.Call(Hash.SET_CURRENT_PED_WEAPON, Game.Player.Character, 0xA2719263, true);

Which will change current weapon to none. 

 

 

oh

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.