Advertisement
lamiastella

GET_PLAYER_PED

Jan 24th, 2017
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.73 KB | None | 0 0
  1. #include "Targets.h"
  2. #include "../lib/script.h"
  3. #include <vector>
  4.  
  5. //TODO:
  6. // -Objects
  7. // -Return also PED type (animal/human) and maybe Vehicle type (discard boats, planes, trains and helicopters)
  8. // -Set max distance and return ordered by distance??
  9. std::vector<Vehicle> getVehiclesInScreen(Vehicle vehicle) {
  10.     const int ARR_SIZE = 1024;
  11.     Vehicle vehicles[ARR_SIZE];
  12.     std::vector<Vehicle> _vehicles;
  13.     int count = worldGetAllVehicles(vehicles, ARR_SIZE);
  14.     for (int i = 0; i < count; i++) {
  15.         if (ENTITY::IS_ENTITY_ON_SCREEN(vehicles[i])) {
  16.             //mona if (!ENTITY::IS_ENTITY_IN_AIR(vehicles[i]) && !ENTITY::IS_ENTITY_IN_WATER(vehicles[i])) {
  17.                 if (ENTITY::HAS_ENTITY_CLEAR_LOS_TO_ENTITY(vehicle, vehicles[i], 19)){
  18.                     Vector3 coord = ENTITY::GET_ENTITY_COORDS(vehicles[i], FALSE);
  19.                     float x, y;
  20.                     if (GRAPHICS::_WORLD3D_TO_SCREEN2D(coord.x, coord.y, coord.z, &x, &y))
  21.                     {
  22.                         char text[256];
  23.                         sprintf_s(text, "^\nVehicle\n");
  24.                         UI::SET_TEXT_FONT(0);
  25.                         UI::SET_TEXT_SCALE(0.2, 0.2);
  26.                         UI::SET_TEXT_COLOUR(255, 255, 255, 255);
  27.                         UI::SET_TEXT_WRAP(0.0, 1.0);
  28.                         UI::SET_TEXT_CENTRE(0);
  29.                         UI::SET_TEXT_DROPSHADOW(0, 0, 0, 0, 0);
  30.                         UI::SET_TEXT_EDGE(1, 0, 0, 0, 205);
  31.                         UI::_SET_TEXT_ENTRY("STRING");
  32.                         UI::_ADD_TEXT_COMPONENT_STRING(text);
  33.                         UI::_DRAW_TEXT(x, y);
  34.                         // box
  35.                         GRAPHICS::DRAW_RECT(x + 0.027f, y + 0.043f, 0.058f, 0.056f, 75, 75, 75, 75);
  36.                     }
  37.                     //_vehicles.push_back(vehicles[i]);
  38.                 }
  39.             }
  40.         }
  41.     }
  42.  
  43.     return _vehicles;
  44. }
  45.  
  46. std::vector<Ped> getPedsInScreen(Vehicle vehicle) {
  47.     const int ARR_SIZE = 1024;
  48.     Ped peds[ARR_SIZE];
  49.     std::vector<Ped> _peds;
  50.     int count = worldGetAllPeds(peds, ARR_SIZE);
  51.     for (int i = 0; i < count; i++) {
  52.         if (ENTITY::IS_ENTITY_ON_SCREEN(peds[i])) {
  53.             if (!PED::IS_PED_IN_ANY_VEHICLE(peds[i], FALSE)) {
  54.                 if (PED::GET_PED_TYPE(peds[i]) != 28) { //ANIMAL
  55.                     if (ENTITY::HAS_ENTITY_CLEAR_LOS_TO_ENTITY(vehicle, peds[i], 19)) {
  56.                         Vector3 coord = ENTITY::GET_ENTITY_COORDS(peds[i], TRUE);
  57.                         float x, y;
  58.                         if (GRAPHICS::_WORLD3D_TO_SCREEN2D(coord.x, coord.y, coord.z, &x, &y))
  59.                         {
  60.                             char text[256];
  61.                             sprintf_s(text, "^\nPed\n");
  62.                             UI::SET_TEXT_FONT(0);
  63.                             UI::SET_TEXT_SCALE(0.2, 0.2);
  64.                             UI::SET_TEXT_COLOUR(255, 255, 255, 255);
  65.                             UI::SET_TEXT_WRAP(0.0, 1.0);
  66.                             UI::SET_TEXT_CENTRE(0);
  67.                             UI::SET_TEXT_DROPSHADOW(0, 0, 0, 0, 0);
  68.                             UI::SET_TEXT_EDGE(1, 0, 0, 0, 205);
  69.                             UI::_SET_TEXT_ENTRY("STRING");
  70.                             UI::_ADD_TEXT_COMPONENT_STRING(text);
  71.                             UI::_DRAW_TEXT(x, y);
  72.                             // box
  73.                             GRAPHICS::DRAW_RECT(x + 0.027f, y + 0.043f, 0.058f, 0.056f, 75, 75, 75, 75);
  74.                         }
  75.                         //_peds.push_back(peds[i]);
  76.                     }
  77.                 }
  78.             }      
  79.         }
  80.     }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement