Jump to content

Get Targeted Ped


fichtenwalder

Recommended Posts

fichtenwalder

Hi,

 

currently i write a Script with the C++ Scripthook from aru. I want to get the speed of the Targeted PED.

 

Now My Problem: How can i get the targeted PED? There is no Native Function. Only to get If I Targeting a Ped.

 

I got the tip from another Thread, that i have to check all PEDs if i aiming them. But there is the next Question. How can I get all PED's???

 

 

Im a Newbie in C++ and this Scripthook. But I'm not programming Noob (I habe al ot of experience with VB.NET). I can't use the .NET Scripthook because the IVMP-Client crash's with that. IN SP the .NET Scripthook is perfectly.

 

 

Thanks für good replys

felix

Link to comment
https://gtaforums.com/topic/465043-get-targeted-ped/
Share on other sites

with ScirptHook it s better in MP...try this:

 

GetCharCoordinates(GetPlayerPed(), &x1, &y1, &z1);SetTimerA(0);     bool search = true;     while(search)     {         int netid++;     	if(netid>15000)     	{       search = false;        netid = 0;      	}     	GetPedFromNetworkId(netid, &ped);          	if(DoesCharExist(ped) && ped != GetPlayerPed())     	{       if(IsCharInArea2D(ped, x1+20, y1+20, x1-20, y1-20, 0))       {       	search = false;       }     	}

 

Link to comment
https://gtaforums.com/topic/465043-get-targeted-ped/#findComment-1060245266
Share on other sites

iriedreadlock23

There is actually a very simple way to do it using Native GET_CLOSEST_CHAR. You need to use flags to get get all peds. Note the flags are not completely documented, but you can find the numbers in HazardX's scripthook. It may not be fastest way, but its easy, and it works. Loop the function, get all the valid Handles all into a simple collection (easy way to prevent duplicating by simple logic) where u can easily check in every tick wheter some of them are being targetted. Make sure that the handles are valid before using them. Also, you could even create timer for each ped, so it will be more precise, but possibly more CPU heavy. Note that depending on your rig, game spawn and destroys ped handles. Please, use GtaModding.com to find exact answers to your questions about these natives.

Link to comment
https://gtaforums.com/topic/465043-get-targeted-ped/#findComment-1060245341
Share on other sites

iriedreadlock23

Sorry to doublepost. But as LMS said you should ask HazardX for his solution, which seems to be the faster, and maybe in your case, much better solution to use. You could find an answer how to build this function even without HazardX, but I am not allowed to tell you how. Forum rules.

Link to comment
https://gtaforums.com/topic/465043-get-targeted-ped/#findComment-1060245448
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
  • 0 User Currently Viewing
    0 members, 0 Anonymous, 0 Guests

×
×
  • Create New...

Important Information

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