Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. Red Dead Redemption 2

      1. Gameplay
      2. Missions
      3. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. Arena War
      2. After Hours
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA Next

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

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

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

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

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

    2. Forum Support

    3. Site Suggestions

Sign in to follow this  
Mordecki

[C++] Get Target

Recommended Posts

Mordecki

Hey, does anyone know the native function to get pedestrian which is being targeted by player ? Thanks.

Share this post


Link to post
Share on other sites
Mordecki

Loop through all the peds and check if the player is aiming at a ped by using the IS_PLAYER_FREE_AIMING_AT_CHAR native.

 

I would have to get all pedestrians around player and that doesn't include dead or fleeing one.

My point is to get all pedestrians which are alive or dead or fleeing ... simply all pedestrians around player.

As far as I know that's impossible, or have you got any idea how could I get dead/fleeing/... characters ?

Share this post


Link to post
Share on other sites
Jitnaught

It's not impossible because that's what SHDN does: loop through all the peds then check if the player is aiming at any of them ped.

 

Here's what SHDN does

// GTA.Player[HandleProcessCorruptedStateExceptions]public unsafe Ped GetTargetedPed(){	int num = (int)stackalloc byte[<Module>.__CxxQueryExceptionSize() / 1];	Model model = new Model(0);	int[] validPedHandles = World.GetValidPedHandles(model);	int num2 = <Module>.Scripting.?A0x41b70ddb.ConvertIntToPlayerIndex((uint)this.pID);	for (int i = 0; i < validPedHandles.Length; i++)	{		try		{			if (<Module>.Scripting.?A0x41b70ddb.IsPlayerFreeAimingAtChar(num2, validPedHandles[i]) != null)			{				return ContentCache.GetPed(validPedHandles[i]);			}			goto IL_91;		}		uint exceptionCode = (uint)Marshal.GetExceptionCode();		endfilter(<Module>.__CxxExceptionFilter(Marshal.GetExceptionPointers(), null, 0, null));		IL_91:;	}	return null;}
Edited by LetsPlayOrDy

Share this post


Link to post
Share on other sites
Mordecki

 

It's not impossible because that's what SHDN does: loop through all the peds check if the player is aiming at the ped.

 

Here's what SHDN does

// GTA.Player[HandleProcessCorruptedStateExceptions]public unsafe Ped GetTargetedPed(){	int num = (int)stackalloc byte[<Module>.__CxxQueryExceptionSize() / 1];	Model model = new Model(0);	int[] validPedHandles = World.GetValidPedHandles(model);	int num2 = <Module>.Scripting.?A0x41b70ddb.ConvertIntToPlayerIndex((uint)this.pID);	for (int i = 0; i < validPedHandles.Length; i++)	{		try		{			if (<Module>.Scripting.?A0x41b70ddb.IsPlayerFreeAimingAtChar(num2, validPedHandles[i]) != null)			{				return ContentCache.GetPed(validPedHandles[i]);			}			goto IL_91;		}		uint exceptionCode = (uint)Marshal.GetExceptionCode();		endfilter(<Module>.__CxxExceptionFilter(Marshal.GetExceptionPointers(), null, 0, null));		IL_91:;	}	return null;}

 

Kinda difficult to understand, doesn't work with C++ getting errors.

The structure of this code is not the same as mine :blink:

Share this post


Link to post
Share on other sites
Wiebrendh

 

 

It's not impossible because that's what SHDN does: loop through all the peds check if the player is aiming at the ped.

 

Here's what SHDN does

// GTA.Player[HandleProcessCorruptedStateExceptions]public unsafe Ped GetTargetedPed(){	int num = (int)stackalloc byte[<Module>.__CxxQueryExceptionSize() / 1];	Model model = new Model(0);	int[] validPedHandles = World.GetValidPedHandles(model);	int num2 = <Module>.Scripting.?A0x41b70ddb.ConvertIntToPlayerIndex((uint)this.pID);	for (int i = 0; i < validPedHandles.Length; i++)	{		try		{			if (<Module>.Scripting.?A0x41b70ddb.IsPlayerFreeAimingAtChar(num2, validPedHandles[i]) != null)			{				return ContentCache.GetPed(validPedHandles[i]);			}			goto IL_91;		}		uint exceptionCode = (uint)Marshal.GetExceptionCode();		endfilter(<Module>.__CxxExceptionFilter(Marshal.GetExceptionPointers(), null, 0, null));		IL_91:;	}	return null;}

 

Kinda difficult to understand, doesn't work with C++ getting errors.

The structure of this code is not the same as mine :blink:

 

 

Why use natives? There is something like: Player.Character.GetTargetedPed();

 

Not sure what it is, but i believe that^

Edited by Wiebrendh

Share this post


Link to post
Share on other sites
stef538

Because C++ isn't C# or VB.

Share this post


Link to post
Share on other sites
leftas

 

 

 

It's not impossible because that's what SHDN does: loop through all the peds check if the player is aiming at the ped.

 

Here's what SHDN does

// GTA.Player[HandleProcessCorruptedStateExceptions]public unsafe Ped GetTargetedPed(){	int num = (int)stackalloc byte[<Module>.__CxxQueryExceptionSize() / 1];	Model model = new Model(0);	int[] validPedHandles = World.GetValidPedHandles(model);	int num2 = <Module>.Scripting.?A0x41b70ddb.ConvertIntToPlayerIndex((uint)this.pID);	for (int i = 0; i < validPedHandles.Length; i++)	{		try		{			if (<Module>.Scripting.?A0x41b70ddb.IsPlayerFreeAimingAtChar(num2, validPedHandles[i]) != null)			{				return ContentCache.GetPed(validPedHandles[i]);			}			goto IL_91;		}		uint exceptionCode = (uint)Marshal.GetExceptionCode();		endfilter(<Module>.__CxxExceptionFilter(Marshal.GetExceptionPointers(), null, 0, null));		IL_91:;	}	return null;}

 

Kinda difficult to understand, doesn't work with C++ getting errors.

The structure of this code is not the same as mine :blink:

 

 

Why use natives? There is something like: Player.Character.GetTargetedPed();

 

Not sure what it is, but i believe that^

 

It's on C# and it's from "ScriptHookDotNet".

And this native which LetsPlayOrDie wrote, is being used in ScriptHookDotNet in GetTargetedPed();

 

 

Because C++ isn't C# or VB.

True, but it's very similar(just C# has and java things, but anything else which not java, is C++). And It's not hard to convert from c++ to c# when code is not complied.

As Shdn has open source, you just can take a look into it.

	[system::Runtime::ExceptionServices::HandleProcessCorruptedStateExceptions]	Ped^ Player::GetTargetedPed() {		array<int>^ list = World::GetValidPedHandles(GTA::Model::Null); //unmanaged::MemoryAccess::GetPedHandleList();		int idx = Index;		for (int i = 0; i < list->Length; i++) {			try {				if (Scripting::IsPlayerFreeAimingAtChar(idx, list[i])) return ContentCache::GetPed(list[i]);			} catch (...) {}		}		return nullptr;	}

And it's CLR(Common Language Runtime)(C#/c++(together) managed)

 

 

 

It's not impossible because that's what SHDN does: loop through all the peds check if the player is aiming at the ped.

 

Here's what SHDN does

// GTA.Player[HandleProcessCorruptedStateExceptions]public unsafe Ped GetTargetedPed(){	int num = (int)stackalloc byte[<Module>.__CxxQueryExceptionSize() / 1];	Model model = new Model(0);	int[] validPedHandles = World.GetValidPedHandles(model);	int num2 = <Module>.Scripting.?A0x41b70ddb.ConvertIntToPlayerIndex((uint)this.pID);	for (int i = 0; i < validPedHandles.Length; i++)	{		try		{			if (<Module>.Scripting.?A0x41b70ddb.IsPlayerFreeAimingAtChar(num2, validPedHandles[i]) != null)			{				return ContentCache.GetPed(validPedHandles[i]);			}			goto IL_91;		}		uint exceptionCode = (uint)Marshal.GetExceptionCode();		endfilter(<Module>.__CxxExceptionFilter(Marshal.GetExceptionPointers(), null, 0, null));		IL_91:;	}	return null;}

 

Kinda difficult to understand, doesn't work with C++ getting errors.

The structure of this code is not the same as mine :blink:

 

You know c++ well or not ? It seems that you are newbie. I don't suggest you copy+paste code, it gives bad experience when you don't know what code does.

 

 

no_idea_what_im_doing.jpg

 

 

Best wishes,

Paul.

Edited by leftas

Share this post


Link to post
Share on other sites
Silent

I'm not sure if Mordecki is a newbie ;)

Share this post


Link to post
Share on other sites
leftas

Oh, Sorry, I am just saying, because it's not hard to see it's c++ code or c#,

P.S. sorry if I was rude.

 

Best regards,

Paul.

Share this post


Link to post
Share on other sites
Wiebrendh

Oh, did not know that was not possible :) Sorry

Share this post


Link to post
Share on other sites
Mordecki

You know c++ well or not ? It seems that you are newbie. I don't suggest you copy+paste code, it gives bad experience when you don't know what code does.

 

 

no_idea_what_im_doing.jpg

 

 

Best wishes,

Paul.

Yeah, I know pretty well what I'm doing.

That's why I put [C++] on front of this topic.

I didn't copy and paste the code, I have been trying to convert those functions.

The reason I wrote "The structure of this code is not the same as mine"

is because not all functions are working the same way with C++

Share this post


Link to post
Share on other sites
leftas

I am sorry, I just thought that u another guy from that Indian team. I posted code you wanted in c++/clr. It's hard to convert as Ilspy shows shdn functions not Scripthook.

 

Best regards,

Paul.

Share this post


Link to post
Share on other sites
Silent

He from the 'selfish Eastern European f*cks' Polish team ;)

Share this post


Link to post
Share on other sites
maro_hannover

EDIT: I DID NOT UNDERSTAND CORRECTLY. THIS POST OF MINE IS POINTLESS

Silent You're The Biggest Racist in World History.

if i don't understand please excuse me,if i understand correctly then -- this is shdn but it uses natives. so i think it may help

because in c#

Native.Function.Call("EXAMPLE_NATIVE",param)

and C++

NATIVE_EXAMPLE_NATIVE(param)

here is the link

http://gtaxscripting.blogspot.com/2013/03/tut-iv-detecting-targets-peds-vehicles.html

Edited by maro_hannover

Share this post


Link to post
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
Sign in to follow this  

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

×

Important Information

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