Advertisement
Guest User

GET_PED_NEARBY_PEDS and GET_PED_NEARBY_VEHICLES

a guest
Oct 9th, 2017
7,005
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //by gopro_2027
  2.  
  3. //On console, the structure format is like:
  4. #define nearbyPedArraySize 100
  5. struct nearbyEnts {
  6.     int size;//32 bit integer
  7.     int entities[nearbyPedArraySize];
  8. };
  9. //on pc it's the same but with int64_t for the entities:
  10. struct nearbyEnts {
  11.     int size;//still 32 bit integer
  12.     int64_t entities[nearbyPedArraySize];
  13. };
  14.  
  15.  
  16. //heres an example of it:
  17. void deletePed(int pedID) {
  18.     //do something with pedID
  19.     int ped = pedID;
  20.     ENTITY::DELETE_ENTITY(&ped);
  21. }
  22. void runOnAllNearbyPedsToPlayer(int player, void (*f)(int)) {
  23.     nearbyEnts arr;
  24.     arr.size = nearbyPedArraySize;
  25.     int ped = PLAYER::GET_PLAYER_PED(player);
  26.     int size = PED::GET_PED_NEARBY_PEDS(ped,(int*)&arr,ped);
  27.     for (int i = 0; i < size; i++) {
  28.         f(arr.entities[i]);
  29.     }
  30. }
  31.  
  32. //then call
  33. runOnAllNearbyPedsToPlayer(PLAYER::PLAYER_ID(),deletePed);
  34.  
  35. //Note: I have not tested the pc version because I do not play on pc but based on the old code that was posted in the documentation, this should work on pc also.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement