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.

664 lines
20 KiB

  1. // -----------------------------------------------------------------------------
  2. // Example Filterscript for the new SF ZomboTech Building and Lab with Elevator
  3. // ----------------------------------------------------------------------------
  4. // Original elevator code by Zamaroht in 2010
  5. //
  6. // Updated by Kye in 2011
  7. // * Added a sound effect for the elevator starting/stopping
  8. //
  9. // Edited by Matite in January 2015
  10. // * Added code to remove the existing building, add the new buildings and
  11. // adapted the elevator code so it works in this new building
  12. //
  13. //
  14. // This script creates the new SF ZomboTech building and the lab objects, removes
  15. // the existing GTASA building object and creates an elevator that can be used to
  16. // travel between the building foyer and the lab.
  17. //
  18. // You can un-comment the OnPlayerCommandText callback below to enable a simple
  19. // teleport command (/zl) that teleports you to the ZomboTech Lab elevator.
  20. //
  21. // Warning...
  22. // This script uses a total of:
  23. // * 9 objects = 1 for the elevator, 2 for the elevator doors, 4 for the elevator
  24. // floor doors and 2 for the buildings (replacement ZomboTech building and lab)
  25. // * 3 3D Text Labels = 2 on the floors and 1 in the elevator
  26. // * 1 dialog (for the elevator)
  27. // -----------------------------------------------------------------------------
  28. // -----------------------------------------------------------------------------
  29. // -----------------------------------------------------------------------------
  30. // Includes
  31. // --------
  32. // SA-MP include
  33. #include <a_samp>
  34. // For PlaySoundForPlayersInRange()
  35. #include "../include/gl_common.inc"
  36. // -----------------------------------------------------------------------------
  37. // Defines
  38. // -------
  39. // Movement speed of the elevator
  40. #define ELEVATOR_SPEED (5.0)
  41. // Movement speed of the doors
  42. #define DOORS_SPEED (5.0)
  43. // Time in ms that the elevator will wait in each floor before continuing with the queue...
  44. // be sure to give enough time for doors to open
  45. #define ELEVATOR_WAIT_TIME (5000)
  46. // Dialog ID for the ZomboTech building elevator dialog
  47. #define DIALOG_ID (875)
  48. // Position defines
  49. #define X_DOOR_CLOSED (-1951.603027)
  50. #define X_DOOR_L_OPENED X_DOOR_CLOSED + 1.6
  51. #define X_DOOR_R_OPENED X_DOOR_CLOSED - 1.6
  52. #define GROUND_Z_COORD (47.451492)
  53. #define X_ELEVATOR_POS (-1951.603027)
  54. #define Y_ELEVATOR_POS (636.418334)
  55. // Elevator state defines
  56. #define ELEVATOR_STATE_IDLE (0)
  57. #define ELEVATOR_STATE_WAITING (1)
  58. #define ELEVATOR_STATE_MOVING (2)
  59. // Invalid floor define
  60. #define INVALID_FLOOR (-1)
  61. // -----------------------------------------------------------------------------
  62. // Constants
  63. // ---------
  64. // Elevator floor names for the 3D text labels
  65. static FloorNames[2][] =
  66. {
  67. "Ground Floor",
  68. "ZomboTech Lab"
  69. };
  70. // Elevator floor Z heights
  71. static Float:FloorZOffsets[2] =
  72. {
  73. 0.0, // Ground Floor
  74. -21.628007 // ZomboTech Lab -21.598007
  75. };
  76. // -----------------------------------------------------------------------------
  77. // Variables
  78. // ---------
  79. // Stores the created object numbers of the replacement building and the lab so
  80. // they can be destroyed when the filterscript is unloaded
  81. new SFZomboTechBuildingObject;
  82. new SFZomboTechLabObject;
  83. // Stores the created object numbers of the elevator, the elevator doors and
  84. // the elevator floor doors so they can be destroyed when the filterscript
  85. // is unloaded
  86. new Obj_Elevator, Obj_ElevatorDoors[2], Obj_FloorDoors[2][2];
  87. // Stores a reference to the 3D text labels used on each floor and inside the
  88. // elevator itself so they can be detroyed when the filterscript is unloaded
  89. new Text3D:Label_Elevator, Text3D:Label_Floors[2];
  90. // Stores the current state of the elevator (ie ELEVATOR_STATE_IDLE,
  91. // ELEVATOR_STATE_WAITING or ELEVATOR_STATE_MOVING)
  92. new ElevatorState;
  93. // Stores the current floor the elevator is on or heading to... if the value is
  94. // ELEVATOR_STATE_IDLE or ELEVATOR_STATE_WAITING this is the current floor. If
  95. // the value is ELEVATOR_STATE_MOVING then it is the floor it's moving to
  96. new ElevatorFloor;
  97. // Stores the elevator queue for each floor
  98. new ElevatorQueue[2];
  99. // Stores who requested the floor for the elevator queue...
  100. // FloorRequestedBy[floor_id] = playerid; (stores who requested which floor)
  101. new FloorRequestedBy[2];
  102. // Used for a timer that makes the elevator move faster after players start
  103. // surfing the object
  104. new ElevatorBoostTimer;
  105. // -----------------------------------------------------------------------------
  106. // Function Forwards
  107. // -----------------
  108. // Public:
  109. forward CallElevator(playerid, floorid); // You can use INVALID_PLAYER_ID too.
  110. forward ShowElevatorDialog(playerid);
  111. // Private:
  112. forward Elevator_Initialize();
  113. forward Elevator_Destroy();
  114. forward Elevator_OpenDoors();
  115. forward Elevator_CloseDoors();
  116. forward Floor_OpenDoors(floorid);
  117. forward Floor_CloseDoors(floorid);
  118. forward Elevator_MoveToFloor(floorid);
  119. forward Elevator_Boost(floorid); // Increases the elevator speed until it reaches 'floorid'.
  120. forward Elevator_TurnToIdle();
  121. forward ReadNextFloorInQueue();
  122. forward RemoveFirstQueueFloor();
  123. forward AddFloorToQueue(floorid);
  124. forward IsFloorInQueue(floorid);
  125. forward ResetElevatorQueue();
  126. forward DidPlayerRequestElevator(playerid);
  127. forward Float:GetElevatorZCoordForFloor(floorid);
  128. forward Float:GetDoorsZCoordForFloor(floorid);
  129. // -----------------------------------------------------------------------------
  130. // Callbacks
  131. // ---------
  132. // Un-comment the OnPlayerCommandText callback below (remove the "/*" and the "*/")
  133. // to enable a simple teleport command (/zl) which teleports the player to
  134. // the Zombotech Lab elevator.
  135. /*
  136. public OnPlayerCommandText(playerid, cmdtext[])
  137. {
  138. // Check command text
  139. if (strcmp("/zl", cmdtext, true, 3) == 0)
  140. {
  141. // Set the interior
  142. SetPlayerInterior(playerid, 0);
  143. // Set player position and facing angle
  144. SetPlayerPos(playerid, -1957.11 + random(2), 644.36 + random(2), 47.6);
  145. SetPlayerFacingAngle(playerid, 215);
  146. // Fix camera position after teleporting
  147. SetCameraBehindPlayer(playerid);
  148. // Send a gametext message to the player
  149. GameTextForPlayer(playerid, "~b~~h~ZomboTech Lab!", 3000, 3);
  150. // Exit here
  151. return 1;
  152. }
  153. // Exit here (return 0 as the command was not handled in this filterscript)
  154. return 0;
  155. }
  156. */
  157. public OnFilterScriptInit()
  158. {
  159. // Display information in the Server Console
  160. print("\n");
  161. print(" |---------------------------------------------------");
  162. print(" |--- SF ZomboTech Filterscript");
  163. print(" |-- Script v1.01");
  164. print(" |-- 12th January 2015");
  165. print(" |---------------------------------------------------");
  166. // Create the SF ZomboTech Building object
  167. SFZomboTechBuildingObject = CreateObject(19593, -1951.687500, 660.023986, 89.507797, 0, 0, 0);
  168. // Create the SF ZomboTech Lab object
  169. SFZomboTechLabObject = CreateObject(19594, -1951.687500, 660.023986, 29.507797, 0, 0, 0);
  170. // Display information in the Server Console
  171. print(" |-- SF ZomboTech Building and Lab objects created");
  172. // Reset the elevator queue
  173. ResetElevatorQueue();
  174. // Create the elevator object, the elevator doors and the floor doors
  175. Elevator_Initialize();
  176. // Display information in the Server Console
  177. print(" |-- SF ZomboTech Building Elevator created");
  178. print(" |---------------------------------------------------");
  179. // Loop
  180. for (new i = 0; i < MAX_PLAYERS; i++)
  181. {
  182. // Check if the player is connected and not a NPC
  183. if (IsPlayerConnected(i) && !IsPlayerNPC(i))
  184. {
  185. // Remove default GTASA SF ZomboTech map object and LOD for the player
  186. // (so any player currently ingame does not have to rejoin for them
  187. // to be removed when this filterscript is loaded)
  188. RemoveBuildingForPlayer(i, 10027, -1951.687500, 660.023986, 89.507797, 250.0); // Building
  189. RemoveBuildingForPlayer(i, 9939, -1951.687500, 660.023986, 89.507797, 250.0); // LOD
  190. }
  191. }
  192. // Exit here
  193. return 1;
  194. }
  195. public OnFilterScriptExit()
  196. {
  197. // Check for valid object
  198. if (IsValidObject(SFZomboTechBuildingObject))
  199. {
  200. // Destroy the SF ZombotTech Building object
  201. DestroyObject(SFZomboTechBuildingObject);
  202. // Display information in the Server Console
  203. print(" |---------------------------------------------------");
  204. print(" |-- SF ZomboTech Building object destroyed");
  205. }
  206. // Check for valid object
  207. if (IsValidObject(SFZomboTechLabObject))
  208. {
  209. // Destroy the SF ZomboTech Lab object
  210. DestroyObject(SFZomboTechLabObject);
  211. // Display information in the Server Console
  212. print(" |-- SF ZomboTech Lab object destroyed");
  213. }
  214. // Destroy the elevator, the elevator doors and the elevator floor doors
  215. Elevator_Destroy();
  216. // Display information in the Server Console
  217. print(" |-- SF ZomboTech Building Elevator destroyed");
  218. print(" |---------------------------------------------------");
  219. // Exit here
  220. return 1;
  221. }
  222. public OnPlayerConnect(playerid)
  223. {
  224. // Remove default GTASA SF ZomboTech map object and LOD for the player
  225. RemoveBuildingForPlayer(playerid, 10027, -1951.687500, 660.023986, 89.507797, 250.0); // Building
  226. RemoveBuildingForPlayer(playerid, 9939, -1951.687500, 660.023986, 89.507797, 250.0); // LOD
  227. // Exit here
  228. return 1;
  229. }
  230. public OnObjectMoved(objectid)
  231. {
  232. new Float:x, Float:y, Float:z;
  233. for(new i; i < sizeof(Obj_FloorDoors); i ++)
  234. {
  235. if(objectid == Obj_FloorDoors[i][0])
  236. {
  237. GetObjectPos(Obj_FloorDoors[i][0], x, y, z);
  238. // A floor door has shut so move the elevator to the next floor in the queue
  239. if (x == X_DOOR_CLOSED)
  240. {
  241. Elevator_MoveToFloor(ElevatorQueue[0]);
  242. RemoveFirstQueueFloor();
  243. }
  244. }
  245. }
  246. if(objectid == Obj_Elevator) // The elevator reached the specified floor.
  247. {
  248. KillTimer(ElevatorBoostTimer); // Kills the timer, in case the elevator reached the floor before boost.
  249. FloorRequestedBy[ElevatorFloor] = INVALID_PLAYER_ID;
  250. Elevator_OpenDoors();
  251. Floor_OpenDoors(ElevatorFloor);
  252. GetObjectPos(Obj_Elevator, x, y, z);
  253. Label_Elevator = Create3DTextLabel("{CCCCCC}Press '{FFFFFF}~k~~CONVERSATION_YES~{CCCCCC}' to use elevator", 0xCCCCCCAA, X_ELEVATOR_POS - 1.8, Y_ELEVATOR_POS + 1.6, z - 0.6, 4.0, 0, 1);
  254. ElevatorState = ELEVATOR_STATE_WAITING;
  255. SetTimer("Elevator_TurnToIdle", ELEVATOR_WAIT_TIME, 0);
  256. }
  257. return 1;
  258. }
  259. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  260. {
  261. if(dialogid == DIALOG_ID)
  262. {
  263. if(!response)
  264. return 0;
  265. if(FloorRequestedBy[listitem] != INVALID_PLAYER_ID || IsFloorInQueue(listitem))
  266. GameTextForPlayer(playerid, "~r~The floor is already in the queue", 3500, 4);
  267. else if(DidPlayerRequestElevator(playerid))
  268. GameTextForPlayer(playerid, "~r~You already requested the elevator", 3500, 4);
  269. else
  270. CallElevator(playerid, listitem);
  271. return 1;
  272. }
  273. return 0;
  274. }
  275. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  276. {
  277. if(!IsPlayerInAnyVehicle(playerid) && (newkeys & KEY_YES))
  278. {
  279. new Float:pos[3];
  280. GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  281. //printf("X = %0.2f | Y = %0.2f | Z = %0.2f", pos[0], pos[1], pos[2]);
  282. if(pos[1] < (Y_ELEVATOR_POS + 1.8) && pos[1] > (Y_ELEVATOR_POS - 1.8) && pos[0] < (X_ELEVATOR_POS + 1.8) && pos[0] > (X_ELEVATOR_POS - 1.8)) // He is using the elevator button
  283. ShowElevatorDialog(playerid);
  284. else // Is the player using a floor button?
  285. {
  286. if(pos[1] > (Y_ELEVATOR_POS + 1.81) && pos[1] < (Y_ELEVATOR_POS + 3.8) && pos[0] < (X_ELEVATOR_POS - 1.81) && pos[0] > (X_ELEVATOR_POS - 3.8))
  287. {
  288. // Create variable
  289. new i = 0;
  290. // Check for ground floor
  291. if (pos[2] > (GROUND_Z_COORD - 2) && pos[2] < (GROUND_Z_COORD + 2))
  292. {
  293. i = 0;
  294. }
  295. else i = 1;
  296. //printf("Floor = %d | State = %d | i = %d", ElevatorFloor, ElevatorState, i);
  297. // Check if the elevator is not moving and already on the requested floor
  298. if (ElevatorState != ELEVATOR_STATE_MOVING && ElevatorFloor == i)
  299. {
  300. // Display a gametext message and exit here
  301. GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~r~ZomboTech Elevator~n~~r~Is Already On~n~~r~This Floor!", 3000, 5);
  302. return 1;
  303. }
  304. //printf("Call Elevator to Floor %i", i);
  305. CallElevator(playerid, i);
  306. GameTextForPlayer(playerid, "~r~Elevator called", 3500, 4);
  307. }
  308. }
  309. }
  310. return 1;
  311. }
  312. // ------------------------ Functions ------------------------
  313. stock Elevator_Initialize()
  314. {
  315. // Initializes the elevator.
  316. Obj_Elevator = CreateObject(18755, X_ELEVATOR_POS, Y_ELEVATOR_POS, GROUND_Z_COORD, 0.000000, 0.000000, 270.000000);
  317. Obj_ElevatorDoors[0] = CreateObject(18757, X_ELEVATOR_POS, Y_ELEVATOR_POS, GROUND_Z_COORD, 0.000000, 0.000000, 270.000000);
  318. Obj_ElevatorDoors[1] = CreateObject(18756, X_ELEVATOR_POS, Y_ELEVATOR_POS, GROUND_Z_COORD, 0.000000, 0.000000, 270.000000);
  319. Label_Elevator = Create3DTextLabel("{CCCCCC}Press '{FFFFFF}~k~~CONVERSATION_YES~{CCCCCC}' to use elevator", 0xCCCCCCAA, X_ELEVATOR_POS - 1.8, Y_ELEVATOR_POS + 1.6, GROUND_Z_COORD - 0.6, 4.0, 0, 1);
  320. new string[128],
  321. Float:z;
  322. for(new i; i < sizeof(Obj_FloorDoors); i ++)
  323. {
  324. Obj_FloorDoors[i][0] = CreateObject(18757, X_ELEVATOR_POS, Y_ELEVATOR_POS + 0.245, GetDoorsZCoordForFloor(i), 0.000000, 0.000000, 270.000000);
  325. Obj_FloorDoors[i][1] = CreateObject(18756, X_ELEVATOR_POS, Y_ELEVATOR_POS + 0.245, GetDoorsZCoordForFloor(i), 0.000000, 0.000000, 270.000000);
  326. format(string, sizeof(string), "{CCCCCC}[%s]\n{CCCCCC}Press '{FFFFFF}~k~~CONVERSATION_YES~{CCCCCC}' to call", FloorNames[i]);
  327. if(i == 0)
  328. z = 47.460277;
  329. else
  330. z = 25.820274;
  331. Label_Floors[i] = Create3DTextLabel(string, 0xCCCCCCAA, X_ELEVATOR_POS - 2.5, Y_ELEVATOR_POS + 2.5, z - 0.2, 10.5, 0, 1);
  332. }
  333. // Open ground floor doors:
  334. Floor_OpenDoors(0);
  335. Elevator_OpenDoors();
  336. return 1;
  337. }
  338. stock Elevator_Destroy()
  339. {
  340. // Destroys the elevator and the elevator doors
  341. DestroyObject(Obj_Elevator);
  342. DestroyObject(Obj_ElevatorDoors[0]);
  343. DestroyObject(Obj_ElevatorDoors[1]);
  344. // Destroy the 3D text label inside the elevator
  345. Delete3DTextLabel(Label_Elevator);
  346. // Loop
  347. for(new i; i < sizeof(Obj_FloorDoors); i ++)
  348. {
  349. // Destroy the elevator floor doors and the floor 3D text labels
  350. DestroyObject(Obj_FloorDoors[i][0]);
  351. DestroyObject(Obj_FloorDoors[i][1]);
  352. Delete3DTextLabel(Label_Floors[i]);
  353. }
  354. return 1;
  355. }
  356. stock Elevator_OpenDoors()
  357. {
  358. // Opens the elevator's doors.
  359. new Float:x, Float:y, Float:z;
  360. GetObjectPos(Obj_ElevatorDoors[0], x, y, z);
  361. MoveObject(Obj_ElevatorDoors[0], X_DOOR_L_OPENED, y, z, DOORS_SPEED);
  362. MoveObject(Obj_ElevatorDoors[1], X_DOOR_R_OPENED, y, z, DOORS_SPEED);
  363. return 1;
  364. }
  365. stock Elevator_CloseDoors()
  366. {
  367. // Closes the elevator's doors.
  368. if(ElevatorState == ELEVATOR_STATE_MOVING)
  369. return 0;
  370. new Float:x, Float:y, Float:z;
  371. GetObjectPos(Obj_ElevatorDoors[0], x, y, z);
  372. MoveObject(Obj_ElevatorDoors[0], X_DOOR_CLOSED, y, z, DOORS_SPEED);
  373. MoveObject(Obj_ElevatorDoors[1], X_DOOR_CLOSED, y, z, DOORS_SPEED);
  374. return 1;
  375. }
  376. stock Floor_OpenDoors(floorid)
  377. {
  378. // Opens the doors at the specified floor.
  379. MoveObject(Obj_FloorDoors[floorid][0], X_DOOR_L_OPENED, Y_ELEVATOR_POS + 0.245, GetDoorsZCoordForFloor(floorid), DOORS_SPEED);
  380. MoveObject(Obj_FloorDoors[floorid][1], X_DOOR_R_OPENED, Y_ELEVATOR_POS + 0.245, GetDoorsZCoordForFloor(floorid), DOORS_SPEED);
  381. PlaySoundForPlayersInRange(6401, 50.0, X_ELEVATOR_POS, Y_ELEVATOR_POS, GetDoorsZCoordForFloor(floorid) + 5.0);
  382. return 1;
  383. }
  384. stock Floor_CloseDoors(floorid)
  385. {
  386. // Closes the doors at the specified floor.
  387. MoveObject(Obj_FloorDoors[floorid][0], X_ELEVATOR_POS, Y_ELEVATOR_POS + 0.245, GetDoorsZCoordForFloor(floorid), DOORS_SPEED);
  388. MoveObject(Obj_FloorDoors[floorid][1], X_ELEVATOR_POS, Y_ELEVATOR_POS + 0.245, GetDoorsZCoordForFloor(floorid), DOORS_SPEED);
  389. PlaySoundForPlayersInRange(6401, 50.0, X_ELEVATOR_POS, Y_ELEVATOR_POS, GetDoorsZCoordForFloor(floorid) + 5.0);
  390. return 1;
  391. }
  392. stock Elevator_MoveToFloor(floorid)
  393. {
  394. // Moves the elevator to specified floor (doors are meant to be already closed).
  395. ElevatorState = ELEVATOR_STATE_MOVING;
  396. ElevatorFloor = floorid;
  397. // Move the elevator slowly, to give time to clients to sync the object surfing. Then, boost it up:
  398. MoveObject(Obj_Elevator, X_ELEVATOR_POS, Y_ELEVATOR_POS, GetElevatorZCoordForFloor(floorid), 0.25);
  399. MoveObject(Obj_ElevatorDoors[0], X_ELEVATOR_POS, Y_ELEVATOR_POS, GetDoorsZCoordForFloor(floorid), 0.25);
  400. MoveObject(Obj_ElevatorDoors[1], X_ELEVATOR_POS, Y_ELEVATOR_POS, GetDoorsZCoordForFloor(floorid), 0.25);
  401. Delete3DTextLabel(Label_Elevator);
  402. ElevatorBoostTimer = SetTimerEx("Elevator_Boost", 2000, 0, "i", floorid);
  403. return 1;
  404. }
  405. public Elevator_Boost(floorid)
  406. {
  407. // Increases the elevator's speed until it reaches 'floorid'
  408. StopObject(Obj_Elevator);
  409. StopObject(Obj_ElevatorDoors[0]);
  410. StopObject(Obj_ElevatorDoors[1]);
  411. MoveObject(Obj_Elevator, X_ELEVATOR_POS, Y_ELEVATOR_POS, GetElevatorZCoordForFloor(floorid), ELEVATOR_SPEED);
  412. MoveObject(Obj_ElevatorDoors[0], X_ELEVATOR_POS, Y_ELEVATOR_POS, GetDoorsZCoordForFloor(floorid), ELEVATOR_SPEED);
  413. MoveObject(Obj_ElevatorDoors[1], X_ELEVATOR_POS, Y_ELEVATOR_POS, GetDoorsZCoordForFloor(floorid), ELEVATOR_SPEED);
  414. return 1;
  415. }
  416. public Elevator_TurnToIdle()
  417. {
  418. ElevatorState = ELEVATOR_STATE_IDLE;
  419. ReadNextFloorInQueue();
  420. return 1;
  421. }
  422. stock RemoveFirstQueueFloor()
  423. {
  424. // Removes the data in ElevatorQueue[0], and reorders the queue accordingly.
  425. for(new i; i < sizeof(ElevatorQueue) - 1; i ++)
  426. ElevatorQueue[i] = ElevatorQueue[i + 1];
  427. ElevatorQueue[sizeof(ElevatorQueue) - 1] = INVALID_FLOOR;
  428. return 1;
  429. }
  430. stock AddFloorToQueue(floorid)
  431. {
  432. // Adds 'floorid' at the end of the queue.
  433. // Scan for the first empty space:
  434. new slot = -1;
  435. for(new i; i < sizeof(ElevatorQueue); i ++)
  436. {
  437. if(ElevatorQueue[i] == INVALID_FLOOR)
  438. {
  439. slot = i;
  440. break;
  441. }
  442. }
  443. if(slot != -1)
  444. {
  445. ElevatorQueue[slot] = floorid;
  446. // If needed, move the elevator.
  447. if(ElevatorState == ELEVATOR_STATE_IDLE)
  448. ReadNextFloorInQueue();
  449. return 1;
  450. }
  451. return 0;
  452. }
  453. stock ResetElevatorQueue()
  454. {
  455. // Resets the queue.
  456. for(new i; i < sizeof(ElevatorQueue); i ++)
  457. {
  458. ElevatorQueue[i] = INVALID_FLOOR;
  459. FloorRequestedBy[i] = INVALID_PLAYER_ID;
  460. }
  461. return 1;
  462. }
  463. stock IsFloorInQueue(floorid)
  464. {
  465. // Checks if the specified floor is currently part of the queue.
  466. for(new i; i < sizeof(ElevatorQueue); i ++)
  467. if(ElevatorQueue[i] == floorid)
  468. return 1;
  469. return 0;
  470. }
  471. stock ReadNextFloorInQueue()
  472. {
  473. // Reads the next floor in the queue, closes doors, and goes to it.
  474. if(ElevatorState != ELEVATOR_STATE_IDLE || ElevatorQueue[0] == INVALID_FLOOR)
  475. return 0;
  476. Elevator_CloseDoors();
  477. Floor_CloseDoors(ElevatorFloor);
  478. return 1;
  479. }
  480. stock DidPlayerRequestElevator(playerid)
  481. {
  482. for(new i; i < sizeof(FloorRequestedBy); i ++)
  483. if(FloorRequestedBy[i] == playerid)
  484. return 1;
  485. return 0;
  486. }
  487. stock ShowElevatorDialog(playerid)
  488. {
  489. new string[512];
  490. for(new i; i < sizeof(ElevatorQueue); i ++)
  491. {
  492. if(FloorRequestedBy[i] != INVALID_PLAYER_ID)
  493. strcat(string, "{FF0000}");
  494. strcat(string, FloorNames[i]);
  495. strcat(string, "\n");
  496. }
  497. ShowPlayerDialog(playerid, DIALOG_ID, DIALOG_STYLE_LIST, "ZomboTech Elevator...", string, "Accept", "Cancel");
  498. return 1;
  499. }
  500. stock CallElevator(playerid, floorid)
  501. {
  502. // Calls the elevator (also used with the elevator dialog).
  503. if(FloorRequestedBy[floorid] != INVALID_PLAYER_ID || IsFloorInQueue(floorid))
  504. return 0;
  505. FloorRequestedBy[floorid] = playerid;
  506. AddFloorToQueue(floorid);
  507. return 1;
  508. }
  509. stock Float:GetElevatorZCoordForFloor(floorid)
  510. return (GROUND_Z_COORD + FloorZOffsets[floorid]);
  511. stock Float:GetDoorsZCoordForFloor(floorid)
  512. return (GROUND_Z_COORD + FloorZOffsets[floorid]);