Charles_Manson Posted December 22, 2018 Share Posted December 22, 2018 Anyway to detect a headshot ? thanks in advance Link to comment Share on other sites More sharing options...
Jitnaught Posted December 22, 2018 Share Posted December 22, 2018 Try these natives: HAS_ENTITY_BEEN_DAMAGED_BY_ENTITY GET_PED_LAST_DAMAGE_BONE Link to comment Share on other sites More sharing options...
Charles_Manson Posted December 23, 2018 Author Share Posted December 23, 2018 On 12/22/2018 at 11:44 AM, Jitnaught said: Try these natives: HAS_ENTITY_BEEN_DAMAGED_BY_ENTITY GET_PED_LAST_DAMAGE_BONE thanks also how to detect Whether player picked up money or not ? Link to comment Share on other sites More sharing options...
Jitnaught Posted December 23, 2018 Share Posted December 23, 2018 (edited) If you created the pickup, you can use this: if (myPickup.IsCollected) { } And the native for that is: OBJECT::HAS_PICKUP_BEEN_COLLECTED If you didn't create the pickup, then I'm not sure. Edited December 23, 2018 by Jitnaught c# info Link to comment Share on other sites More sharing options...
Guest Posted December 23, 2018 Share Posted December 23, 2018 (edited) This is what I use for money collection in my addon peds. I have just pulled out all the relevant code into a standalone project... which seems to work. If you saw what I posted here earlier, sorry, that just turned into a mess. I can't say if this is the best way, or even the right way but it seems to work okay. Edit: I probably should have said, this is a system I use in my Players Extended mod, that gives addon peds a money system to buy things and pay for activities. With the normal players, you might have access to more money related info. At the very least, you could monitor the player's money changing and if it coincides with a pickup occuring, you will know how much they have picked up. using System; using System.Collections.Generic; using GTA; using GTA.Math; using GTA.Native; using System.Linq; namespace MoneyPickups { public struct MoneyPickup { public MoneyPickup(Prop prop, Vector3 position) { MoneyProp = prop; Position = position; } public Prop MoneyProp; public Vector3 Position; } public class cMoneyPickups : Script { private Ped PlayerPed; private List<int> MoneyHashes; private List<string> MoneyPropNames = new List<string>() { "prop_ld_wallet_01", "prop_ld_wallet_01_s", "prop_ld_wallet_02", "prop_ld_wallet_pickup", "prop_cash_pile_01", "prop_cash_pile_02" }; private Dictionary<int, MoneyPickup> DroppedCash = new Dictionary<int, MoneyPickup>(); public cMoneyPickups() { Tick += onTick; Aborted += onAborted; Interval = 0; CreateMoneyHashes(); } private void CreateMoneyHashes() { MoneyHashes = new List<int>(); for (int i = 0; i < MoneyPropNames.Count; i++) { MoneyHashes.Add(Function.Call<int>(Hash.GET_HASH_KEY, MoneyPropNames[i])); } } private void onTick(object sender, EventArgs e) { // Exits from the loop if the game is loading if (Game.IsLoading) return; // A collection of lines that process the player's current state, along with the player's vehicle if (PlayerPed != Game.Player.Character) PlayerPed = Game.Player.Character; DoCashPickupWatch(); WatchForMoneyCollection(); } private void DoCashPickupWatch() { for (int i = 0; i < MoneyHashes.Count; i++) { if (DoesObjectExist(PlayerPed.Position, 5f, MoneyHashes[i])) { Prop money = GetClosestObjectofType<Prop>(PlayerPed.Position, 5f, MoneyHashes[i], false); if (!DroppedCash.ContainsKey(money.Handle)) { DroppedCash.Add(money.Handle, new MoneyPickup(money, money.Position)); } } } } private void WatchForMoneyCollection() { foreach (int key in DroppedCash.Keys.ToList()) { if (!DroppedCash[key].MoneyProp.Exists()) { // This is to make sure we're not given the cash for missed pickups that just stop existing. Not sure on the 2f range yet // though, will have to watch for any collections that get missed if (World.GetDistance(DroppedCash[key].Position, PlayerPed.Position) < 2f) { UI.Notify("Picked up: " + key.ToString()); DroppedCash.Remove(key); } } } } private bool DoesObjectExist(Vector3 position, float radius, int hash) { return Function.Call<bool>(Hash.DOES_OBJECT_OF_TYPE_EXIST_AT_COORDS, position.X, position.Y, position.Z, radius, hash, 0); } private T GetClosestObjectofType<T>(Vector3 position, float radius, int hash, bool isMission) { return Function.Call<T>(Hash.GET_CLOSEST_OBJECT_OF_TYPE, position.X, position.Y, position.Z, radius, hash, isMission, 0, 0); } private void onAborted(object sender, EventArgs e) { // Should do cleanup of any props held in the dictionary here... } } } Edited December 23, 2018 by Guest 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