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.

212 lines
6.2 KiB

  1. // -----------------------------------------------------------------------------
  2. // Example Filterscript for the new Safe with Door
  3. // -----------------------------------------------
  4. // By Matite in January 2015
  5. //
  6. // v1.0.1
  7. // * Inital release in RC1
  8. //
  9. // v1.0.2
  10. // * Changed the Z offset in the MoveObject parameters to fix an issue with
  11. // movement caused by rounding on some PCs
  12. //
  13. // This script removes the existing safe in Madd Dogg's Mansion then creates the
  14. // new safe and door object in its place. You can then use commands to open and
  15. // close the safe door.
  16. //
  17. // You can use the following commands:
  18. // * /safe = Teleports the player to the safe in Madd Dogg's Mansion
  19. // * /openopen = Makes the safe door open
  20. // * /closesafe = Makes the safe door close
  21. //
  22. // Warning...
  23. // This script uses a total of 2 objects
  24. // -----------------------------------------------------------------------------
  25. // -----------------------------------------------------------------------------
  26. // Includes
  27. // --------
  28. // SA-MP include
  29. #include <a_samp>
  30. // ------------------------------------------------------------------------------
  31. // Defines
  32. // -------
  33. // Safe door status
  34. #define SAFE_DOOR_OPEN (1)
  35. #define SAFE_DOOR_CLOSED (0)
  36. // ------------------------------------------------------------------------------
  37. // Variables
  38. // ---------
  39. // Stores the created object number of the safe
  40. new SafeObject;
  41. // Stores the created object number of the safe door
  42. new SafeDoorObject;
  43. // Tracks the status of the safe door (ie whether it is open or closed)
  44. new SafeDoorStatus = SAFE_DOOR_CLOSED;
  45. // ------------------------------------------------------------------------------
  46. // Callbacks
  47. // ---------
  48. public OnPlayerCommandText(playerid, cmdtext[])
  49. {
  50. // Check command text
  51. if (strcmp("/safe", cmdtext, true, 5) == 0)
  52. {
  53. // Set the interior
  54. SetPlayerInterior(playerid, 5);
  55. // Set player position and facing angle
  56. SetPlayerPos(playerid, 1230.61, -808.15, 1084.1);
  57. SetPlayerFacingAngle(playerid, 0);
  58. // Fix camera position after teleporting
  59. SetCameraBehindPlayer(playerid);
  60. // Send a gametext message to the player
  61. GameTextForPlayer(playerid, "~b~~h~Safe And Door!", 3000, 3);
  62. // Exit here
  63. return 1;
  64. }
  65. else if (strcmp("/opensafe", cmdtext, true, 9) == 0)
  66. {
  67. // Check if the safe door is already open
  68. if (SafeDoorStatus == SAFE_DOOR_OPEN)
  69. {
  70. // Send a gametext message to the player and exit here
  71. GameTextForPlayer(playerid, "~r~~h~Safe Door~n~~r~~h~Already Open!", 3000, 3);
  72. return 1;
  73. }
  74. // Animate the safe door opening (the small Z offset is required)
  75. MoveObject(SafeDoorObject, 1230.225708, -806.648803, 1083.5 + 0.01, 0.005, 0, 0, 280);
  76. // Set the safe door status
  77. SafeDoorStatus = SAFE_DOOR_OPEN;
  78. // Send a gametext message to the player
  79. GameTextForPlayer(playerid, "~b~~h~Safe Door Opened!", 3000, 3);
  80. // Exit here
  81. return 1;
  82. }
  83. else if (strcmp("/closesafe", cmdtext, true, 10) == 0)
  84. {
  85. // Check if the safe door is already open
  86. if (SafeDoorStatus == SAFE_DOOR_CLOSED)
  87. {
  88. // Send a gametext message to the player and exit here
  89. GameTextForPlayer(playerid, "~r~~h~Safe Door~n~~r~~h~Already Closed!", 3000, 3);
  90. return 1;
  91. }
  92. // Animate the safe door closing (the small Z offset is required)
  93. MoveObject(SafeDoorObject, 1230.225708, -806.648803, 1083.5 - 0.01, 0.005, 0, 0, 0);
  94. // Set the safe door status
  95. SafeDoorStatus = SAFE_DOOR_CLOSED;
  96. // Send a gametext message to the player
  97. GameTextForPlayer(playerid, "~b~~h~Safe Door Closed!", 3000, 3);
  98. // Exit here
  99. return 1;
  100. }
  101. // Exit here (return 0 as the command was not handled in this filterscript)
  102. return 0;
  103. }
  104. public OnFilterScriptInit()
  105. {
  106. // Display information in the Server Console
  107. print("\n");
  108. print(" |---------------------------------------------------");
  109. print(" |--- Safe and Door Filterscript by Matite");
  110. print(" |-- Script v1.02");
  111. print(" |-- 13th February 2015");
  112. print(" |---------------------------------------------------");
  113. // Create the safe object
  114. SafeObject = CreateObject(19618, 1230.646118, -806.418823, 1083.5, 0, 0, 0);
  115. // Display information in the Server Console
  116. print(" |-- Safe object created");
  117. // Create the safe door object
  118. SafeDoorObject = CreateObject(19619, 1230.225708, -806.648803, 1083.5 - 0.01, 0, 0, 0);
  119. // Display information in the Server Console
  120. print(" |-- Safe door object created");
  121. print(" |---------------------------------------------------");
  122. // Loop
  123. for (new i = 0; i < MAX_PLAYERS; i++)
  124. {
  125. // Check if the player is connected and is not a NPC
  126. if (IsPlayerConnected(i) && !IsPlayerNPC(i))
  127. {
  128. // Remove default GTASA safe object in Madd Dogg's Mansion office
  129. // (we do this now incase the filterscipt was loaded after the player joined)
  130. RemoveBuildingForPlayer(i, 2332, 1230.646118, -806.418823, 1083.5, 10.0);
  131. }
  132. }
  133. // Exit here
  134. return 1;
  135. }
  136. public OnFilterScriptExit()
  137. {
  138. // Check for valid object
  139. if (IsValidObject(SafeObject))
  140. {
  141. // Destroy the safe object
  142. DestroyObject(SafeObject);
  143. // Display information in the Server Console
  144. print(" |---------------------------------------------------");
  145. print(" |-- Safe object destroyed");
  146. }
  147. // Check for valid object
  148. if (IsValidObject(SafeDoorObject))
  149. {
  150. // Destroy the safe door object
  151. DestroyObject(SafeDoorObject);
  152. // Display information in the Server Console
  153. print(" |-- Safe door object destroyed");
  154. }
  155. // Display information in the Server Console
  156. print(" |---------------------------------------------------");
  157. print(" |-- Safe and Door Filterscript Unloaded");
  158. print(" |---------------------------------------------------");
  159. // Exit here
  160. return 1;
  161. }
  162. public OnPlayerConnect(playerid)
  163. {
  164. // Remove default GTASA safe object in Madd Dogg's Mansion office
  165. RemoveBuildingForPlayer(playerid, 2332, 1230.646118, -806.418823, 1083.5, 10.0);
  166. // Exit here
  167. return 1;
  168. }