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.

630 lines
24 KiB

  1. //---------------------------------------------------------
  2. //
  3. // Rivershell v2 by Kye - 2006-2013
  4. //
  5. //---------------------------------------------------------
  6. #include <a_samp>
  7. #include <core>
  8. #include <float>
  9. // Global stuff and defines for our gamemode.
  10. static gTeam[MAX_PLAYERS]; // Tracks the team assignment for each player
  11. #define OBJECTIVE_VEHICLE_GREEN 2
  12. #define OBJECTIVE_VEHICLE_BLUE 1
  13. #define TEAM_GREEN 1
  14. #define TEAM_BLUE 2
  15. #define OBJECTIVE_COLOR 0xE2C063FF
  16. #define TEAM_GREEN_COLOR 0x77CC77FF
  17. #define TEAM_BLUE_COLOR 0x7777DDFF
  18. #define CAPS_TO_WIN 5
  19. #define ALLOW_RESPAWN_AFTER_N_SECONDS 20
  20. #define SPECTATE_STATE_NONE 0
  21. #define SPECTATE_STATE_PLAYER 1
  22. #define SPECTATE_STATE_FIXED 2
  23. #define SPECTATE_MODE_NONE 0
  24. #define SPECTATE_MODE_PLAYER 1
  25. #define SPECTATE_MODE_VEHICLE 2
  26. new gObjectiveReached = 0; // Stops the winner logic reentering itself.
  27. new gObjectiveGreenPlayer=(-1); // Tracks which green player has the vehicle.
  28. new gObjectiveBluePlayer=(-1); // Tracks which blue player has the vehicle.
  29. // number of times the vehicle has been captured by each team
  30. new gGreenTimesCapped=0;
  31. new gBlueTimesCapped=0;
  32. // forward declarations for the PAWN compiler (not really needed, but there for the sake of clarity)
  33. forward SetPlayerToTeamColor(playerid);
  34. forward SetupPlayerForClassSelection(playerid);
  35. forward SetPlayerTeamFromClass(playerid,classid);
  36. forward ExitTheGameMode();
  37. //---------------------------------------------------------
  38. main()
  39. {
  40. print("\n----------------------------------");
  41. print(" Rivershell by Kye 2006-2013\n");
  42. print("----------------------------------\n");
  43. }
  44. //---------------------------------------------------------
  45. public SetPlayerToTeamColor(playerid)
  46. {
  47. if(gTeam[playerid] == TEAM_GREEN) {
  48. SetPlayerColor(playerid, TEAM_GREEN_COLOR); // green
  49. } else if(gTeam[playerid] == TEAM_BLUE) {
  50. SetPlayerColor(playerid, TEAM_BLUE_COLOR); // blue
  51. }
  52. }
  53. //---------------------------------------------------------
  54. public SetupPlayerForClassSelection(playerid)
  55. {
  56. // Set the player's orientation when they're selecting a class.
  57. SetPlayerPos(playerid,1984.4445,157.9501,55.9384);
  58. SetPlayerCameraPos(playerid,1984.4445,160.9501,55.9384);
  59. SetPlayerCameraLookAt(playerid,1984.4445,157.9501,55.9384);
  60. SetPlayerFacingAngle(playerid,0.0);
  61. }
  62. //---------------------------------------------------------
  63. public SetPlayerTeamFromClass(playerid,classid)
  64. {
  65. // Set their team number based on the class they selected.
  66. if(classid == 0 || classid == 1) {
  67. SetPlayerTeam(playerid, TEAM_GREEN);
  68. gTeam[playerid] = TEAM_GREEN;
  69. }
  70. else if(classid == 2 || classid == 3) {
  71. SetPlayerTeam(playerid, TEAM_BLUE);
  72. gTeam[playerid] = TEAM_BLUE;
  73. }
  74. }
  75. //---------------------------------------------------------
  76. public ExitTheGameMode()
  77. {
  78. PlaySoundForAll(1186, 0.0, 0.0, 0.0); // Stops the music
  79. //printf("Exiting Game Mode");
  80. GameModeExit();
  81. }
  82. //---------------------------------------------------------
  83. public OnPlayerStateChange(playerid, newstate, oldstate)
  84. {
  85. new vehicleid;
  86. if(newstate == PLAYER_STATE_DRIVER)
  87. {
  88. vehicleid = GetPlayerVehicleID(playerid);
  89. if(gTeam[playerid] == TEAM_GREEN && vehicleid == OBJECTIVE_VEHICLE_GREEN)
  90. { // It's the objective vehicle
  91. SetPlayerColor(playerid,OBJECTIVE_COLOR);
  92. GameTextForPlayer(playerid,"~w~Take the ~y~boat ~w~back to the ~r~spawn!",3000,5);
  93. SetPlayerCheckpoint(playerid, 2135.7368, -179.8811, -0.5323, 10.0);
  94. gObjectiveGreenPlayer = playerid;
  95. }
  96. if(gTeam[playerid] == TEAM_BLUE && vehicleid == OBJECTIVE_VEHICLE_BLUE)
  97. { // It's the objective vehicle
  98. SetPlayerColor(playerid,OBJECTIVE_COLOR);
  99. GameTextForPlayer(playerid,"~w~Take the ~y~boat ~w~back to the ~r~spawn!",3000,5);
  100. SetPlayerCheckpoint(playerid, 2329.4226, 532.7426, 0.5862, 10.0);
  101. gObjectiveBluePlayer = playerid;
  102. }
  103. }
  104. else if(newstate == PLAYER_STATE_ONFOOT)
  105. {
  106. if(playerid == gObjectiveGreenPlayer) {
  107. gObjectiveGreenPlayer = (-1);
  108. SetPlayerToTeamColor(playerid);
  109. DisablePlayerCheckpoint(playerid);
  110. }
  111. if(playerid == gObjectiveBluePlayer) {
  112. gObjectiveBluePlayer = (-1);
  113. SetPlayerToTeamColor(playerid);
  114. DisablePlayerCheckpoint(playerid);
  115. }
  116. }
  117. return 1;
  118. }
  119. //---------------------------------------------------------
  120. public OnGameModeInit()
  121. {
  122. SetGameModeText("Rivershell");
  123. ShowPlayerMarkers(0);
  124. ShowNameTags(1);
  125. SetWorldTime(17);
  126. SetWeather(11);
  127. UsePlayerPedAnims();
  128. EnableVehicleFriendlyFire();
  129. SetNameTagDrawDistance(110.0);
  130. DisableInteriorEnterExits();
  131. // Green classes
  132. AddPlayerClass(162,2117.0129,-224.4389,8.15,0.0,31,100,29,200,34,10);
  133. AddPlayerClass(157,2148.6606,-224.3336,8.15,347.1396,31,100,29,200,34,10);
  134. // Blue classes
  135. AddPlayerClass(154,2352.9873,580.3051,7.7813,178.1424,31,100,29,200,34,10);
  136. AddPlayerClass(138,2281.1504,567.6248,7.7813,163.7289,31,100,29,200,34,10);
  137. // Objective vehicles
  138. CreateVehicle(453, 2184.7156, -188.5401, -0.0239, 0.0000, 114, 1, 100); // gr reefer
  139. CreateVehicle(453, 2380.0542, 535.2582, -0.0272, 178.4999, 79, 7, 100); // bl reefer
  140. // Green Dhingys
  141. CreateVehicle(473, 2096.0833, -168.7771, 0.3528, 4.5000, 114, 1, 100);
  142. CreateVehicle(473, 2103.2510, -168.7598, 0.3528, 3.1800, 114, 1, 100);
  143. CreateVehicle(473, 2099.4966, -168.8216, 0.3528, 2.8200, 114, 1, 100);
  144. CreateVehicle(473, 2107.1143, -168.7798, 0.3528, 3.1800, 114, 1, 100);
  145. CreateVehicle(473, 2111.0674, -168.7609, 0.3528, 3.1800, 114, 1, 100);
  146. CreateVehicle(473, 2114.8933, -168.7898, 0.3528, 3.1800, 114, 1, 100);
  147. CreateVehicle(473, 2167.2217, -169.0570, 0.3528, 3.1800, 114, 1, 100);
  148. CreateVehicle(473, 2170.4294, -168.9724, 0.3528, 3.1800, 114, 1, 100);
  149. CreateVehicle(473, 2173.7952, -168.9217, 0.3528, 3.1800, 114, 1, 100);
  150. CreateVehicle(473, 2177.0386, -168.9767, 0.3528, 3.1800, 114, 1, 100);
  151. CreateVehicle(473, 2161.5786, -191.9538, 0.3528, 89.1000, 114, 1, 100);
  152. CreateVehicle(473, 2161.6394, -187.2925, 0.3528, 89.1000, 114, 1, 100);
  153. CreateVehicle(473, 2161.7610, -183.0225, 0.3528, 89.1000, 114, 1, 100);
  154. CreateVehicle(473, 2162.0283, -178.5106, 0.3528, 89.1000, 114, 1, 100);
  155. // Green Mavericks
  156. CreateVehicle(487, 2088.7905, -227.9593, 8.3662, 0.0000, 114, 1, 100);
  157. CreateVehicle(487, 2204.5991, -225.3703, 8.2400, 0.0000, 114, 1, 100);
  158. // Blue Dhingys
  159. CreateVehicle(473, 2370.3198, 518.3151, 0.1240, 180.3600, 79, 7, 100);
  160. CreateVehicle(473, 2362.6484, 518.3978, 0.0598, 180.3600, 79, 7, 100);
  161. CreateVehicle(473, 2358.6550, 518.2167, 0.2730, 180.3600, 79, 7, 100);
  162. CreateVehicle(473, 2366.5544, 518.2680, 0.1080, 180.3600, 79, 7, 100);
  163. CreateVehicle(473, 2354.6321, 518.1960, 0.3597, 180.3600, 79, 7, 100);
  164. CreateVehicle(473, 2350.7449, 518.1929, 0.3597, 180.3600, 79, 7, 100);
  165. CreateVehicle(473, 2298.8977, 518.4470, 0.3597, 180.3600, 79, 7, 100);
  166. CreateVehicle(473, 2295.6118, 518.3963, 0.3597, 180.3600, 79, 7, 100);
  167. CreateVehicle(473, 2292.3237, 518.4249, 0.3597, 180.3600, 79, 7, 100);
  168. CreateVehicle(473, 2289.0901, 518.4363, 0.3597, 180.3600, 79, 7, 100);
  169. CreateVehicle(473, 2304.8232, 539.7859, 0.3597, 270.5998, 79, 7, 100);
  170. CreateVehicle(473, 2304.6936, 535.0454, 0.3597, 270.5998, 79, 7, 100);
  171. CreateVehicle(473, 2304.8245, 530.3308, 0.3597, 270.5998, 79, 7, 100);
  172. CreateVehicle(473, 2304.8142, 525.7471, 0.3597, 270.5998, 79, 7, 100);
  173. // Blue Mavericks
  174. CreateVehicle(487, 2260.2637, 578.5220, 8.1223, 182.3401, 79, 7, 100);
  175. CreateVehicle(487, 2379.9792, 580.0323, 8.0178, 177.9601, 79, 7, 100);
  176. // Green Base Section
  177. CreateMapObject(9090, 2148.64, -222.88, -20.60, 0.00, 0.00, 179.70);
  178. // Green resupply hut
  179. CreateMapObject(12991, 2140.83, -235.13, 7.13, 0.00, 0.00, -89.94);
  180. // Blue Base Section
  181. CreateMapObject(9090, 2317.09, 572.27, -20.97, 0.00, 0.00, 0.00);
  182. // Blue resupply hut
  183. CreateMapObject(12991, 2318.73, 590.96, 6.75, 0.00, 0.00, 89.88);
  184. // General mapping
  185. CreateMapObject(12991, 2140.83, -235.13, 7.13, 0.00, 0.00, -89.94);
  186. CreateMapObject(19300, 2137.33, -237.17, 46.61, 0.00, 0.00, 180.00);
  187. CreateMapObject(12991, 2318.73, 590.96, 6.75, 0.00, 0.00, 89.88);
  188. CreateMapObject(19300, 2325.41, 587.93, 47.37, 0.00, 0.00, 180.00);
  189. CreateMapObject(12991, 2140.83, -235.13, 7.13, 0.00, 0.00, -89.94);
  190. CreateMapObject(12991, 2318.73, 590.96, 6.75, 0.00, 0.00, 89.88);
  191. CreateMapObject(12991, 2140.83, -235.13, 7.13, 0.00, 0.00, -89.94);
  192. CreateMapObject(12991, 2318.73, 590.96, 6.75, 0.00, 0.00, 89.88);
  193. CreateMapObject(18228, 1887.93, -59.78, -2.14, 0.00, 0.00, 20.34);
  194. CreateMapObject(17031, 1990.19, 541.37, -22.32, 0.00, 0.00, 0.00);
  195. CreateMapObject(18227, 2000.82, 494.15, -7.53, 11.70, -25.74, 154.38);
  196. CreateMapObject(17031, 1992.35, 539.80, -2.97, 9.12, 30.66, 0.00);
  197. CreateMapObject(17031, 1991.88, 483.77, -0.66, -2.94, -5.22, 12.78);
  198. CreateMapObject(17029, 2070.57, -235.87, -6.05, -7.20, 4.08, 114.30);
  199. CreateMapObject(17029, 2056.50, -228.77, -19.67, 14.16, 19.68, 106.56);
  200. CreateMapObject(17029, 2074.00, -205.33, -18.60, 16.02, 60.60, 118.86);
  201. CreateMapObject(17029, 2230.39, -242.59, -11.41, 5.94, 7.56, 471.24);
  202. CreateMapObject(17029, 2252.53, -213.17, -20.81, 18.90, -6.30, -202.38);
  203. CreateMapObject(17029, 2233.04, -234.08, -19.00, 21.84, -8.88, -252.06);
  204. CreateMapObject(17027, 2235.05, -201.49, -11.90, -11.94, -4.08, 136.32);
  205. CreateMapObject(17029, 2226.11, -237.07, -2.45, 8.46, 2.10, 471.24);
  206. CreateMapObject(4368, 2433.79, 446.26, 4.67, -8.04, -9.30, 61.02);
  207. CreateMapObject(4368, 2031.23, 489.92, -13.20, -8.04, -9.30, -108.18);
  208. CreateMapObject(17031, 2458.36, 551.10, -6.95, 0.00, 0.00, 0.00);
  209. CreateMapObject(17031, 2465.37, 511.35, -7.70, 0.00, 0.00, 0.00);
  210. CreateMapObject(17031, 2474.80, 457.71, -5.17, 0.00, 0.00, 172.74);
  211. CreateMapObject(17031, 2466.03, 426.28, -5.17, 0.00, 0.00, 0.00);
  212. CreateMapObject(791, 2310.45, -229.38, 7.41, 0.00, 0.00, 0.00);
  213. CreateMapObject(791, 2294.00, -180.15, 7.41, 0.00, 0.00, 60.90);
  214. CreateMapObject(791, 2017.50, -305.30, 7.29, 0.00, 0.00, 60.90);
  215. CreateMapObject(791, 2106.45, -279.86, 20.05, 0.00, 0.00, 60.90);
  216. CreateMapObject(706, 2159.13, -263.71, 19.22, 356.86, 0.00, -17.18);
  217. CreateMapObject(706, 2055.75, -291.53, 13.98, 356.86, 0.00, -66.50);
  218. CreateMapObject(791, 1932.65, -315.88, 6.77, 0.00, 0.00, -35.76);
  219. CreateMapObject(790, 2429.40, 575.79, 10.42, 0.00, 0.00, 3.14);
  220. CreateMapObject(790, 2403.40, 581.56, 10.42, 0.00, 0.00, 29.48);
  221. CreateMapObject(791, 2083.44, 365.48, 13.19, 356.86, 0.00, -1.95);
  222. CreateMapObject(791, 2040.15, 406.02, 13.33, 356.86, 0.00, -1.95);
  223. CreateMapObject(791, 1995.36, 588.10, 7.50, 356.86, 0.00, -1.95);
  224. CreateMapObject(791, 2126.11, 595.15, 5.99, 0.00, 0.00, -35.82);
  225. CreateMapObject(791, 2188.35, 588.90, 6.04, 0.00, 0.00, 0.00);
  226. CreateMapObject(791, 2068.56, 595.58, 5.99, 0.00, 0.00, 52.62);
  227. CreateMapObject(698, 2385.32, 606.16, 9.79, 0.00, 0.00, 34.62);
  228. CreateMapObject(698, 2309.29, 606.92, 9.79, 0.00, 0.00, -54.54);
  229. CreateMapObject(790, 2347.14, 619.77, 9.94, 0.00, 0.00, 3.14);
  230. CreateMapObject(698, 2255.28, 606.94, 9.79, 0.00, 0.00, -92.76);
  231. CreateMapObject(4298, 2121.37, 544.12, -5.74, -10.86, 6.66, 3.90);
  232. CreateMapObject(4368, 2273.18, 475.02, -15.30, 4.80, 8.10, 266.34);
  233. CreateMapObject(18227, 2232.38, 451.61, -30.71, -18.54, -6.06, 154.38);
  234. CreateMapObject(17031, 2228.15, 518.87, -16.51, 13.14, -1.32, -20.10);
  235. CreateMapObject(17031, 2230.42, 558.52, -18.38, -2.94, -5.22, 12.78);
  236. CreateMapObject(17031, 2228.97, 573.62, 5.17, 17.94, -15.60, -4.08);
  237. CreateMapObject(17029, 2116.67, -87.71, -2.31, 5.94, 7.56, 215.22);
  238. CreateMapObject(17029, 2078.66, -83.87, -27.30, 13.02, -53.94, -0.30);
  239. CreateMapObject(17029, 2044.80, -36.91, -9.26, -13.74, 27.90, 293.76);
  240. CreateMapObject(17029, 2242.41, 426.16, -15.43, -21.54, 22.26, 154.80);
  241. CreateMapObject(17029, 2220.06, 450.07, -34.78, -1.32, 10.20, -45.84);
  242. CreateMapObject(17029, 2252.49, 439.08, -19.47, -41.40, 20.16, 331.86);
  243. CreateMapObject(17031, 2241.41, 431.93, -5.62, -2.22, -4.80, 53.64);
  244. CreateMapObject(17029, 2141.10, -81.30, -2.41, 5.94, 7.56, 39.54);
  245. CreateMapObject(17031, 2277.07, 399.31, -1.65, -2.22, -4.80, -121.74);
  246. CreateMapObject(17026, 2072.75, -224.40, -5.25, 0.00, 0.00, -41.22);
  247. // Ramps
  248. CreateMapObject(1632, 2131.97, 110.24, 0.00, 0.00, 0.00, 153.72);
  249. CreateMapObject(1632, 2124.59, 113.69, 0.00, 0.00, 0.00, 157.56);
  250. CreateMapObject(1632, 2116.31, 116.44, 0.00, 0.00, 0.00, 160.08);
  251. CreateMapObject(1632, 2113.22, 108.48, 0.00, 0.00, 0.00, 340.20);
  252. CreateMapObject(1632, 2121.21, 105.21, 0.00, 0.00, 0.00, 340.20);
  253. CreateMapObject(1632, 2127.84, 102.06, 0.00, 0.00, 0.00, 334.68);
  254. CreateMapObject(1632, 2090.09, 40.90, 0.00, 0.00, 0.00, 348.36);
  255. CreateMapObject(1632, 2098.73, 39.12, 0.00, 0.00, 0.00, 348.36);
  256. CreateMapObject(1632, 2107.17, 37.94, 0.00, 0.00, 0.00, 348.36);
  257. CreateMapObject(1632, 2115.88, 36.47, 0.00, 0.00, 0.00, 348.36);
  258. CreateMapObject(1632, 2117.46, 45.86, 0.00, 0.00, 0.00, 529.20);
  259. CreateMapObject(1632, 2108.98, 46.95, 0.00, 0.00, 0.00, 529.20);
  260. CreateMapObject(1632, 2100.42, 48.11, 0.00, 0.00, 0.00, 526.68);
  261. CreateMapObject(1632, 2091.63, 50.02, 0.00, 0.00, 0.00, 526.80);
  262. return 1;
  263. }
  264. //---------------------------------------------------------
  265. public OnPlayerConnect(playerid)
  266. {
  267. SetPlayerColor(playerid,0x888888FF);
  268. GameTextForPlayer(playerid,"~r~SA-MP: ~w~Rivershell",2000,5);
  269. RemoveNeededBuildingsForPlayer(playerid);
  270. return 1;
  271. }
  272. //---------------------------------------------------------
  273. public OnPlayerRequestClass(playerid, classid)
  274. {
  275. SetupPlayerForClassSelection(playerid);
  276. SetPlayerTeamFromClass(playerid,classid);
  277. if(classid == 0 || classid == 1) {
  278. GameTextForPlayer(playerid,"~g~GREEN ~w~TEAM",1000,5);
  279. } else if(classid == 2 || classid == 3) {
  280. GameTextForPlayer(playerid,"~b~BLUE ~w~TEAM",1000,5);
  281. }
  282. return 1;
  283. }
  284. //---------------------------------------------------------
  285. public OnPlayerSpawn(playerid)
  286. {
  287. // Wait a bit before allowing them to respawn. Switch to spectate mode.
  288. if( GetPVarInt(playerid, "LastDeathTick") != 0 &&
  289. GetTickCount() - GetPVarInt(playerid, "LastDeathTick") < (ALLOW_RESPAWN_AFTER_N_SECONDS * 1000) )
  290. {
  291. SendClientMessage(playerid, 0xFFAAEEEE, "Waiting to respawn....");
  292. TogglePlayerSpectating(playerid, 1);
  293. // If the last killer id is valid, we should try setting it now to avoid any camera lag switching to spectate.
  294. new LastKillerId = GetPVarInt(playerid, "LastKillerId");
  295. if( IsPlayerConnected(LastKillerId) &&
  296. (GetPlayerState(LastKillerId) == PLAYER_STATE_ONFOOT ||
  297. GetPlayerState(LastKillerId) == PLAYER_STATE_DRIVER ||
  298. GetPlayerState(LastKillerId) == PLAYER_STATE_PASSENGER) )
  299. {
  300. SpectatePlayer(playerid, LastKillerId);
  301. SetPVarInt(playerid, "SpectateState", SPECTATE_STATE_PLAYER);
  302. }
  303. return 1;
  304. }
  305. SetPlayerToTeamColor(playerid);
  306. if(gTeam[playerid] == TEAM_GREEN) {
  307. GameTextForPlayer(playerid,
  308. "Defend the ~g~GREEN ~w~team's ~y~Reefer~n~~w~Capture the ~b~BLUE ~w~team's ~y~Reefer",
  309. 6000,5);
  310. }
  311. else if(gTeam[playerid] == TEAM_BLUE) {
  312. GameTextForPlayer(playerid,
  313. "Defend the ~b~BLUE ~w~team's ~y~Reefer~n~~w~Capture the ~g~GREEN ~w~team's ~y~Reefer",
  314. 6000,5);
  315. }
  316. SetPlayerHealth(playerid, 100.0);
  317. SetPlayerArmour(playerid, 100.0);
  318. SetPlayerWorldBounds(playerid, 2500.0, 1850.0, 631.2963, -454.9898);
  319. SetPVarInt(playerid, "SpectateState", SPECTATE_STATE_NONE);
  320. SetPVarInt(playerid, "SpectateMode", SPECTATE_MODE_NONE);
  321. return 1;
  322. }
  323. //---------------------------------------------------------
  324. public OnPlayerEnterCheckpoint(playerid)
  325. {
  326. new playervehicleid = GetPlayerVehicleID(playerid);
  327. if(gObjectiveReached) return;
  328. if(playervehicleid == OBJECTIVE_VEHICLE_GREEN && gTeam[playerid] == TEAM_GREEN)
  329. { // Green OBJECTIVE REACHED.
  330. gGreenTimesCapped++;
  331. SetPlayerScore(playerid,GetPlayerScore(playerid)+5);
  332. if(gGreenTimesCapped==CAPS_TO_WIN) {
  333. GameTextForAll("~g~GREEN ~w~team wins!",3000,5);
  334. gObjectiveReached = 1; PlaySoundForAll(1185, 0.0, 0.0, 0.0);
  335. SetTimer("ExitTheGameMode", 6000, 0); // Set up a timer to exit this mode.
  336. } else {
  337. GameTextForAll("~g~GREEN ~w~team captured the ~y~boat!",3000,5);
  338. SetVehicleToRespawn(OBJECTIVE_VEHICLE_GREEN);
  339. }
  340. return;
  341. }
  342. else if(playervehicleid == OBJECTIVE_VEHICLE_BLUE && gTeam[playerid] == TEAM_BLUE)
  343. { // Blue OBJECTIVE REACHED.
  344. gBlueTimesCapped++;
  345. SetPlayerScore(playerid,GetPlayerScore(playerid)+5);
  346. if(gBlueTimesCapped==CAPS_TO_WIN) {
  347. GameTextForAll("~b~BLUE ~w~team wins!",3000,5);
  348. gObjectiveReached = 1; PlaySoundForAll(1185, 0.0, 0.0, 0.0);
  349. SetTimer("ExitTheGameMode", 6000, 0); // Set up a timer to exit this mode.
  350. } else {
  351. GameTextForAll("~b~BLUE ~w~team captured the ~y~boat!",3000,5);
  352. SetVehicleToRespawn(OBJECTIVE_VEHICLE_BLUE);
  353. }
  354. return;
  355. }
  356. }
  357. //---------------------------------------------------------
  358. public OnPlayerDeath(playerid, killerid, reason)
  359. {
  360. if(killerid == INVALID_PLAYER_ID) {
  361. SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);
  362. } else {
  363. if(gTeam[killerid] != gTeam[playerid]) {
  364. // Valid kill
  365. SendDeathMessage(killerid,playerid,reason);
  366. SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
  367. }
  368. else {
  369. // Team kill
  370. SendDeathMessage(killerid,playerid,reason);
  371. }
  372. }
  373. SetPVarInt(playerid, "LastDeathTick", GetTickCount());
  374. SetPVarInt(playerid, "LastKillerId", killerid);
  375. return 1;
  376. }
  377. //---------------------------------
  378. public OnVehicleStreamIn(vehicleid, forplayerid)
  379. {
  380. // As the vehicle streams in, player team dependant params are applied. They can't be
  381. // applied to vehicles that don't exist in the player's world.
  382. if(vehicleid == OBJECTIVE_VEHICLE_BLUE) {
  383. if(gTeam[forplayerid] == TEAM_GREEN) {
  384. SetVehicleParamsForPlayer(OBJECTIVE_VEHICLE_BLUE,forplayerid,1,1); // objective; locked
  385. }
  386. else if(gTeam[forplayerid] == TEAM_BLUE) {
  387. SetVehicleParamsForPlayer(OBJECTIVE_VEHICLE_BLUE,forplayerid,1,0); // objective; unlocked
  388. }
  389. }
  390. else if(vehicleid == OBJECTIVE_VEHICLE_GREEN) {
  391. if(gTeam[forplayerid] == TEAM_BLUE) {
  392. SetVehicleParamsForPlayer(OBJECTIVE_VEHICLE_GREEN,forplayerid,1,1); // objective; locked
  393. }
  394. else if(gTeam[forplayerid] == TEAM_GREEN) {
  395. SetVehicleParamsForPlayer(OBJECTIVE_VEHICLE_GREEN,forplayerid,1,0); // objective; unlocked
  396. }
  397. }
  398. return 1;
  399. //printf("GameMode: VehicleStreamIn(%d,%d)",vehicleid,forplayerid);
  400. }
  401. //---------------------------------
  402. public OnVehicleStreamOut(vehicleid, forplayerid)
  403. {
  404. return 1;
  405. //printf("GameMode: VehicleStreamOut(%d,%d)",vehicleid,forplayerid);
  406. }
  407. //---------------------------------
  408. public OnPlayerUpdate(playerid)
  409. {
  410. if(!IsPlayerConnected(playerid)) return 0;
  411. if(IsPlayerNPC(playerid)) return 1;
  412. if(GetPlayerState(playerid) == PLAYER_STATE_SPECTATING) {
  413. if(GetPVarInt(playerid, "LastDeathTick") == 0) {
  414. TogglePlayerSpectating(playerid, 0);
  415. return 1;
  416. }
  417. // Allow respawn after an arbitrary time has passed
  418. if(GetTickCount() - GetPVarInt(playerid, "LastDeathTick") > (ALLOW_RESPAWN_AFTER_N_SECONDS * 1000)) {
  419. TogglePlayerSpectating(playerid, 0);
  420. return 1;
  421. }
  422. HandleSpectating(playerid);
  423. return 1;
  424. }
  425. // Check the resupply huts
  426. if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) {
  427. if(IsPlayerInRangeOfPoint(playerid, 2.5, 2140.83, -235.13, 7.13) || IsPlayerInRangeOfPoint(playerid, 2.5, 2318.73, 590.96, 6.75)) {
  428. DoResupply(playerid);
  429. }
  430. }
  431. return 1;
  432. }
  433. //---------------------------------
  434. PlaySoundForAll(soundid, Float:x, Float:y, Float:z)
  435. {
  436. for (new i=0; i<MAX_PLAYERS; i++)
  437. {
  438. if (IsPlayerConnected(i))
  439. {
  440. PlayerPlaySound(i, soundid, x, y, z);
  441. }
  442. }
  443. }
  444. //---------------------------------
  445. CreateMapObject(modelid, Float:fX, Float:fY, Float:fZ, Float:fRX, Float:fRY, Float:fRZ)
  446. {
  447. return CreateObject(modelid, fX, fY, fZ, fRX, fRY, fRZ, 500.0);
  448. }
  449. //---------------------------------
  450. RemoveNeededBuildingsForPlayer(playerid)
  451. {
  452. if(GetPVarInt(playerid,"BuildingsRemoved") == 0) {
  453. RemoveBuildingForPlayer(playerid, 9090, 2317.0859, 572.2656, -20.9688, 10.0);
  454. RemoveBuildingForPlayer(playerid, 9091, 2317.0859, 572.2656, -20.9688, 10.0);
  455. RemoveBuildingForPlayer(playerid, 13483, 2113.5781, -96.7344, 0.9844, 0.25);
  456. RemoveBuildingForPlayer(playerid, 12990, 2113.5781, -96.7344, 0.9844, 0.25);
  457. RemoveBuildingForPlayer(playerid, 935, 2119.8203, -84.4063, -0.0703, 0.25);
  458. RemoveBuildingForPlayer(playerid, 1369, 2104.0156, -105.2656, 1.7031, 0.25);
  459. RemoveBuildingForPlayer(playerid, 935, 2122.3750, -83.3828, 0.4609, 0.25);
  460. RemoveBuildingForPlayer(playerid, 935, 2119.5313, -82.8906, -0.1641, 0.25);
  461. RemoveBuildingForPlayer(playerid, 935, 2120.5156, -79.0859, 0.2188, 0.25);
  462. RemoveBuildingForPlayer(playerid, 935, 2119.4688, -69.7344, 0.2266, 0.25);
  463. RemoveBuildingForPlayer(playerid, 935, 2119.4922, -73.6172, 0.1250, 0.25);
  464. RemoveBuildingForPlayer(playerid, 935, 2117.8438, -67.8359, 0.1328, 0.25);
  465. SetPVarInt(playerid,"BuildingsRemoved",1);
  466. }
  467. }
  468. //---------------------------------
  469. SpectatePlayer(playerid, specplayerid)
  470. {
  471. if(GetPlayerState(specplayerid) == PLAYER_STATE_ONFOOT) {
  472. if(GetPVarInt(playerid, "SpectateMode") != SPECTATE_MODE_PLAYER) {
  473. PlayerSpectatePlayer(playerid, specplayerid);
  474. SetPVarInt(playerid, "SpectateMode", SPECTATE_MODE_PLAYER);
  475. }
  476. }
  477. else if( GetPlayerState(specplayerid) == PLAYER_STATE_DRIVER ||
  478. GetPlayerState(specplayerid) == PLAYER_STATE_PASSENGER )
  479. {
  480. if(GetPVarInt(playerid, "SpectateMode") != SPECTATE_MODE_VEHICLE) {
  481. PlayerSpectateVehicle(playerid, GetPlayerVehicleID(specplayerid));
  482. SetPVarInt(playerid, "SpectateMode", SPECTATE_MODE_VEHICLE);
  483. }
  484. }
  485. }
  486. //---------------------------------
  487. SpectateFixedPosition(playerid)
  488. {
  489. if(gTeam[playerid] == TEAM_GREEN) {
  490. SetPlayerCameraPos(playerid, 2221.5820, -273.9985, 61.7806);
  491. SetPlayerCameraLookAt(playerid, 2220.9978, -273.1861, 61.4606);
  492. }
  493. else {
  494. SetPlayerCameraPos(playerid, 2274.8467, 591.3257, 30.1311);
  495. SetPlayerCameraLookAt(playerid, 2275.0503, 590.3463, 29.9460);
  496. }
  497. }
  498. //---------------------------------
  499. HandleSpectating(playerid)
  500. {
  501. new LastKillerId = GetPVarInt(playerid, "LastKillerId");
  502. // Make sure the killer player is still active in the world
  503. if( IsPlayerConnected(LastKillerId) &&
  504. (GetPlayerState(LastKillerId) == PLAYER_STATE_ONFOOT ||
  505. GetPlayerState(LastKillerId) == PLAYER_STATE_DRIVER ||
  506. GetPlayerState(LastKillerId) == PLAYER_STATE_PASSENGER) )
  507. {
  508. SpectatePlayer(playerid, LastKillerId);
  509. SetPVarInt(playerid, "SpectateState", SPECTATE_STATE_PLAYER);
  510. }
  511. else
  512. {
  513. // Else switch to the fixed position camera
  514. if(GetPVarInt(playerid, "SpectateState") != SPECTATE_STATE_FIXED) {
  515. SpectateFixedPosition(playerid);
  516. SetPVarInt(playerid, "SpectateState", SPECTATE_STATE_FIXED);
  517. }
  518. }
  519. }
  520. //---------------------------------
  521. DoResupply(playerid)
  522. {
  523. new iLastResupplyTime = GetPVarInt(playerid, "LastResupply");
  524. if(iLastResupplyTime == 0 || (GetTickCount() - iLastResupplyTime) > 30000) {
  525. SetPVarInt(playerid, "LastResupply", GetTickCount());
  526. ResetPlayerWeapons(playerid);
  527. GivePlayerWeapon(playerid,31,100);
  528. GivePlayerWeapon(playerid,29,200);
  529. GivePlayerWeapon(playerid,34,10);
  530. SetPlayerHealth(playerid, 100.0);
  531. SetPlayerArmour(playerid, 100.0);
  532. GameTextForPlayer(playerid,"Resupplied", 2000, 5);
  533. PlayerPlaySound(playerid, 1150, 0.0, 0.0, 0.0);
  534. }
  535. }
  536. //---------------------------------