SAMP Gitlab CI Test
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

422 lines
15 KiB

  1. // -----------------------------------------------------------------------------
  2. // Example Filterscript for the Area 51 (69) Base Objects
  3. // ------------------------------------------------------
  4. // By Matite in March 2015
  5. //
  6. //
  7. // This script removes the existing GTASA Area 51 (69) land section, fence and
  8. // buildings. It then replaces the land section and buildings with the new
  9. // enterable versions. It also replaces the perimeter fence and adds two
  10. // gates that can be opened or closed.
  11. //
  12. // Warning...
  13. // This script uses a total of:
  14. // * 11 objects = 1 for the replacement land object, 7 for the replacement
  15. // building objects, 1 for the outer fence and 2 for the gates
  16. // * Enables the /a51 command to teleport the player to the Area 51 (69) Base
  17. // * 2 3D Text Labels = 1 on each gate
  18. // -----------------------------------------------------------------------------
  19. // -----------------------------------------------------------------------------
  20. // -----------------------------------------------------------------------------
  21. // Includes
  22. // --------
  23. // SA-MP include
  24. #include <a_samp>
  25. // For PlaySoundForPlayersInRange()
  26. #include "../include/gl_common.inc"
  27. // -----------------------------------------------------------------------------
  28. // Defines
  29. // -------
  30. // Used for messages sent to the player
  31. #define COLOR_MESSAGE_YELLOW 0xFFDD00AA
  32. // Used for the northern and eastern A51 (69) gates status flags
  33. #define GATES_CLOSED 0
  34. #define GATES_CLOSING 1
  35. #define GATES_OPEN 2
  36. #define GATES_OPENING 3
  37. // -----------------------------------------------------------------------------
  38. // Constants
  39. // ---------
  40. // Gate names for the 3D text labels
  41. static GateNames[2][] =
  42. {
  43. "Northern Gate",
  44. "Eastern Gate"
  45. };
  46. // -----------------------------------------------------------------------------
  47. // Variables
  48. // ---------
  49. // Stores the created object numbers of the replacement Area 51 (69) land object,
  50. // buildings and fence so they can be destroyed when the filterscript is unloaded
  51. new A51LandObject; // Land object
  52. new A51Buildings[7]; // Building object
  53. new A51Fence; // Fence
  54. new A51NorthernGate; // Northern Gate
  55. new A51EasternGate; // Eastern Gate
  56. // Stores a reference to the 3D text labels used on each set of gates so they
  57. // can be destroyed when the filterscript is unloaded
  58. new Text3D:LabelGates[2];
  59. // Stores the current status of the northern gate
  60. new NorthernGateStatus = GATES_CLOSED;
  61. // Stores the current status of the eastern gate
  62. new EasternGateStatus = GATES_CLOSED;
  63. // -----------------------------------------------------------------------------
  64. // Callbacks
  65. // ---------
  66. public OnPlayerCommandText(playerid, cmdtext[])
  67. {
  68. // Check command text
  69. if (strcmp("/a51", cmdtext, true, 4) == 0)
  70. {
  71. // Set the interior (outside)
  72. SetPlayerInterior(playerid, 0);
  73. // Set player position and facing angle (outside the northern gate)
  74. SetPlayerPos(playerid, 135.20, 1948.51, 19.74);
  75. SetPlayerFacingAngle(playerid, 180);
  76. // Fix camera position after teleporting
  77. SetCameraBehindPlayer(playerid);
  78. // Send a gametext message to the player
  79. GameTextForPlayer(playerid, "~b~~h~Area 51 (69) Base!", 3000, 3);
  80. // Exit here
  81. return 1;
  82. }
  83. // Exit here (return 0 as the command was not handled in this filterscript)
  84. return 0;
  85. }
  86. public OnFilterScriptInit()
  87. {
  88. // Display information in the Server Console
  89. print("\n");
  90. print(" |---------------------------------------------------");
  91. print(" |--- Area 51 (69) Building Objects Filterscript");
  92. print(" |-- Script v1.01");
  93. print(" |-- 28th March 2015");
  94. print(" |---------------------------------------------------");
  95. // Create the A51 Land object
  96. A51LandObject = CreateObject(11692, 199.344, 1943.79, 18.2031, 0, 0, 0);
  97. // Display information in the Server Console
  98. print(" |-- Area 51 (69) Land object created");
  99. // Create the A51 Fence object
  100. A51Fence = CreateObject(19312, 191.141, 1870.04, 21.4766, 0, 0, 0);
  101. // Display information in the Server Console
  102. print(" |-- Area 51 (69) Fence object created");
  103. // Create the A51 Building objects
  104. A51Buildings[0] = CreateObject(19905, 206.798950, 1931.643432, 16.450595, 0, 0, 0);
  105. A51Buildings[1] = CreateObject(19905, 188.208908, 1835.033569, 16.450595, 0, 0, 0);
  106. A51Buildings[2] = CreateObject(19905, 230.378875, 1835.033569, 16.450595, 0, 0, 0);
  107. A51Buildings[3] = CreateObject(19907, 142.013977, 1902.538085, 17.633581, 0, 0, 270.0);
  108. A51Buildings[4] = CreateObject(19907, 146.854003, 1846.008056, 16.533580, 0, 0, 0);
  109. A51Buildings[5] = CreateObject(19909, 137.900390, 1875.024291, 16.836734, 0, 0, 270.0);
  110. A51Buildings[6] = CreateObject(19909, 118.170387, 1875.184326, 16.846735, 0, 0, 0);
  111. // Display information in the Server Console
  112. print(" |-- Area 51 (69) Building objects created");
  113. // Create the Northern gate object
  114. A51NorthernGate = CreateObject(19313, 134.545074, 1941.527709, 21.691408, 0, 0, 180.0);
  115. // Create the Eastern gate object
  116. A51EasternGate = CreateObject(19313, 286.008666, 1822.744628, 20.010623, 0, 0, 90.0);
  117. // Display information in the Server Console
  118. print(" |-- Area 51 (69) Gate objects created");
  119. // Create variable
  120. new string[192];
  121. // Create 3D Text Label at the prisons eastern gates
  122. format(string, sizeof(string), "{CCCCCC}[%s]\n{CCCCCC}Press '{FFFFFF}~k~~CONVERSATION_YES~{CCCCCC}' to open or close the gate", GateNames[0]);
  123. LabelGates[0] = Create3DTextLabel(string, 0xCCCCCCAA, 135.09, 1942.37, 19.82, 10.5, 0, 0);
  124. // Create 3D Text Label at the prisons eastern gates
  125. format(string, sizeof(string), "{CCCCCC}[%s]\n{CCCCCC}Press '{FFFFFF}~k~~CONVERSATION_YES~{CCCCCC}' to open or close the gate", GateNames[1]);
  126. LabelGates[1] = Create3DTextLabel(string, 0xCCCCCCAA, 287.12, 1821.51, 18.14, 10.5, 0, 0);
  127. // Display information in the Server Console
  128. print(" |-- Area 51 (69) Gates 3D Text Labels created");
  129. print(" |---------------------------------------------------");
  130. // Loop
  131. for (new i = 0; i < MAX_PLAYERS; i++)
  132. {
  133. // Check if the player is connected and not a NPC
  134. if (IsPlayerConnected(i) && !IsPlayerNPC(i))
  135. {
  136. // Remove default GTASA Area 51 (69) land and buildings for the player
  137. // (so any player currently ingame does not have to rejoin for them to
  138. // be removed when this filterscript is loaded)
  139. RemoveBuildingForPlayer(i, 16203, 199.344, 1943.79, 18.2031, 250.0); // Land
  140. RemoveBuildingForPlayer(i, 16590, 199.344, 1943.79, 18.2031, 250.0); // Land LOD
  141. RemoveBuildingForPlayer(i, 16323, 199.336, 1943.88, 18.2031, 250.0); // Buildings
  142. RemoveBuildingForPlayer(i, 16619, 199.336, 1943.88, 18.2031, 250.0); // Buildings LOD
  143. RemoveBuildingForPlayer(i, 1697, 228.797, 1835.34, 23.2344, 250.0); // Solar Panels (they poke through the roof inside)
  144. RemoveBuildingForPlayer(i, 16094, 191.141, 1870.04, 21.4766, 250.0); // Outer Fence
  145. }
  146. }
  147. // Exit here
  148. return 1;
  149. }
  150. public OnFilterScriptExit()
  151. {
  152. // Check for valid object
  153. if (IsValidObject(A51LandObject))
  154. {
  155. // Destroy the A51 land object
  156. DestroyObject(A51LandObject);
  157. // Display information in the Server Console
  158. print(" |---------------------------------------------------");
  159. print(" |-- Area 51 (69) Land object destroyed");
  160. }
  161. // Check for valid object
  162. if (IsValidObject(A51Fence))
  163. {
  164. // Destroy the A51 fence object
  165. DestroyObject(A51Fence);
  166. // Display information in the Server Console
  167. print(" |-- Area 51 (69) Fence object destroyed");
  168. }
  169. // Check for valid object
  170. if (IsValidObject(A51NorthernGate))
  171. {
  172. // Destroy the A51 northern gate object
  173. DestroyObject(A51NorthernGate);
  174. // Display information in the Server Console
  175. print(" |-- Area 51 (69) Northern Gate object destroyed");
  176. }
  177. // Check for valid object
  178. if (IsValidObject(A51EasternGate))
  179. {
  180. // Destroy the A51 eastern gate object
  181. DestroyObject(A51EasternGate);
  182. // Display information in the Server Console
  183. print(" |-- Area 51 (69) Eastern Gate object destroyed");
  184. }
  185. // Loop
  186. for (new i = 0; i < sizeof(A51Buildings); i++)
  187. {
  188. // Check for valid object
  189. if (IsValidObject(A51Buildings[i]))
  190. {
  191. // Destroy the A51 building object
  192. DestroyObject(A51Buildings[i]);
  193. // Display information in the Server Console
  194. printf(" |-- Area 51 (69) Building object %d destroyed", i + 1);
  195. }
  196. }
  197. // Destroy 3D Text Labels on the northern and eastern gates
  198. Delete3DTextLabel(LabelGates[0]);
  199. Delete3DTextLabel(LabelGates[1]);
  200. // Display information in the Server Console
  201. print(" |-- Deleted the 3D Text Labels on the Area 51 (69) Gates");
  202. // Display information in the Server Console
  203. print(" |---------------------------------------------------");
  204. print(" |-- Area 51 (69) Base Objects Filterscript Unloaded");
  205. print(" |---------------------------------------------------");
  206. // Exit here
  207. return 1;
  208. }
  209. public OnPlayerConnect(playerid)
  210. {
  211. // Remove default GTASA Area 51 (69) land and buildings for the player
  212. RemoveBuildingForPlayer(playerid, 16203, 199.344, 1943.79, 18.2031, 250.0); // Land
  213. RemoveBuildingForPlayer(playerid, 16590, 199.344, 1943.79, 18.2031, 250.0); // Land LOD
  214. RemoveBuildingForPlayer(playerid, 16323, 199.336, 1943.88, 18.2031, 250.0); // Buildings
  215. RemoveBuildingForPlayer(playerid, 16619, 199.336, 1943.88, 18.2031, 250.0); // Buildings LOD
  216. RemoveBuildingForPlayer(playerid, 1697, 228.797, 1835.34, 23.2344, 250.0); // Solar Panels (they poke through the roof inside)
  217. RemoveBuildingForPlayer(playerid, 16094, 191.141, 1870.04, 21.4766, 250.0); // Outer Fence
  218. // Exit here (return 1 so this callback is handled in other scripts too)
  219. return 1;
  220. }
  221. public OnObjectMoved(objectid)
  222. {
  223. // Check if the object that moved was the northern gate
  224. if (objectid == A51NorthernGate)
  225. {
  226. // Check if the northern gate was closing
  227. if (NorthernGateStatus == GATES_CLOSING)
  228. {
  229. // Set status flag for northern gates
  230. NorthernGateStatus = GATES_CLOSED;
  231. }
  232. else
  233. {
  234. // Set status flag for northern gates
  235. NorthernGateStatus = GATES_OPEN;
  236. }
  237. }
  238. // Check if the object that moved was the eastern gate
  239. else if (objectid == A51EasternGate)
  240. {
  241. // Check if the eastern gate was closing
  242. if (EasternGateStatus == GATES_CLOSING)
  243. {
  244. // Set status flag for eastern gate
  245. EasternGateStatus = GATES_CLOSED;
  246. }
  247. else
  248. {
  249. // Set status flag for eastern gate
  250. EasternGateStatus = GATES_OPEN;
  251. }
  252. }
  253. // Exit here
  254. return 1;
  255. }
  256. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  257. {
  258. // Check if the player pressed the conversation yes key (normally the Y key)
  259. if (newkeys & KEY_YES)
  260. {
  261. // Check if the player is near the eastern A51 gate
  262. if (IsPlayerInRangeOfPoint(playerid, 10.0, 287.12, 1821.51, 18.14))
  263. {
  264. // Debug
  265. //printf("-->Player ID %d within 10m of the Eastern A51 Gate", playerid);
  266. // Check if the eastern gate is currently opening (ie moving)
  267. if (EasternGateStatus == GATES_OPENING)
  268. {
  269. // Send chat text message and exit here
  270. SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Sorry, you must wait for the eastern gate to fully open first.");
  271. return 1;
  272. }
  273. // Check if the eastern gate is currently closing (ie moving)
  274. else if (EasternGateStatus == GATES_CLOSING)
  275. {
  276. // Send chat text message and exit here
  277. SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Sorry, you must wait for the eastern gate to fully close first.");
  278. return 1;
  279. }
  280. // Play gate opening sound
  281. PlaySoundForPlayersInRange(1035, 50.0, 287.12, 1821.51, 18.14);
  282. // Check if the eastern gate is currently closed
  283. if (EasternGateStatus == GATES_CLOSED)
  284. {
  285. // Send a gametext message to the player
  286. GameTextForPlayer(playerid, "~b~~h~Eastern Gate Opening!", 3000, 3);
  287. // Animate the eastern gate opening
  288. MoveObject(A51EasternGate, 286.008666, 1833.744628, 20.010623, 1.1, 0, 0, 90);
  289. // Set status flag for eastern gate
  290. EasternGateStatus = GATES_OPENING;
  291. }
  292. else
  293. {
  294. // Send a gametext message to the player
  295. GameTextForPlayer(playerid, "~b~~h~Eastern Gate Closing!", 3000, 3);
  296. // Animate the eastern gates closing
  297. MoveObject(A51EasternGate, 286.008666, 1822.744628, 20.010623, 1.1, 0, 0, 90);
  298. // Set status flag for eastern gate
  299. EasternGateStatus = GATES_CLOSING;
  300. }
  301. }
  302. // Check if the player is near the northern A51 gate
  303. else if (IsPlayerInRangeOfPoint(playerid, 10.0, 135.09, 1942.37, 19.82))
  304. {
  305. // Debug
  306. //printf("-->Player ID %d within 10m of the Northern A51 Gate", playerid);
  307. // Check if the northern gate is currently opening (ie moving)
  308. if (NorthernGateStatus == GATES_OPENING)
  309. {
  310. // Send chat text message and exit here
  311. SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Sorry, you must wait for the northern gate to fully open first.");
  312. return 1;
  313. }
  314. // Check if the northern gates is currently closing (ie moving)
  315. else if (NorthernGateStatus == GATES_CLOSING)
  316. {
  317. // Send chat text message and exit here
  318. SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Sorry, you must wait for the northern gate to fully close first.");
  319. return 1;
  320. }
  321. // Play gate opening sound
  322. PlaySoundForPlayersInRange(1035, 50.0, 135.09, 1942.37, 19.82);
  323. // Check if the northern gate is currently closed
  324. if (NorthernGateStatus == GATES_CLOSED)
  325. {
  326. // Send a gametext message to the player
  327. GameTextForPlayer(playerid, "~b~~h~Northern Gate Opening!", 3000, 3);
  328. // Animate the northern gates opening
  329. MoveObject(A51NorthernGate, 121.545074, 1941.527709, 21.691408, 1.3, 0, 0, 180);
  330. // Set status flag for northern gates
  331. NorthernGateStatus = GATES_OPENING;
  332. }
  333. else
  334. {
  335. // Send a gametext message to the player
  336. GameTextForPlayer(playerid, "~b~~h~Northern Gate Closing!", 3000, 3);
  337. // Animate the northern gates closing
  338. MoveObject(A51NorthernGate, 134.545074, 1941.527709, 21.691408, 1.3, 0, 0, 180);
  339. // Set status flag for northern gates
  340. NorthernGateStatus = GATES_CLOSING;
  341. }
  342. }
  343. }
  344. // Exit here (return 1 so this callback is handled in other scripts too)
  345. return 1;
  346. }