Guest User

a_zones GTA United

a guest
Feb 9th, 2014
1,340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.15 KB | None | 0 0
  1. /* SA:MP Functions
  2. *
  3. * ZONES Functions By ~Slayer101~
  4. * ZONES Functions Aided By Betamaster (locations), Mabako (locations), Simon (finetuning), and Cueball.
  5. *
  6. * (c) Copyright 2005-2014, SA:MP Team
  7. *
  8. */
  9.  
  10. #if defined _zones_included
  11. #endinput
  12. #endif
  13. #define _zones_included
  14. #pragma library samp
  15. #include <a_samp>
  16.  
  17. #define MAX_ZONE_NAME 28
  18.  
  19. //---------------------------------------------------------------------------------------------------
  20.  
  21. //NATIVES: KEEP THESE COMMENTED! THEY WILL STILL SHOW IN THE RIGHT HAND SIDE OF PAWN!
  22.  
  23. //native GetPlayer2DZone(playerid, zone[], len);
  24. //native GetPlayer3DZone(playerid, zone[], len);
  25. //native IsPlayerInZone(playerid, zone[]);
  26.  
  27. //---------------------------------------------------------------------------------------------------
  28.  
  29. //OUR MAJOR ARRAY: (GLOBAL)
  30.  
  31. enum SAZONE_MAIN { //Betamaster
  32. SAZONE_NAME[28],
  33. Float:SAZONE_AREA[6]
  34. };
  35.  
  36. static const gSAZones[][SAZONE_MAIN] = { // Majority of names and area coordinates adopted from Mabako's 'Zones Script' v0.2
  37. // NAME AREA (Xmin,Ymin,Zmin,Xmax,Ymax,Zmax)
  38.  
  39. // LC-Zones:
  40. {"Francis Intl. Airport", {-2310.71, 990.272, 0.0, -2023.55, 1402.69, 155.802}},
  41. {"Francis Intl. Airport", {-2976.69, 776.426, 0.0, -2316.82, 1448.51, 244.396}},
  42. {"Francis Intl. Airport", {-2982.97, 455.29, -45.9404, -1818.63, 1531.56, 254.696}},
  43. {"Cochrane Dam", {-2744.5, 1893.44, -46.7412, -2217.52, 2504.54, 253.344}},
  44. {"Chinatown", {-604.579, 891.711, -21.203, -284.58, 1336.31, 191.101}},
  45. {"Newport", {-1149.89, 740.81, -0.000144958, -734.893, 1387.81, 198.864}},
  46. {"Fort Staunton", {-1110.12, 1388.38, 7.62939e-005, -735.678, 1738.38, 173.897}},
  47. {"Portland Beach", {39.37, 1186.53, -29.883, 447.6, 1999.63, 120.117}},
  48. {"Harwood", {-604.021, 1721.82, -48.5832, 38.98, 2122.68, 101.417}},
  49. {"Shoreside Lift Bridge", {-1909.72, 1128.27, 0.213943, -1348.6, 1210.21, 173.004}},
  50. {"Rockford", {-1232.76, 1738.89, -17.071, -734.764, 2068.89, 83.754}},
  51. {"Saint Mark's", {-284.1, 1287.68, -14.296, 38.9, 1721.68, 135.704}},
  52. {"Belleville Park", {-1471.57, 796.93, -46.7463, -1150.73, 1386.93, 224.163}},
  53. {"Portland Harbor", {13.6801, 730.35, -18.8643, 465.68, 1186.35, 131.136}},
  54. {"Trenton", {-284.12, 730.15, 1.49868, 13.38, 1057.95, 151.499}},
  55. {"Portland View", {-284.508, 1058.91, -5.78586, 38.4922, 1286.91, 126.214}},
  56. {"Atlantic Quays", {-284.12, 548.45, -13.5049, 151.88, 730.07, 136.495}},
  57. {"Callahan Point", {-598.32, 621.78, -13.8723, -284.32, 841.275, 136.128}},
  58. {"Wichita Gardens", {-2161.83, 1531.93, -45.8745, -1721.04, 1892.73, 254.241}},
  59. {"Red Light District", {-604.622, 1336.38, -22.6676, -284.62, 1517.38, 147.332}},
  60. {"Callahan Bridge", {-732.558, 841.653, 6.26081, -284.56, 891.653, 206.261}},
  61. {"Callahan Bridge", {-905.232, 841.702, 30.7441, -735.122, 891.702, 180.744}},
  62. {"Bedford Point", {-1574.44, 127.95, -61.3183, -1150.44, 795.55, 432.352}},
  63. {"Aspatria", {-1575.76, 1387.4, -8.01086e-005, -1233.76, 1960.5, 120.271}},
  64. {"Pike Creek", {-2757.57, 1532.03, -49.6792, -2162.31, 1892.76, 250.437}},
  65. {"Cedar Grove", {-2217.23, 1893.39, -50.1134, -1616.91, 2450.06, 250.426}},
  66. {"Hepburn Heights", {-604.579, 1517.6, -13.4117, -284.58, 1721.23, 136.588}},
  67. {"Liberty Campus", {-1232.73, 1388.38, 0.000190735, -1110.73, 1738.38, 166.36}},
  68. {"Torrington", {-1150.23, 127.58, -61.7588, -772.234, 740.07, 473.656}},
  69.  
  70. // VC-Zones:
  71. {"Leaf Links", {1786.27, -1191.43, 0.0, 2163.66, -152.395, 300.0}},
  72. {"Escobar International", {92.1001, -1895.2, 0.0, 792.1, -1265.2, 300.0}},
  73. {"Escobar International", {77.7263, -2752.63, 0.0, 792.246, -1895.2, 300.0}},
  74. {"National Guard Base", {112.466, -1265.46, 0.0, 792.466, -905.464, 300.0}},
  75. {"Ocean Beach", {1746.79, -2948.1, 0.0, 3254.9, -1848.1, 300.0}},
  76. {"Washington Beach", {1895.18, -1849.14, 0.0, 3245.18, -1191.14, 300.0}},
  77. {"Starfish Island", {1251.79, -1671.72, 0.0, 1895.49, -1191.72, 300.0}},
  78. {"Viceport", {791.79, -2729.61, 0.0, 1746.79, -1848.74, 300.0}},
  79. {"Washington Mall", {1926.84, -1984.67, 0.0, 2051.84, -1859.67, 100.0}},
  80. {"Prawn Island", {1786.27, -152.395, 0.0, 2163.66, 293.47, 300.0}},
  81. {"Little Haiti", {791.79, -1191.47, 0.0, 1421.71, -537.34, 300.0}},
  82. {"Little Havana", {791.79, -1848.74, 0.0, 1251.79, -1191.47, 300.0}},
  83. {"Junk Yard", {640.441, -992.911, 0.0, 792.441, -719.61, 250.0}},
  84. {"Terminal", {423.404, -1892.41, 0.0, 723.404, -1705.41, 250.0}},
  85. {"Vice Point", {2163.66, -1190.35, 0.0, 3246.03, 439.646, 300.0}},
  86. {"Vice City Downtown", {386.97, -536.872, 0.0, 1786.27, 727.32, 300.0}},
  87. {"Hyman Memorial Stadium", {413.973, 189.007, 0.0, 1062.48, 643.753, 290.0}},
  88. // SHOP2", {2324.31, 27.1423, 0.0, 2484.31, 327.142, 250.0}}, VCMALL2 #North Point Mall // The mall is interior now, so this is also Vice Point
  89. {"Vice Point", {2324.31, 27.1423, 0.0, 2484.31, 327.142, 250.0}},
  90. {"VCBRID", {1421.38, -1191.47, 0.0, 1783.81, -537.34, 300.0}},
  91.  
  92. {"Liberty City", {-3000.0, 0.0, -100.0, 400.0, 3000.0, 800.0}},
  93. {"Liberty City", {400.0, 2300.0, -100.0, 700.0, 3000.0, 800.0}},
  94. {"Vice City", {400.0, -3000.0, -100.0, 3000.0, 700.0, 800.0}},
  95. {"Vice City", {100.0, -3000.0, -100.0, 400.0, -800.0, 800.0}},
  96.  
  97. // LC-Islands:
  98. {"Staunton Island", {-1615.48, 80.03, -114.769, -734.48, 2167.26, 485.231}},
  99. {"Portland", {-732.849, 470.28, -117.535, 552.66, 2234.11, 482.465}},
  100. {"Shoreside Vale", {-2994.64, 448.62, -117.0, -1616.9, 3006.35, 483.0}},
  101. {"Shoreside Vale", {-1615.44, 1961.11, -41.7094, -1471.29, 2167.04, 358.291}},
  102. {"Shoreside Vale", {-1615.43, 1879.09, -45.8201, -1576.33, 1961.06, 354.18}}
  103.  
  104. };
  105.  
  106. //---------------------------------------------------------------------------------------------------
  107.  
  108. /* GetPlayer2DZone(playerid, zone[], len)
  109. * @Info: Used to retrieve the players zone/area name. DOES NOT COMPARE HEIGHTS!
  110. *
  111. * @params: playerid - The id of the player whose zone you will retrieve.
  112. * @params: zone[] - The string with which the zone name will be formatted into.
  113. * @params: len - The maximum length you wish to format the zone name into. RECOMMENDED 28!
  114. */
  115.  
  116. stock GetPlayer2DZone(playerid, zone[], len) //Credits to Cueball, Betamaster, Mabako, and Simon (for finetuning).
  117. {
  118. new Float:x, Float:y, Float:z;
  119. GetPlayerPos(playerid, x, y, z);
  120. for(new i = 0; i != sizeof(gSAZones); i++ )
  121. {
  122. if(x >= gSAZones[i][SAZONE_AREA][0] && x <= gSAZones[i][SAZONE_AREA][3] && y >= gSAZones[i][SAZONE_AREA][1] && y <= gSAZones[i][SAZONE_AREA][4])
  123. {
  124. return format(zone, len, gSAZones[i][SAZONE_NAME], 0);
  125. }
  126. }
  127. return 0;
  128. }
  129.  
  130. //---------------------------------------------------------------------------------------------------
  131.  
  132. /* GetPlayer3DZone(playerid, zone[], len)
  133. * @Info: Used to retrieve the players zone/area name and comparing with heights.
  134. *
  135. * @params: playerid - The id of the player whose zone you will retrieve.
  136. * @params: zone[] - The string with which the zone name will be formatted into.
  137. * @params: len - The maximum length you wish to format the zone name into. RECOMMENDED 28!
  138. */
  139.  
  140. stock GetPlayer3DZone(playerid, zone[], len) //Credits to Cueball, Betamaster, Mabako, and Simon (for finetuning).
  141. {
  142. new Float:x, Float:y, Float:z;
  143. GetPlayerPos(playerid, x, y, z);
  144. for(new i = 0; i != sizeof(gSAZones); i++ )
  145. {
  146. if(x >= gSAZones[i][SAZONE_AREA][0] && x <= gSAZones[i][SAZONE_AREA][3] && y >= gSAZones[i][SAZONE_AREA][1] && y <= gSAZones[i][SAZONE_AREA][4] && z >= gSAZones[i][SAZONE_AREA][2] && z <= gSAZones[i][SAZONE_AREA][5])
  147. {
  148. return format(zone, len, gSAZones[i][SAZONE_NAME], 0);
  149. }
  150. }
  151. return 0;
  152. }
  153.  
  154. //---------------------------------------------------------------------------------------------------
  155.  
  156. /* IsPlayerInZone(playerid, zone[])
  157. * @Info: Used to check if the player is inside the zone[] parameter.
  158. *
  159. * @params: playerid - The id of the player whose zone you will check.
  160. * @params: zone[] - The string with which we will compare the players zone name to.
  161. */
  162.  
  163. stock IsPlayerInZone(playerid, zone[]) //Credits to Cueball, Betamaster, Mabako, and Simon (for finetuning).
  164. {
  165. new TmpZone[MAX_ZONE_NAME];
  166. GetPlayer3DZone(playerid, TmpZone, sizeof(TmpZone));
  167. for(new i = 0; i != sizeof(gSAZones); i++)
  168. {
  169. if(strfind(TmpZone, zone, true) != -1)
  170. return 1;
  171. }
  172. return 0;
  173. }
Advertisement
Add Comment
Please, Sign In to add comment