1
0

rivershell.pwn 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. //---------------------------------------------------------
  2. //
  3. // Rivershell by Kye - 2006
  4. //
  5. // Updated 2009 for SA-MP 0.3
  6. //
  7. //---------------------------------------------------------
  8. #include <a_samp>
  9. #include <core>
  10. #include <float>
  11. // Global stuff and defines for our gamemode.
  12. static gTeam[MAX_PLAYERS]; // Tracks the team assignment for each player
  13. #define OBJECTIVE_VEHICLE_GREEN 2
  14. #define OBJECTIVE_VEHICLE_BLUE 1
  15. #define TEAM_GREEN 1
  16. #define TEAM_BLUE 2
  17. #define OBJECTIVE_COLOR 0xE2C063FF
  18. #define TEAM_GREEN_COLOR 0x77CC77FF
  19. #define TEAM_BLUE_COLOR 0x7777DDFF
  20. #define CAPS_TO_WIN 3
  21. new gObjectiveReached = 0; // Stops the winner logic reentering itself.
  22. new gObjectiveGreenPlayer=(-1); // Tracks which green player has the vehicle.
  23. new gObjectiveBluePlayer=(-1); // Tracks which blue player has the vehicle.
  24. // number of times the vehicle has been captured by each team
  25. new gGreenTimesCapped=0;
  26. new gBlueTimesCapped=0;
  27. // forward declarations for the PAWN compiler (not really needed, but there for the sake of clarity)
  28. forward SetPlayerToTeamColor(playerid);
  29. forward SetupPlayerForClassSelection(playerid);
  30. forward SetPlayerTeamFromClass(playerid,classid);
  31. forward ExitTheGameMode();
  32. //---------------------------------------------------------
  33. main()
  34. {
  35. print("\n----------------------------------");
  36. print(" Rivershell by Kye 2006\n");
  37. print("----------------------------------\n");
  38. }
  39. //---------------------------------------------------------
  40. public SetPlayerToTeamColor(playerid)
  41. {
  42. if(gTeam[playerid] == TEAM_GREEN) {
  43. SetPlayerColor(playerid,TEAM_GREEN_COLOR); // green
  44. } else if(gTeam[playerid] == TEAM_BLUE) {
  45. SetPlayerColor(playerid,TEAM_BLUE_COLOR); // blue
  46. }
  47. }
  48. //---------------------------------------------------------
  49. public SetupPlayerForClassSelection(playerid)
  50. {
  51. // Set the player's orientation when they're selecting a class.
  52. SetPlayerPos(playerid,1984.4445,157.9501,55.9384);
  53. SetPlayerCameraPos(playerid,1984.4445,160.9501,55.9384);
  54. SetPlayerCameraLookAt(playerid,1984.4445,157.9501,55.9384);
  55. SetPlayerFacingAngle(playerid,0.0);
  56. }
  57. //---------------------------------------------------------
  58. public SetPlayerTeamFromClass(playerid,classid)
  59. {
  60. // Set their team number based on the class they selected.
  61. if(classid == 0 || classid == 1) {
  62. gTeam[playerid] = TEAM_GREEN;
  63. } else if(classid == 2 || classid == 3) {
  64. gTeam[playerid] = TEAM_BLUE;
  65. }
  66. }
  67. //---------------------------------------------------------
  68. public ExitTheGameMode()
  69. {
  70. PlaySoundForAll(1186, 0.0, 0.0, 0.0); // Stops the music
  71. //printf("Exiting Game Mode");
  72. GameModeExit();
  73. }
  74. //---------------------------------------------------------
  75. public OnPlayerStateChange(playerid, newstate, oldstate)
  76. {
  77. new vehicleid;
  78. if(newstate == PLAYER_STATE_DRIVER)
  79. {
  80. vehicleid = GetPlayerVehicleID(playerid);
  81. if(gTeam[playerid] == TEAM_GREEN && vehicleid == OBJECTIVE_VEHICLE_GREEN)
  82. { // It's the objective vehicle
  83. SetPlayerColor(playerid,OBJECTIVE_COLOR);
  84. GameTextForPlayer(playerid,"~w~Take the ~y~boat ~w~back to the ~r~spawn!",3000,5);
  85. SetPlayerCheckpoint(playerid,1982.6150,-220.6680,-0.2432,7.0);
  86. gObjectiveGreenPlayer = playerid;
  87. }
  88. if(gTeam[playerid] == TEAM_BLUE && vehicleid == OBJECTIVE_VEHICLE_BLUE)
  89. { // It's the objective vehicle
  90. SetPlayerColor(playerid,OBJECTIVE_COLOR);
  91. GameTextForPlayer(playerid,"~w~Take the ~y~boat ~w~back to the ~r~spawn!",3000,5);
  92. SetPlayerCheckpoint(playerid,2328.2935,531.8324,0.0094,7.0);
  93. gObjectiveBluePlayer = playerid;
  94. }
  95. }
  96. else if(newstate == PLAYER_STATE_ONFOOT)
  97. {
  98. if(playerid == gObjectiveGreenPlayer) {
  99. gObjectiveGreenPlayer = (-1);
  100. SetPlayerToTeamColor(playerid);
  101. DisablePlayerCheckpoint(playerid);
  102. }
  103. if(playerid == gObjectiveBluePlayer) {
  104. gObjectiveBluePlayer = (-1);
  105. SetPlayerToTeamColor(playerid);
  106. DisablePlayerCheckpoint(playerid);
  107. }
  108. }
  109. return 1;
  110. }
  111. //---------------------------------------------------------
  112. public OnGameModeInit()
  113. {
  114. SetGameModeText("Rivershell");
  115. ShowPlayerMarkers(1);
  116. ShowNameTags(1);
  117. SetWorldTime(17);
  118. // GREEN CLASSES
  119. AddPlayerClass(162,1980.0054,-266.6487,2.9653,348.9788,0,0,31,400,29,400);
  120. AddPlayerClass(157,1980.0054,-266.6487,2.9653,348.9788,0,0,31,400,29,400);
  121. // BLUE CLASSES
  122. AddPlayerClass(154,2359.2703,540.5911,1.7969,180.6476,0,0,31,400,29,400);
  123. AddPlayerClass(138,2294.0413,541.8565,1.7944,188.6283,0,0,31,400,29,400);
  124. // OBJECTIVE VEHICLES
  125. AddStaticVehicle(453,2057.0154,-236.5598,-0.2621,359.4377,114,1); // gr reefer
  126. AddStaticVehicle(453,2381.9685,532.4496,0.2574,183.2029,79,7); // b reefer
  127. // GREEN VEHICLES
  128. AddStaticVehicle(473,2023.5109,-246.4161,-0.1514,351.0038,114,1); // gr dhin
  129. AddStaticVehicle(473,1949.2490,-259.5398,-0.2794,13.3247,114,1); // gr ding2fix
  130. AddStaticVehicle(473,2003.7256,-248.4939,-0.2243,5.1752,114,1); // gr ding
  131. AddStaticVehicle(473,1982.4832,-252.4811,-0.3006,358.3696,114,1); // gr ding
  132. AddStaticVehicle(473,1927.7894,-249.3088,-0.2893,320.7715,114,1); // gr ding
  133. AddStaticVehicle(473,1907.6969,-230.4202,-0.2585,306.0136,114,1); // gr ding
  134. AddStaticVehicle(487,1913.0819,-376.2350,21.4819,350.9412,114,1); // gr mav
  135. // BLUE VEHICLES
  136. AddStaticVehicle(473,2289.7571,518.4412,-0.2167,178.8301,79,7); // b ding
  137. AddStaticVehicle(473,2294.3599,519.1021,-0.1391,177.1416,79,7); // b ding
  138. AddStaticVehicle(473,2298.8411,518.4229,-0.2333,181.1228,79,7); // b ding
  139. AddStaticVehicle(473,2369.9839,519.0364,-0.3190,187.9187,79,7); // b ding
  140. AddStaticVehicle(473,2359.9417,519.1055,-0.2271,183.8014,79,7); // b ding
  141. AddStaticVehicle(473,2351.4617,519.1046,-0.1172,182.8623,79,7); // b ding
  142. AddStaticVehicle(487,2324.4399,573.1667,7.9578,177.6699,79,7); // b mav
  143. return 1;
  144. }
  145. //---------------------------------------------------------
  146. public OnPlayerConnect(playerid)
  147. {
  148. SetPlayerColor(playerid,0x888888FF);
  149. GameTextForPlayer(playerid,"~r~SA-MP:~w~Rivershell",2000,5);
  150. return 1;
  151. }
  152. //---------------------------------------------------------
  153. public OnPlayerRequestClass(playerid, classid)
  154. {
  155. SetupPlayerForClassSelection(playerid);
  156. SetPlayerTeamFromClass(playerid,classid);
  157. if(classid == 0 || classid == 1) {
  158. GameTextForPlayer(playerid,"~g~GREEN ~w~TEAM",1000,5);
  159. } else if(classid == 2 || classid == 3) {
  160. GameTextForPlayer(playerid,"~b~BLUE ~w~TEAM",1000,5);
  161. }
  162. return 1;
  163. }
  164. //---------------------------------------------------------
  165. public OnPlayerSpawn(playerid)
  166. {
  167. SetPlayerToTeamColor(playerid);
  168. if(gTeam[playerid] == TEAM_GREEN) {
  169. SetPlayerWorldBounds(playerid,2444.4185,1687.5696,631.2963,-454.9898);
  170. GameTextForPlayer(playerid,
  171. "Defend the ~g~GREEN ~w~team's ~y~Reefer~n~~w~Capture the ~b~BLUE ~w~team's ~y~Reefer",
  172. 6000,5);
  173. }
  174. else if(gTeam[playerid] == TEAM_BLUE) {
  175. SetPlayerWorldBounds(playerid,2444.4185,1687.5696,631.2963,-454.9898);
  176. GameTextForPlayer(playerid,
  177. "Defend the ~b~BLUE ~w~team's ~y~Reefer~n~~w~Capture the ~g~GREEN ~w~team's ~y~Reefer",
  178. 6000,5);
  179. }
  180. return 1;
  181. }
  182. //---------------------------------------------------------
  183. public OnPlayerEnterCheckpoint(playerid)
  184. {
  185. new playervehicleid = GetPlayerVehicleID(playerid);
  186. if(gObjectiveReached) return;
  187. if(playervehicleid == OBJECTIVE_VEHICLE_GREEN && gTeam[playerid] == TEAM_GREEN)
  188. { // Green OBJECTIVE REACHED.
  189. gGreenTimesCapped++;
  190. SetPlayerScore(playerid,GetPlayerScore(playerid)+5);
  191. if(gGreenTimesCapped==CAPS_TO_WIN) {
  192. GameTextForAll("~g~GREEN ~w~team wins!",3000,5);
  193. gObjectiveReached = 1; PlaySoundForAll(1185, 0.0, 0.0, 0.0);
  194. SetTimer("ExitTheGameMode", 6000, 0); // Set up a timer to exit this mode.
  195. } else {
  196. GameTextForAll("~g~GREEN ~w~team captured the ~y~boat!",3000,5);
  197. SetVehicleToRespawn(OBJECTIVE_VEHICLE_GREEN);
  198. }
  199. return;
  200. }
  201. else if(playervehicleid == OBJECTIVE_VEHICLE_BLUE && gTeam[playerid] == TEAM_BLUE)
  202. { // Blue OBJECTIVE REACHED.
  203. gBlueTimesCapped++;
  204. SetPlayerScore(playerid,GetPlayerScore(playerid)+5);
  205. if(gBlueTimesCapped==CAPS_TO_WIN) {
  206. GameTextForAll("~b~BLUE ~w~team wins!",3000,5);
  207. gObjectiveReached = 1; PlaySoundForAll(1185, 0.0, 0.0, 0.0);
  208. SetTimer("ExitTheGameMode", 6000, 0); // Set up a timer to exit this mode.
  209. } else {
  210. GameTextForAll("~b~BLUE ~w~team captured the ~y~boat!",3000,5);
  211. SetVehicleToRespawn(OBJECTIVE_VEHICLE_BLUE);
  212. }
  213. return;
  214. }
  215. }
  216. //---------------------------------------------------------
  217. public OnPlayerDeath(playerid, killerid, reason)
  218. {
  219. if(killerid == INVALID_PLAYER_ID) {
  220. SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);
  221. } else {
  222. if(gTeam[killerid] != gTeam[playerid]) {
  223. // Valid kill
  224. SendDeathMessage(killerid,playerid,reason);
  225. SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
  226. }
  227. else {
  228. // Team kill
  229. SendDeathMessage(killerid,playerid,reason);
  230. }
  231. }
  232. return 1;
  233. }
  234. //---------------------------------
  235. public OnVehicleStreamIn(vehicleid, forplayerid)
  236. {
  237. // Note for SA-MP 0.3:
  238. // As the vehicle streams in, player team dependant params are applied. They can't be
  239. // applied to vehicles that don't exist in the player's world.
  240. if(vehicleid == OBJECTIVE_VEHICLE_BLUE) {
  241. if(gTeam[forplayerid] == TEAM_GREEN) {
  242. SetVehicleParamsForPlayer(OBJECTIVE_VEHICLE_BLUE,forplayerid,1,1); // objective; locked
  243. }
  244. else if(gTeam[forplayerid] == TEAM_BLUE) {
  245. SetVehicleParamsForPlayer(OBJECTIVE_VEHICLE_BLUE,forplayerid,1,0); // objective; unlocked
  246. }
  247. }
  248. else if(vehicleid == OBJECTIVE_VEHICLE_GREEN) {
  249. if(gTeam[forplayerid] == TEAM_BLUE) {
  250. SetVehicleParamsForPlayer(OBJECTIVE_VEHICLE_GREEN,forplayerid,1,1); // objective; locked
  251. }
  252. else if(gTeam[forplayerid] == TEAM_GREEN) {
  253. SetVehicleParamsForPlayer(OBJECTIVE_VEHICLE_GREEN,forplayerid,1,0); // objective; unlocked
  254. }
  255. }
  256. return 1;
  257. //printf("GameMode: VehicleStreamIn(%d,%d)",vehicleid,forplayerid);
  258. }
  259. //---------------------------------
  260. public OnVehicleStreamOut(vehicleid, forplayerid)
  261. {
  262. return 1;
  263. //printf("GameMode: VehicleStreamOut(%d,%d)",vehicleid,forplayerid);
  264. }
  265. //---------------------------------
  266. PlaySoundForAll(soundid, Float:x, Float:y, Float:z)
  267. {
  268. for (new i=0; i<MAX_PLAYERS; i++)
  269. {
  270. if (IsPlayerConnected(i))
  271. {
  272. PlayerPlaySound(i, soundid, x, y, z);
  273. }
  274. }
  275. }
  276. //---------------------------------