fichtenwalder Posted December 12, 2010 Share Posted December 12, 2010 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 More sharing options...
Kucikuc24 Posted December 13, 2010 Share Posted December 13, 2010 Ped closPed, targetPed;GetClosestChar(x, y, z, 1, 2, &closPed);if(IsPlayerAimingAtChar(GetPlayer(), closPed) closPed = targetPed; try somethink like this Link to comment https://gtaforums.com/topic/465043-get-targeted-ped/#findComment-1060244446 Share on other sites More sharing options...
fichtenwalder Posted December 13, 2010 Author Share Posted December 13, 2010 i think with that function i only know if i aiming the closest PED. I Think i need a loop to get it. Or i change the radius from GetClosestChar(); What do you think about that idea? Link to comment https://gtaforums.com/topic/465043-get-targeted-ped/#findComment-1060244688 Share on other sites More sharing options...
LMS Posted December 14, 2010 Share Posted December 14, 2010 Using GetClosestChar will never give you all peds. You have to access the CPool of peds, addresses are CPool+iterator+4 and size of CPool is CPool+8 as far as I remember. Link to comment https://gtaforums.com/topic/465043-get-targeted-ped/#findComment-1060244940 Share on other sites More sharing options...
Intosia Posted December 14, 2010 Share Posted December 14, 2010 Thats the beauty of the .net hook Link to comment https://gtaforums.com/topic/465043-get-targeted-ped/#findComment-1060244959 Share on other sites More sharing options...
a-k-t-w Posted December 14, 2010 Share Posted December 14, 2010 Thats the beauty of the .net hook What do you mean? Link to comment https://gtaforums.com/topic/465043-get-targeted-ped/#findComment-1060245101 Share on other sites More sharing options...
LMS Posted December 14, 2010 Share Posted December 14, 2010 That hazard has already put things like that in easy to use functions. Link to comment https://gtaforums.com/topic/465043-get-targeted-ped/#findComment-1060245180 Share on other sites More sharing options...
Kucikuc24 Posted December 14, 2010 Share Posted December 14, 2010 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 More sharing options...
iriedreadlock23 Posted December 14, 2010 Share Posted December 14, 2010 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 More sharing options...
iriedreadlock23 Posted December 14, 2010 Share Posted December 14, 2010 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 More sharing options...
Rapier Posted December 15, 2010 Share Posted December 15, 2010 You need to use flags to get get all peds. Okay, what are these flags??? Link to comment https://gtaforums.com/topic/465043-get-targeted-ped/#findComment-1060247651 Share on other sites More sharing options...
Kucikuc24 Posted December 16, 2010 Share Posted December 16, 2010 x, y, z, radius, unknown, unknown, *ped Link to comment https://gtaforums.com/topic/465043-get-targeted-ped/#findComment-1060247933 Share on other sites More sharing options...
Rapier Posted December 17, 2010 Share Posted December 17, 2010 Kucikuc24, I mean what are the numbers... Or what combination of numbers to get any ped. You understand? Link to comment https://gtaforums.com/topic/465043-get-targeted-ped/#findComment-1060249453 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