Bulletje

Untitled

Jan 24th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.38 KB | None | 0 0
  1. /*
  2. Script by: Bullet
  3. Map by: Bullet
  4. Mission Base: Capture The Flag
  5. Mission Type: Capture The Flag
  6. Mission Type ID: 6
  7. */
  8. //==============================================================================
  9. // Includes
  10. //==============================================================================
  11. #include <a_samp>
  12. #include <crashdetect>
  13. #include <float>
  14. #include <fixes2>
  15.  
  16. #include "..\filterscripts\MM\stuff\defines"
  17. #include "..\filterscripts\MM\stuff\serverkeymsg"
  18.  
  19. //==============================================================================
  20. // Defines
  21. //==============================================================================
  22.  
  23. #define MISSION_NAME "Mine Wars"
  24. #define Health 99.0
  25. #define VEHICLE_HEALTH 999.0
  26. #define TEAM_ATTACK_NAME "Cowboys"
  27. #define TEAM_DEFEND_NAME "Workers"
  28. #define CP_POS 393.4844,4033.3633,9.4901
  29. #define CP_SIZE 3.0
  30. #define TEAM_DEFEND_CAPTURE 329.9418,3971.8276,14.0544
  31. #define TEAM_ATTACK_CAPTURE 421.6885,4089.8411,5.2357
  32. #define MAX_MAP_OBJECTS 63
  33. #define CLASS_POSTION 1566.2374,-3066.1609,5.2656
  34. #define CLASS_CAMERA 1575.1250,-3066.3704,5.2656
  35. #define CLASS_FACING_AGNLE 266.8701
  36. #define OBJ_NAME "Diamond"
  37. #define OBJ_ID 1559
  38. #define SPAWN_PROTECTION true
  39.  
  40. //==============================================================================
  41. // Per mission functions
  42. //==============================================================================
  43.  
  44. enum ped_enum
  45. {
  46. TeamID,
  47. Skin,
  48. Float:SpawnX,
  49. Float:SpawnY,
  50. Float:SpawnZ,
  51. Float:SpawnAngle,
  52. SpawnInterior,
  53. VirtualWorld,
  54. Weapon1,
  55. Ammo1,
  56. Weapon2,
  57. Ammo2,
  58. Weapon3,
  59. Ammo3,
  60. };
  61.  
  62. new PedInfo[][ped_enum] = {
  63. {TEAM_ATTACK, 30, 421.6885,4089.8411,5.2357,245.4168,0,0,WEAPON_DEAGLE,210,WEAPON_AK47,500,WEAPON_GRENADE,5},
  64. {TEAM_DEFEND, 287,329.9418,3971.8276,14.0544,71.8283,0,0,WEAPON_DEAGLE,210,WEAPON_M4,500,WEAPON_GRENADE,5}
  65. };
  66.  
  67. #if MAX_MAP_OBJECTS != 0
  68. new Object[MAX_MAP_OBJECTS];
  69.  
  70. CreateMap()
  71. {
  72. Object[0] = CreateObject(11696,389.7102100,4055.4184600,5.0000000,0.0000000,0.0000000,0.0000000); //
  73. Object[1] = CreateObject(744,416.2350800,4088.9177200,3.6876600,0.0000000,0.0000000,50.0000000); //
  74. Object[2] = CreateObject(744,418.1844800,4092.5312500,3.3391800,0.0000000,0.0000000,58.0000000); //
  75. Object[3] = CreateObject(744,334.6243600,3968.6020500,13.0915900,0.0000000,0.0000000,-33.0000000); //
  76. Object[4] = CreateObject(744,335.2477100,3972.0681200,12.8975000,0.0000000,0.0000000,-33.0000000); //
  77. Object[5] = CreateObject(2936,409.3111300,4030.9980500,27.7112600,0.0000000,0.0000000,0.0000000); //
  78. Object[6] = CreateObject(2936,414.3909300,4031.0017100,27.7112600,0.0000000,0.0000000,0.0000000); //
  79. Object[7] = CreateObject(2936,421.4023700,4027.6796900,27.1719200,0.0000000,0.0000000,0.0000000); //
  80. Object[8] = CreateObject(2936,421.0508700,4035.2319300,27.1719200,0.0000000,0.0000000,0.0000000); //
  81. Object[9] = CreateObject(2936,404.9755200,4031.6892100,28.3711200,0.0000000,0.0000000,0.0000000); //
  82. Object[10] = CreateObject(2936,398.3390200,4036.0874000,28.4310100,0.0000000,0.0000000,0.0000000); //
  83. Object[11] = CreateObject(2936,405.7936400,4035.7717300,28.4909200,0.0000000,0.0000000,0.0000000); //
  84. Object[12] = CreateObject(2936,394.6105700,4032.4885300,27.7578300,0.0000000,0.0000000,0.0000000); //
  85. Object[13] = CreateObject(2936,387.3726200,4037.0744600,28.0806300,0.0000000,0.0000000,0.0000000); //
  86. Object[14] = CreateObject(2936,384.8745100,4031.6486800,27.6379900,0.0000000,0.0000000,0.0000000); //
  87. Object[15] = CreateObject(2936,374.4191000,4031.7106900,27.1788700,0.0000000,0.0000000,0.0000000); //
  88. Object[16] = CreateObject(2936,375.5055200,4038.7756300,27.1788700,0.0000000,0.0000000,0.0000000); //
  89. Object[17] = CreateObject(2936,385.6531100,4025.2939500,26.3162400,0.0000000,0.0000000,0.0000000); //
  90. Object[18] = CreateObject(2936,378.1670800,4025.0485800,25.8150600,0.0000000,0.0000000,0.0000000); //
  91. Object[19] = CreateObject(2936,388.2245800,4017.8886700,21.9005700,0.0000000,0.0000000,0.0000000); //
  92. Object[20] = CreateObject(2936,382.8870800,4017.6086400,21.9005700,0.0000000,0.0000000,0.0000000); //
  93. Object[21] = CreateObject(2936,396.6984600,4025.4943800,26.9160100,0.0000000,0.0000000,0.0000000); //
  94. Object[22] = CreateObject(2936,398.0264000,4022.4123500,25.4084500,0.0000000,0.0000000,0.0000000); //
  95. Object[23] = CreateObject(2936,391.7637900,4028.3559600,27.6371100,0.0000000,0.0000000,0.0000000); //
  96. Object[24] = CreateObject(2936,371.6201500,4028.2412100,27.1788700,0.0000000,0.0000000,0.0000000); //
  97. Object[25] = CreateObject(2936,370.8545200,4022.1367200,24.6416400,0.0000000,0.0000000,0.0000000); //
  98. Object[26] = CreateObject(2936,364.9714400,4025.9677700,25.9469700,0.0000000,0.0000000,0.0000000); //
  99. Object[27] = CreateObject(2936,370.9244100,4015.0666500,18.2966300,0.0000000,0.0000000,0.0000000); //
  100. Object[28] = CreateObject(2936,379.3250700,4014.5268600,16.9324600,0.0000000,0.0000000,0.0000000); //
  101. Object[29] = CreateObject(2936,442.8230000,4030.3327600,19.9380900,0.0000000,0.0000000,0.0000000); //
  102. Object[30] = CreateObject(2936,421.5344200,4017.1218300,19.9380900,0.0000000,0.0000000,0.0000000); //
  103. Object[31] = CreateObject(2936,414.4274900,4023.0278300,25.5998000,0.0000000,0.0000000,0.0000000); //
  104. Object[32] = CreateObject(2936,421.4812000,4022.5737300,25.3660800,0.0000000,0.0000000,0.0000000); //
  105. Object[33] = CreateObject(2936,436.8805800,4007.6936000,34.4646600,0.0000000,0.0000000,0.0000000); //
  106. Object[34] = CreateObject(2936,417.6314100,4017.9480000,21.3593700,0.0000000,0.0000000,0.0000000); //
  107. Object[35] = CreateObject(2936,386.2952000,4046.3584000,20.9764500,0.0000000,0.0000000,0.0000000); //
  108. Object[36] = CreateObject(2936,404.3441800,4046.7661100,21.2013500,0.0000000,0.0000000,0.0000000); //
  109. Object[37] = CreateObject(2936,415.2910500,4043.7507300,19.0575200,0.0000000,0.0000000,0.0000000); //
  110. Object[38] = CreateObject(2936,414.3179900,4041.5219700,23.2484600,0.0000000,0.0000000,0.0000000); //
  111. Object[39] = CreateObject(2936,428.5527000,4036.8481400,23.2484600,0.0000000,0.0000000,0.0000000); //
  112. Object[40] = CreateObject(899,436.1568900,4025.3403300,3.0000000,0.0000000,0.0000000,0.0000000); //
  113. Object[41] = CreateObject(899,422.3172300,4026.0483400,3.0000000,0.0000000,0.0000000,-30.0000000); //
  114. Object[42] = CreateObject(899,423.3393900,4037.9108900,3.0000000,0.0000000,0.0000000,-30.0000000); //
  115. Object[43] = CreateObject(899,402.5417200,4040.8576700,3.0000000,0.0000000,0.0000000,-30.0000000); //
  116. Object[44] = CreateObject(899,406.1453600,4023.2724600,3.0199200,0.0000000,0.0000000,-30.0000000); //
  117. Object[45] = CreateObject(899,388.9830000,4025.8439900,3.0000000,0.0000000,0.0000000,-30.0000000); //
  118. Object[46] = CreateObject(899,388.1668700,4037.2131300,3.0000000,0.0000000,0.0000000,-30.0000000); //
  119. Object[47] = CreateObject(899,374.4233400,4022.0502900,3.0000000,0.0000000,0.0000000,120.0000000); //
  120. Object[48] = CreateObject(899,370.8603800,4039.9008800,3.0000000,0.0000000,0.0000000,120.0000000); //
  121. Object[49] = CreateObject(899,352.3211400,4035.7771000,3.0000000,0.0000000,0.0000000,120.0000000); //
  122. Object[50] = CreateObject(899,354.3014800,4017.4646000,3.0000000,0.0000000,0.0000000,120.0000000); //
  123. Object[51] = CreateObject(899,337.0445300,4019.9873000,3.0000000,0.0000000,0.0000000,120.0000000); //
  124. Object[52] = CreateObject(899,336.9896200,4037.8071300,3.0000000,0.0000000,0.0000000,120.0000000); //
  125. Object[53] = CreateObject(899,435.3073700,4009.3430200,3.0000000,0.0000000,0.0000000,-30.0000000); //
  126. Object[54] = CreateObject(899,392.9835500,4014.7258300,3.0199200,0.0000000,0.0000000,-30.0000000); //
  127. Object[55] = CreateObject(3865,372.6852700,4023.5202600,9.9230100,0.0000000,0.0000000,0.0000000); //
  128. Object[56] = CreateObject(3865,353.8850400,4033.0817900,9.9230100,0.0000000,0.0000000,0.0000000); //
  129. Object[57] = CreateObject(3865,394.6105000,4033.2678200,9.9230000,0.0000000,0.0000000,-66.0000000); //
  130. Object[58] = CreateObject(3865,429.8086900,4032.0449200,8.6218000,-10.0000000,0.0000000,-33.0000000); //
  131. Object[59] = CreateObject(3865,405.7546100,4021.6103500,9.9230000,0.0000000,0.0000000,40.0000000); //
  132. Object[60] = CreateObject(899,439.9010300,4021.5190400,3.0000000,0.0000000,0.0000000,0.0000000); //
  133. Object[61] = CreateObject(899,423.2704200,4013.1130400,3.0000000,0.0000000,0.0000000,-30.0000000); //
  134. Object[62] = CreateObject(3865,366.7371200,4036.0654300,8.7915600,13.2600000,-34.2599900,-87.7200200); //
  135. }
  136. #endif
  137.  
  138. //==============================================================================
  139. // Basic vars
  140. //==============================================================================
  141.  
  142. new bool:MissionStarted;
  143. new bool:ObjectiveStarted;
  144. new bool:MissionCancelled;
  145.  
  146. native IsValidVehicle(vehicleid);
  147.  
  148. enum teamdata
  149. {
  150. Kills,
  151. Name[32],
  152. Members,
  153. Points
  154. };
  155.  
  156. enum playerdata
  157. {
  158. UserName[MAX_PLAYER_NAME],
  159. bool:TeamChosen,
  160. TeamSelection,
  161. PlayerClassID,
  162. PlayerPointsTaken,
  163. Counted
  164. };
  165.  
  166. new Team[2][teamdata];
  167. new PlayerMissionInfo[MAX_PLAYERS][playerdata];
  168.  
  169. new Collecting= INVALID_PLAYER_ID;
  170. new ObjectiveObj;
  171.  
  172. //==============================================================================
  173. // Basic script
  174. //==============================================================================
  175.  
  176. main()
  177. {
  178. print("----------------------------------");
  179. print(" Mission: "MISSION_NAME" started.");
  180. print("----------------------------------\n");
  181. }
  182.  
  183. public OnGameModeInit()
  184. {
  185. MissionStarted= true;
  186.  
  187. format(Team[TEAM_DEFEND][Name],32,"%s",TEAM_DEFEND_NAME);
  188. format(Team[TEAM_ATTACK][Name],32,"%s",TEAM_ATTACK_NAME);
  189.  
  190. if(CallRemoteFunction("GetCurrentMissionCJWalk","")) UsePlayerPedAnims();
  191.  
  192. #if MAX_MAP_OBJECTS != 0
  193. CreateMap();
  194. #endif
  195.  
  196. for(new i=0; i<sizeof(PedInfo); i++)AddPlayerClassEx(PedInfo[i][TeamID],PedInfo[i][Skin],PedInfo[i][SpawnX],PedInfo[i][SpawnY],PedInfo[i][SpawnZ],PedInfo[i][SpawnAngle],0,0,0,0,0,0);
  197.  
  198. for(new i=0; i<MAX_VEHICLES; i++) if(IsValidVehicle(i)) SetVehicleHealth(i,VEHICLE_HEALTH);
  199. for(new i=0; i<MAX_PLAYERS; i++) PlayerMissionInfo[i][TeamSelection]= NO_TEAM;
  200.  
  201. ObjectiveObj=CreateObject(19306,CP_POS+2.0,0.0,0.0,0.0);
  202. Collecting=INVALID_PLAYER_ID;
  203.  
  204. SetTimer("StartMissionFunc",3000,false);
  205. return 1;
  206. }
  207.  
  208. FUNCTION StartMissionFunc()
  209. {
  210. CallRemoteFunction("StartMission","");
  211. ObjectiveStarted= true;
  212. return 1;
  213. }
  214.  
  215. public OnGameModeExit()
  216. {
  217. #if MAX_MAP_OBJECTS != 0
  218. for(new i=0;i<MAX_MAP_OBJECTS;i++) DestroyObject(Object[i]);
  219. #endif
  220. DestroyObject(ObjectiveObj);
  221. return 1;
  222. }
  223.  
  224. public OnPlayerDisconnect(playerid)
  225. {
  226. if(PlayerMissionInfo[playerid][TeamSelection] != NO_TEAM && PlayerMissionInfo[playerid][TeamChosen])
  227. {
  228. Team[PlayerMissionInfo[playerid][TeamSelection]][Members] --;
  229. PlayerMissionInfo[playerid][TeamChosen] = false;
  230. }
  231. new string[70];
  232. if(Collecting == playerid)
  233. {
  234. if(!MissionStarted) return 1;
  235. format(string,sizeof(string),"%s has dropped the "OBJ_NAME"",PlayerMissionInfo[Collecting][UserName]);
  236. CallRemoteFunction("ShowInfoBox", "iisi", -1, Collecting,string,0);
  237. new Float:x,Float:y,Float:z;
  238. GetPlayerPos(playerid,x,y,z);
  239. for(new i=0,j=GetPlayerPoolSize(); i<=j; i++)
  240. {
  241. if(!IsPlayerConnected(i)) continue;
  242. if(!CallRemoteFunction("GetAliveState","i",i)) continue;
  243. SetPlayerCheckpoint(i,x,y,z,3.0);
  244. }
  245. RemovePlayerAttachedObject(playerid,0);
  246. ObjectiveObj=CreateObject(OBJ_ID,x,y,z+2.0,0.0,0.0,0.0);
  247. Collecting=INVALID_PLAYER_ID;
  248. }
  249. return 1;
  250. }
  251.  
  252. public OnPlayerRequestClass(playerid,classid)
  253. {
  254. SetPlayerPos(playerid,CLASS_POSTION);
  255. SetPlayerCameraPos(playerid,CLASS_CAMERA);
  256. SetPlayerCameraLookAt(playerid,CLASS_POSTION);
  257. SetPlayerFacingAngle(playerid,CLASS_FACING_AGNLE);
  258.  
  259. CallRemoteFunction("TdmHide","i",playerid);
  260. CallRemoteFunction("ShowClassSelection","ddsddd",playerid, PedInfo[classid][TeamID],Team[PedInfo[classid][TeamID]][Name], PedInfo[classid][Weapon1], PedInfo[classid][Weapon2], PedInfo[classid][Weapon3]);
  261.  
  262. if(PlayerMissionInfo[playerid][Counted] && PlayerMissionInfo[playerid][TeamSelection] != NO_TEAM)
  263. {
  264. Team[PlayerMissionInfo[playerid][TeamSelection]][Members]--;
  265. PlayerMissionInfo[playerid][Counted] = false;
  266. }
  267. PlayerMissionInfo[playerid][TeamSelection] = PedInfo[classid][TeamID];
  268. PlayerMissionInfo[playerid][PlayerClassID]=classid;
  269. return 1;
  270. }
  271.  
  272. public OnPlayerRequestSpawn(playerid)
  273. {
  274. new opp_team = (PlayerMissionInfo[playerid][TeamSelection] == 1)? 0:1;
  275. if(Team[PlayerMissionInfo[playerid][TeamSelection]][Members] > Team[opp_team][Members])
  276. {
  277. CallRemoteFunction("ShowInfoBox", "iisi", playerid, -1,"This Team is full, choose another!",100);
  278. return 0;
  279. }
  280.  
  281. return 1;
  282. }
  283.  
  284. public OnPlayerSpawn(playerid)
  285. {
  286. SetPlayerHealth(playerid,Health);
  287. CallRemoteFunction("UpdateAliveState","ii",playerid,1);
  288. CallRemoteFunction("TdmShow","i",playerid);
  289. CallRemoteFunction("TdmUpdate","sssdd",OBJ_NAME,Team[TEAM_DEFEND][Name],Team[TEAM_ATTACK][Name],Team[TEAM_DEFEND][Points],Team[TEAM_ATTACK][Points]);
  290. new string[124];
  291. if(CallRemoteFunction("GetSpectateStatus","d",playerid)) return CallRemoteFunction("SpecOffAdmin","d",playerid);
  292. if(CallRemoteFunction("GetJailedStatus","d",playerid)) CallRemoteFunction("SetJailed","d",playerid);
  293. else
  294. {
  295. SetPlayerPos(playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][SpawnX],PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][SpawnY],PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][SpawnZ]);
  296. SetPlayerFacingAngle(playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][SpawnAngle]);
  297. SetPlayerInterior(playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][SpawnInterior]);
  298. SetPlayerVirtualWorld(playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][VirtualWorld]);
  299. CallRemoteFunction("GivePlayerWeaponEx","ddd",playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Weapon1],PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Ammo1]);
  300. CallRemoteFunction("GivePlayerWeaponEx","ddd",playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Weapon2],PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Ammo2]);
  301. CallRemoteFunction("GivePlayerWeaponEx","ddd",playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Weapon3],PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Ammo3]);
  302. if(!PlayerMissionInfo[playerid][Counted])
  303. {
  304. PlayerMissionInfo[playerid][Counted] = true;
  305. Team[PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][TeamID]][Members]++;
  306. format(string,sizeof(string),"You have chosen team %s, Your mission is to capture &s.",Team[PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][TeamID]][Name],OBJ_NAME);
  307. CallRemoteFunction("ShowInfoBox", "iisi", playerid, -1,string,100);
  308. if(PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][TeamID] == TEAM_ATTACK) format(string,sizeof(string),"~r~~h~Stop ~w~%s.",Team[TEAM_DEFEND][Name]);
  309. else format(string,sizeof(string),"~r~~h~Stop ~w~%s.",Team[TEAM_ATTACK][Name]);
  310. CallRemoteFunction("ShowInfoText", "iisi", playerid, -1,string,100);
  311. }
  312. if(Collecting == INVALID_PLAYER_ID) SetPlayerCheckpoint(playerid,CP_POS,3.0);
  313. else
  314. {
  315. if(PlayerMissionInfo[Collecting][TeamSelection] == TEAM_ATTACK) SetPlayerCheckpoint(playerid,TEAM_ATTACK_CAPTURE,3.0);
  316. else SetPlayerCheckpoint(playerid,TEAM_DEFEND_CAPTURE,3.0);
  317. }
  318. }
  319. SetPlayerTeam(playerid,PlayerMissionInfo[playerid][TeamSelection]);
  320. if(PlayerMissionInfo[playerid][TeamSelection] == TEAM_ATTACK) SetPlayerColor(playerid,COLOR_TEAM_ATTACK);
  321. else SetPlayerColor(playerid,COLOR_TEAM_DEFEND);
  322. TogglePlayerControllable(playerid,true);
  323. #if SPAWN_PROTECTION == true
  324. CallRemoteFunction("SetSpawnProtection","df",playerid,Health);
  325. #endif
  326. return 1;
  327. }
  328.  
  329. public OnPlayerDeath(playerid, killerid, reason)
  330. {
  331. if(killerid != INVALID_PLAYER_ID && PlayerMissionInfo[playerid][TeamSelection] != NO_TEAM && MissionStarted)
  332. {
  333. Team[PlayerMissionInfo[killerid][TeamSelection]][Kills]++;
  334. }
  335. new string[70];
  336. if(Collecting == playerid)
  337. {
  338. if(!MissionStarted) return 1;
  339. format(string,sizeof(string),"%s has dropped the "OBJ_NAME"",PlayerMissionInfo[Collecting][UserName]);
  340. CallRemoteFunction("ShowInfoBox", "iisi", -1, Collecting,string,0);
  341. new Float:x,Float:y,Float:z;
  342. GetPlayerPos(playerid,x,y,z);
  343. for(new i=0,j=GetPlayerPoolSize(); i<=j; i++)
  344. {
  345. if(!IsPlayerConnected(i)) continue;
  346. if(!CallRemoteFunction("GetAliveState","i",i)) continue;
  347. DisablePlayerCheckpoint(i);
  348. SetPlayerCheckpoint(i,x,y,z,3.0);
  349. }
  350. RemovePlayerAttachedObject(playerid,0);
  351. ObjectiveObj=CreateObject(OBJ_ID,x,y,z+2.0,0.0,0.0,0.0);
  352. Collecting=INVALID_PLAYER_ID;
  353. }
  354. CallRemoteFunction("UpdateAliveState","ii",playerid,0);
  355. return 1;
  356. }
  357.  
  358.  
  359. public OnPlayerEnterCheckpoint(playerid)
  360. {
  361. new string[128];
  362. if(!MissionStarted || MissionCancelled) return 1;
  363. if(IsPlayerInAnyVehicle(playerid)) return 1;
  364. if(Collecting == INVALID_PLAYER_ID)
  365. {
  366. DisablePlayerCheckpoint(Collecting);
  367. Collecting= playerid;
  368. CallRemoteFunction("ShowInfoBox", "iisi", Collecting, -1,"Deliver this "OBJ_NAME" to your base",0);
  369. format(string,sizeof(string),"%s is capturing "OBJ_NAME" for %s",PlayerMissionInfo[Collecting][UserName],Team[PlayerMissionInfo[Collecting][TeamSelection]][Name]);
  370. CallRemoteFunction("ShowInfoBox", "iisi", -1, Collecting,string,0);
  371. SetPlayerColor(playerid,COLOR_SERVER);
  372. DisablePlayerCheckpoint(Collecting);
  373. for(new i=0,j=GetPlayerPoolSize(); i<=j; i++)
  374. {
  375. if(!IsPlayerConnected(i)) continue;
  376. if(!CallRemoteFunction("GetAliveState","i",i)) continue;
  377. DisablePlayerCheckpoint(i);
  378. if(PlayerMissionInfo[Collecting][TeamSelection] == TEAM_ATTACK) SetPlayerCheckpoint(i,TEAM_ATTACK_CAPTURE,3.0);
  379. else SetPlayerCheckpoint(i,TEAM_DEFEND_CAPTURE,3.0);
  380. }
  381. DestroyObject(ObjectiveObj);
  382. SetPlayerAttachedObject(playerid, 0, OBJ_ID, 6, -0.006000,0.010000,0.918000,0.000000,0.000000,0.000000,1.000000,1.000000,1.000000);
  383. }
  384. else if(Collecting == playerid)
  385. {
  386. format(string,sizeof(string),"%s has captured the "OBJ_NAME" for %s",PlayerMissionInfo[Collecting][UserName],Team[PlayerMissionInfo[Collecting][TeamSelection]][Name]);
  387. CallRemoteFunction("ShowInfoBox", "iisi", -1, Collecting,string,0);
  388. PlayerMissionInfo[playerid][PlayerPointsTaken]++;
  389. CallRemoteFunction("PlayerMissionStats","dd",playerid,7);
  390. Team[PlayerMissionInfo[playerid][TeamSelection]][Points]++;
  391. SetPlayerScore(playerid,PlayerMissionInfo[playerid][PlayerPointsTaken]);
  392. CallRemoteFunction("TdmUpdate","sssdd",OBJ_NAME,Team[TEAM_DEFEND][Name],Team[TEAM_ATTACK][Name],Team[TEAM_DEFEND][Points],Team[TEAM_ATTACK][Points]);
  393. if(PlayerMissionInfo[playerid][TeamSelection] == TEAM_ATTACK) SetPlayerColor(playerid,COLOR_TEAM_ATTACK);
  394. else SetPlayerColor(playerid,COLOR_TEAM_DEFEND);
  395. for(new i=0,j=GetPlayerPoolSize(); i<=j; i++)
  396. {
  397. if(!IsPlayerConnected(i)) continue;
  398. if(!CallRemoteFunction("GetAliveState","i",i)) continue;
  399. DisablePlayerCheckpoint(i);
  400. SetPlayerCheckpoint(i,CP_POS,3.0);
  401. }
  402. RemovePlayerAttachedObject(playerid,0);
  403. ObjectiveObj=CreateObject(OBJ_ID,CP_POS+2.0,0.0,0.0,0.0);
  404. Collecting=INVALID_PLAYER_ID;
  405. }
  406. return 1;
  407. }
  408.  
  409. FUNCTION EndTheMission()
  410. {
  411. if(!MissionStarted) return 1;
  412. MissionStarted= false;
  413. if(!MissionCancelled)
  414. {
  415. new string[256];
  416. new amount= 10000;
  417. new winning_team;
  418. if(Team[TEAM_DEFEND][Points] == Team[TEAM_ATTACK][Points]) { winning_team = 2; }
  419. else if(Team[TEAM_DEFEND][Points] > Team[TEAM_ATTACK][Points]) { winning_team = 0; }
  420. else { winning_team = 1; }
  421.  
  422. if(winning_team != 2)
  423. {
  424. amount =amount+(Team[winning_team][Points]*60);
  425. format(string,sizeof(string),""SERVER_KEY_MSG" %s has won the capture the "OBJ_NAME"! Reward: $%d",Team[winning_team][Name],amount);
  426. CallRemoteFunction("IRC_SendMessage","ss",string,IRC_SERVER_COLOR);
  427. SendClientMessageToAll(COLOR_SERVER,string);
  428. format(string,sizeof(string),""SERVER_KEY_MSG" You have received $%i because your team has won capture the "OBJ_NAME"!",amount);
  429. for(new i=0,j=GetPlayerPoolSize(); i <= j; i++)
  430. {
  431. if(PlayerMissionInfo[i][TeamSelection] == winning_team && PlayerMissionInfo[i][Counted])
  432. {
  433. PlayerPlaySound(i,3200,0,0,0);
  434. SendClientMessage(i,COLOR_SERVER,string);
  435. CallRemoteFunction("GivePlayerCash","ii",i,amount);
  436. CallRemoteFunction("PlayerMissionStats","dd",i,0);
  437. CallRemoteFunction("PlayerMissionStats","dd",i,6);
  438. }
  439. if(PlayerMissionInfo[i][TeamSelection] != winning_team && PlayerMissionInfo[i][Counted])
  440. {
  441. PlayerPlaySound(i,17004,0,0,0);
  442. GameTextForPlayer(i,"~R~MISSION FAILED~w~!",3000,3);
  443. CallRemoteFunction("PlayerMissionStats","dd",i,1);
  444. }
  445. }
  446. }
  447. else
  448. {
  449. PlaySoundForAll(1058);
  450. format(string,sizeof(string),""SERVER_KEY_MSG" IT'S A DRAW! No team has won capture the "OBJ_NAME".");
  451. SendClientMessageToAll(COLOR_SERVER,string);
  452. CallRemoteFunction("IRC_SendMessage","ss",string,IRC_SERVER_COLOR);
  453. for(new i=0,j=GetPlayerPoolSize(); i <= j; i++) if(IsPlayerConnected(i) && PlayerMissionInfo[i][Counted]) CallRemoteFunction("PlayerMissionStats","dd",i,2);
  454. }
  455. }
  456. else
  457. {
  458. PlaySoundForAll(1058);
  459. SendClientMessageToAll(COLOR_SERVER,""SERVER_KEY_MSG" The mission has been cancelled.");
  460. CallRemoteFunction("IRC_SendMessage","ss",""SERVER_KEY_MSG" The mission has been cancelled.",IRC_SERVER_COLOR);
  461. CallRemoteFunction("ShowInfoBox", "iisi", -1, -1,"The mission has been cancelled.",0);
  462. GameTextForAll("~R~MISSION CANCELLED~w~!",3000,3);
  463. }
  464. return 1;
  465. }
  466.  
  467. //==============================================================================
  468. // Mission functions
  469. //==============================================================================
  470.  
  471. PlaySoundForAll(sound)
  472. {
  473. for (new i=0,j=GetPlayerPoolSize(); i <=j ; i++)
  474. {
  475. if(IsPlayerConnected(i)) PlayerPlaySound(i,sound,0,0,0);
  476. }
  477. }
  478.  
  479. //==============================================================================
  480. // Important functions required
  481. //==============================================================================
  482.  
  483. FUNCTION OnPlayerNameRecieve(playerid,name[])
  484. {
  485. format(PlayerMissionInfo[playerid][UserName],MAX_PLAYER_NAME,"%s",name);
  486. return 1;
  487. }
  488.  
  489.  
  490. FUNCTION CancelTheMission()
  491. {
  492. MissionCancelled= true;
  493. return 1;
  494. }
  495.  
  496. FUNCTION MissionObjectiveStarted() return ObjectiveStarted;
  497.  
  498. FUNCTION OnPlayerSpectateObjective(playerid)
  499. {
  500. SetPlayerCameraPos(playerid, CP_POS + 2.5);
  501. SetPlayerCameraLookAt(playerid, CP_POS);
  502. SetPlayerPos(playerid, CP_POS - 5);
  503.  
  504. SetPlayerColor(playerid, (PlayerMissionInfo[playerid][TeamSelection] == TEAM_ATTACK) ? COLOR_TEAM_ATTACK_INV : COLOR_TEAM_DEFEND_INV);
  505. return 1;
  506. }
Advertisement
Add Comment
Please, Sign In to add comment