Prof_Farnsworth Posted July 12, 2015 Share Posted July 12, 2015 (edited) As the title states does anyone know how to retrieve this information from a weapon or tell whether a ped was killed with a suppressor? Any help is appreciated, thanks. Prof Edited July 12, 2015 by Prof_Farnsworth Link to comment Share on other sites More sharing options...
Colata Posted July 13, 2015 Share Posted July 13, 2015 (edited) As the title states does anyone know how to retrieve this information from a weapon or tell whether a ped was killed with a suppressor? Any help is appreciated, thanks. Prof There is a function WEAPON::IS_PED_WEAPON_COMPONENT_ACTIVE Do you think that if that returns true and the ped gets a kill, you can assume it was with the suppressor? edit: like if IS_PED_WEAPON_COMPONENT_ACTIVE returns supressor as true and (deceased) was killed by Ped with suppressor true, then (deceased) was killed with a suppressor? Edited July 13, 2015 by Colata Link to comment Share on other sites More sharing options...
Prof_Farnsworth Posted July 13, 2015 Author Share Posted July 13, 2015 Thanks for the reply. Guess I'll need to do some testing. Link to comment Share on other sites More sharing options...
frodzet Posted July 14, 2015 Share Posted July 14, 2015 (edited) Here is some C# code, not sure what language you use, but: int weaponComponentHash = Function.Call<int>(Hash.GET_HASH_KEY, "COMPONENT_AT_PI_SUPP");bool hasWeaponGotComponent = Function.Call<bool>(Hash.HAS_PED_GOT_WEAPON_COMPONENT, Game.Player.Character, (int) WeaponHash.APPistol, weaponComponentHash); This will check if AP Pistol has a suppressor. Below are the possible suppressor components (i believe it's all of them): COMPONENT_AT_PI_SUPP COMPONENT_AT_PI_SUPP_02 COMPONENT_AT_AR_SUPP COMPONENT_AT_AR_SUPP_02 COMPONENT_AT_SR_SUPP COMPONENT_AT_SR_SUPP_02 so you could do something like: List<string> weaponComponentList = new List<string>(){ "COMPONENT_AT_PI_SUPP", "COMPONENT_AT_PI_SUPP_02", "COMPONENT_AT_AR_SUPP", "COMPONENT_AT_AR_SUPP_02", "COMPONENT_AT_SR_SUPP", "COMPONENT_AT_SR_SUPP_02"};foreach (WeaponHash weapon in Enum.GetValues(typeof(WeaponHash))){ foreach (string weaponComponent in weaponComponentList) { int weaponComponentHash = Function.Call<int>(Hash.GET_HASH_KEY, weaponComponent); bool hasWeaponGotComponent = Function.Call<bool>(Hash.HAS_PED_GOT_WEAPON_COMPONENT, Game.Player.Character, (int) weapon, weaponComponentHash); if (hasWeaponGotComponent && Game.Player.Character.Weapons.Current.Hash == weapon) { // Code goes here. } }} This was just quick from the top of my head, there might be a better way around it. You could probably instead of checking for all weapons and comparing them with your current weapon just check for the weapon the player is currently using, changing to the following: bool hasWeaponGotComponent = Function.Call<bool>(Hash.HAS_PED_GOT_WEAPON_COMPONENT, Game.Player.Character, (int) Game.Player.Character.Weapons.Current.Hash, weaponComponentHash); this way you would not need the first foreach :-) Edited July 14, 2015 by frodzet Prof_Farnsworth 1 Link to comment Share on other sites More sharing options...
Prof_Farnsworth Posted July 14, 2015 Author Share Posted July 14, 2015 Here is some C# code, not sure what language you use, but: int weaponComponentHash = Function.Call<int>(Hash.GET_HASH_KEY, "COMPONENT_AT_PI_SUPP");bool hasWeaponGotComponent = Function.Call<bool>(Hash.HAS_PED_GOT_WEAPON_COMPONENT, Game.Player.Character, (int) WeaponHash.APPistol, weaponComponentHash); This will check if AP Pistol has a suppressor. Below are the possible suppressor components (i believe it's all of them): COMPONENT_AT_PI_SUPP COMPONENT_AT_PI_SUPP_02 COMPONENT_AT_AR_SUPP COMPONENT_AT_AR_SUPP_02 COMPONENT_AT_SR_SUPP COMPONENT_AT_SR_SUPP_02 so you could do something like: List<string> weaponComponentList = new List<string>(){ "COMPONENT_AT_PI_SUPP", "COMPONENT_AT_PI_SUPP_02", "COMPONENT_AT_AR_SUPP", "COMPONENT_AT_AR_SUPP_02", "COMPONENT_AT_SR_SUPP", "COMPONENT_AT_SR_SUPP_02"};foreach (WeaponHash weapon in Enum.GetValues(typeof(WeaponHash))){ foreach (string weaponComponent in weaponComponentList) { int weaponComponentHash = Function.Call<int>(Hash.GET_HASH_KEY, weaponComponent); bool hasWeaponGotComponent = Function.Call<bool>(Hash.HAS_PED_GOT_WEAPON_COMPONENT, Game.Player.Character, (int) weapon, weaponComponentHash); if (hasWeaponGotComponent && Game.Player.Character.Weapons.Current.Hash == weapon) { // Code goes here. } }} This was just quick from the top of my head, there might be a better way around it. You could probably instead of checking for all weapons and comparing them with your current weapon just check for the weapon the player is currently using, changing to the following: bool hasWeaponGotComponent = Function.Call<bool>(Hash.HAS_PED_GOT_WEAPON_COMPONENT, Game.Player.Character, (int) Game.Player.Character.Weapons.Current.Hash, weaponComponentHash); this way you would not need the first foreach :-) My man! Thanks a bunch. The specific components were what I was looking for. You just saved me a bunch of time. I appreciate it. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now