Advertisement
HolywoodJack

GetCurrentZoneID(CPed *playa)

Jan 8th, 2021
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. static int GetCurrZoneID(CPed *playa2) {
  2. unsigned int zone1 = CTheZones::m_CurrLevel;
  3. auto zoneName1 = CTheZones::FindSmallestZoneForPosition(playa2->GetPosition(), true);
  4. if (playa2->m_pEnex) {
  5. CEntryExit *playaEnex = reinterpret_cast<CEntryExit *>(playa2->m_pEnex);
  6. CVector playaEnexPos = playaEnex->m_vecExitPos;
  7. zoneName1 = CTheZones::FindSmallestZoneForPosition(playaEnexPos, true);
  8. if (PointWithinRectangle(playaEnexPos, -728.85f, 1249.78f, 855.36f, 2901.67f)) {
  9. zone1 = THE_DESERT;
  10. } else {
  11. if (PointWithinRectangle(playaEnexPos, 3000.0f, -200.0f, 8500.0f, 3500.0f)) { // LC
  12. zone1 = LIBERTY_CITY;
  13. } else {
  14. if (PointWithinRectangle(playaEnexPos, 3000.0f, -4500.0f, 8500.0f, -200.0f)) { // VC
  15. zone1 = VICE_CITY;
  16. }
  17. }
  18. }
  19. }
  20. std::string zoneName1Txt = zoneName1->m_szTextKey;
  21. auto playa3 = playa2;
  22. // CMessages::AddMessage(zoneName1->m_szTextKey, -1, true, true);
  23. if (zoneName1Txt == "BONE" || zoneName1Txt == "SUNMA" || zoneName1Txt == "SUNNN" || zoneName1Txt == "BIGE" ||
  24. zoneName1Txt == "ELQUE" || zoneName1Txt == "BARRA" || zoneName1Txt == "CARSO" || zoneName1Txt == "PAYAS" ||
  25. zoneName1Txt == "PROBE" || zoneName1Txt == "ELCA" || zoneName1Txt == "ARCO" || zoneName1Txt == "VALLE" ||
  26. zoneName1Txt == "ROBINT" || zoneName1Txt == "TOM" || zoneName1Txt == "ALDEA" || zoneName1Txt == "BRUJA" ||
  27. zoneName1Txt == "ROBAD" || zoneName1Txt == "QUARY" || zoneName1Txt == "OCTAN" || zoneName1Txt == "PALMS" ||
  28. zoneName1Txt == "DAM" || zoneName1Txt == "MEAD" || zoneName1Txt == "REST" || zoneName1Txt == "BYTUN" ||
  29. playa3->IsWithinArea(-728.85f, 1249.78f, 855.36f, 2901.67f)) {
  30. zone1 = THE_DESERT;
  31. }
  32.  
  33. if (playa3->IsWithinArea(3000.0f, -200.0f, 8500.0f, 3500.0f)) {
  34. zone1 = LIBERTY_CITY;
  35. } else {
  36. if (playa3->IsWithinArea(3000.0f, -4500.0f, 8500.0f, -200.0f)) {
  37. zone1 = VICE_CITY;
  38. }
  39. }
  40. // PointWithinRectangle(playaEnexPos, -728.85f, 1249.78f, 855.36f, 2901.67f);
  41. return zone1;
  42. }
  43.  
  44. static bool PointWithinRectangle(CVector pointA, float leftCornerX, float leftCornerY, float rightCornerX, float rightCornerY) {
  45. if (pointA.x > leftCornerX && pointA.x < rightCornerX && pointA.y > leftCornerY && pointA.y < rightCornerY) {
  46. return true;
  47. } else {
  48. return false;
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement