Bulletje

Untitled

Mar 17th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.86 KB | None | 0 0
  1. /*
  2. Script by: Bullet
  3. Map by: MiD
  4. Mission Base: Bombing
  5. Mission Type: Checkpoint bombing
  6. Mission Type ID: 1
  7. */
  8. //==============================================================================
  9. // Includes
  10. //==============================================================================
  11. #include <a_samp>
  12. #include <crashdetect>
  13. #include <float>
  14.  
  15. #include "..\filterscripts\MM\stuff\defines"
  16. #include "..\filterscripts\MM\stuff\serverkeymsg"
  17.  
  18. //==============================================================================
  19. // Defines
  20. //==============================================================================
  21.  
  22. #define MISSION_NAME "Evening Sun"
  23. #define Health 99.0
  24. #define OBJ_NAME "The Fuel Ship"
  25. #define CP_POS -2145.6235,-253.9246,40.71
  26. #define CP_SIZE 3.0
  27. #define VEHICLE_HEALTH 999.0
  28. #define CLASS_POSTION -2175.7952,-231.4047,36.5156
  29. #define CLASS_CAMERA -2181.8398,-230.1611,36.5156
  30. #define CLASS_FACING_AGNLE 80.2331
  31. #define TEAM_DEFEND_NAME "Nang Boys"
  32. #define TEAM_ATTACK_NAME "Cops"
  33. #define MAX_MAP_OBJECTS 8
  34. #define PLACING_TIME 7
  35. #define SPAWN_PROTECTION true
  36.  
  37. //==============================================================================
  38. // Per mission functions
  39. //==============================================================================
  40.  
  41. enum skindata
  42. {
  43. TeamID,
  44. SkinID,
  45. Float:SpawnX,
  46. Float:SpawnY,
  47. Float:SpawnZ,
  48. Float:SpawnAngle,
  49. SpawnInterior,
  50. VirtualWorld,
  51. Weapon1,
  52. Ammo1,
  53. Weapon2,
  54. Ammo2,
  55. Weapon3,
  56. Ammo3,
  57. };
  58.  
  59. new const SkinData[][skindata] = {
  60. {TEAM_ATTACK, 280, -1862.19995, -144.89999, 11.5,85.1686,0,0,WEAPON_M4,500,WEAPON_DEAGLE,210,WEAPON_SHOTGUN,50},
  61. {TEAM_DEFEND, 122,-1474.90002, 151.89999, 18.4,88.8383,0,0,WEAPON_AK47,30,WEAPON_CHINSAW,1,WEAPON_SHOTGSPA,210},
  62.  
  63. };
  64.  
  65. new const Float:ExplosionsInfo[][3] = {
  66. {-1593.0496,35.4267,24.6390},
  67. {-1581.7583,25.1551,24.6390},
  68. {-1591.5850,27.0092,33.6390},
  69. {-1615.1014,15.9942,23.6390},
  70. {-1626.4165,2.6474,16.6390},
  71. {-1543.2272,61.5388,16.6390},
  72. {-1543.6031,96.9205,16.6390},
  73. {-1503.0050,106.3370,16.6390},
  74. {-1486.5426,136.9788,16.6390}
  75. };
  76.  
  77.  
  78. #if MAX_MAP_OBJECTS != 0
  79. new Object[MAX_MAP_OBJECTS];
  80.  
  81. CreateMap()
  82. {
  83. AddStaticVehicleEx(443,-1638.4000200,64.7000000,4.3000000,316.0000000,34,25,15); //Packer
  84. AddStaticVehicleEx(578,-1604.1999500,49.5000000,4.3000000,136.0000000,245,245,15); //DFT-30
  85. AddStaticVehicleEx(486,-1550.5000000,63.6000000,17.6000000,134.0000000,245,245,15); //Dozer
  86. AddStaticVehicleEx(413,-1561.9000200,76.9000000,17.5000000,44.0000000,100,104,15); //Pony
  87. AddStaticVehicleEx(413,-1487.5999800,132.6000100,17.5000000,133.9950000,100,104,15); //Pony
  88. AddStaticVehicleEx(413,-1571.5999800,137.3000000,3.7000000,135.9950000,100,104,15); //Pony
  89. AddStaticVehicleEx(435,-1597.1999500,50.1000000,18.0000000,314.0000000,245,245,15); //Trailer 1
  90. AddStaticVehicleEx(450,-1594.9000200,116.3000000,4.2000000,136.0000000,245,245,15); //Trailer 2
  91. AddStaticVehicleEx(414,-1599.4000200,84.4000000,3.7000000,136.0000000,63,62,15); //Mule
  92. AddStaticVehicleEx(414,-1533.0000000,88.7000000,17.5000000,46.0000000,63,62,15); //Mule
  93. AddStaticVehicleEx(422,-1551.5000000,93.2000000,17.4000000,316.0000000,71,53,15); //Bobcat
  94. AddStaticVehicleEx(422,-1577.5999800,28.0000000,17.4000000,326.0000000,71,53,15); //Bobcat
  95. AddStaticVehicleEx(422,-1672.0000000,40.8000000,3.6000000,145.9970000,71,53,15); //Bobcat
  96. AddStaticVehicleEx(456,-1530.8000500,161.1000100,3.8000000,130.0000000,93,126,15); //Yankee
  97. AddStaticVehicleEx(498,-1663.6999500,3.7000000,3.8000000,40.0000000,81,84,15); //Boxville
  98. AddStaticVehicleEx(406,-1704.6999500,15.3000000,6.0000000,316.0000000,245,245,15); //Dumper
  99. AddStaticVehicleEx(514,-1590.1999500,56.8000000,18.0000000,314.0000000,37,37,15); //Tanker
  100. AddStaticVehicleEx(514,-1601.1999500,109.8000000,4.3000000,133.9950000,37,37,15); //Tanker
  101. AddStaticVehicleEx(422,-1527.8000500,125.6000000,3.6000000,325.9920000,71,53,15); //Bobcat
  102. AddStaticVehicleEx(597,-1876.8000500,-147.6000100,11.8000000,80.0000000,15,15,15); //Police Car (SFPD)
  103. AddStaticVehicleEx(599,-1851.5000000,-136.8000000,12.3000000,90.0000000,15,15,15); //Police Ranger
  104. AddStaticVehicleEx(427,-1852.5999800,-129.1000100,12.1000000,90.0000000,15,15,15); //Enforcer
  105. AddStaticVehicleEx(523,-1850.3000500,-141.8000000,11.6000000,90.0000000,15,15,15); //HPV1000
  106. AddStaticVehicleEx(427,-1882.0000000,-167.7000000,12.2000000,0.0000000,15,15,15); //Enforcer
  107. AddStaticVehicleEx(597,-1876.8000500,-153.8000000,11.8000000,79.9970000,15,15,15); //Police Car (SFPD)
  108. AddStaticVehicleEx(597,-1876.5000000,-150.7000000,11.8000000,79.9970000,15,15,15); //Police Car (SFPD)
  109. AddStaticVehicleEx(597,-1851.3000500,-144.2000000,11.8000000,89.9970000,15,15,15); //Police Car (SFPD)
  110. AddStaticVehicleEx(597,-1851.5999800,-133.0000000,11.8000000,89.9950000,15,15,15); //Police Car (SFPD)
  111. AddStaticVehicleEx(523,-1850.3000500,-140.0000000,11.6000000,90.0000000,15,15,15); //HPV1000
  112. AddStaticVehicleEx(599,-1870.0999800,-127.1000000,12.3000000,80.0000000,15,15,15); //Police Ranger
  113. AddStaticVehicleEx(599,-1853.4000200,-169.8000000,9.6000000,269.9970000,15,15,15); //Police Ranger
  114. AddStaticVehicleEx(599,-1840.5999800,-110.4000000,6.0000000,269.9950000,15,15,15); //Police Ranger
  115. AddStaticVehicleEx(597,-1871.3000500,-142.8000000,11.8000000,359.9950000,15,15,15); //Police Car (SFPD)
  116. AddStaticVehicleEx(597,-1885.0999800,-133.1000100,12.2000000,339.9950000,15,15,15); //Police Car (SFPD)
  117. AddStaticVehicleEx(597,-1882.4000200,-123.8000000,12.7000000,349.9940000,15,15,15); //Police Car (SFPD)
  118. AddStaticVehicleEx(597,-1887.5000000,-142.8999900,11.8000000,349.9910000,15,15,15); //Police Car (SFPD)
  119. AddStaticVehicleEx(597,-1888.5999800,-158.3000000,11.8000000,359.9910000,15,15,15); //Police Car (SFPD)
  120. AddStaticVehicleEx(597,-1870.8000500,-178.1000100,9.2000000,269.9890000,15,15,15); //Police Car (SFPD)
  121. AddStaticVehicleEx(597,-1864.4000200,-178.1000100,9.2000000,269.9890000,15,15,15); //Police Car (SFPD)
  122.  
  123. Object[0] = CreateObject(8615,-1600.9000200,44.3000000,23.8000000,0.0000000,0.0000000,135.0000000); //
  124. Object[1] = CreateObject(8614,-1582.4000200,25.9000000,24.3000000,0.0000000,0.0000000,135.0000000); //
  125. Object[2] = CreateObject(14410,-1608.0999800,40.2000000,22.3000000,0.0000000,0.0000000,314.0000000); //
  126. Object[3] = CreateObject(14410,-1613.0999800,35.3000000,17.3000000,0.0000000,0.0000000,313.9950000); //
  127. Object[4] = CreateObject(14410,-1586.6999500,18.9000000,22.3000000,0.0000000,0.0000000,313.9950000); //
  128. Object[5] = CreateObject(14410,-1592.0000000,13.8000000,17.3000000,0.0000000,0.0000000,313.9950000); //
  129. Object[6] = CreateObject(14410,-1590.5000000,40.0000000,19.4000000,0.0000000,0.0000000,134.9950000); //
  130. Object[7] = CreateObject(14410,-1587.6999500,37.2000000,19.4000000,0.0000000,0.0000000,134.9950000); //
  131. }
  132. #endif
  133.  
  134.  
  135. //==============================================================================
  136. // Basic vars
  137. //==============================================================================
  138.  
  139. new bool:MissionStarted;
  140. new bool:ObjectiveStarted;
  141. new bool:MissionCancelled;
  142.  
  143. new bool:ObjectivePlaced;
  144.  
  145. native IsValidVehicle(vehicleid);
  146.  
  147. enum obj
  148. {
  149. ObjectiveName[30],
  150. BeingPlaced,
  151. ObjectiveTimer,
  152. ProgressTimer,
  153. ProgressCount,
  154. Count
  155. };
  156.  
  157. enum teamdata
  158. {
  159. Name[32],
  160. Members,
  161. Kills
  162. };
  163.  
  164. enum playerdata
  165. {
  166. UserName[MAX_PLAYER_NAME],
  167. bool:TeamChosen,
  168. TeamSelection,
  169. PlayerClassID
  170. };
  171.  
  172. new Team[2][teamdata];
  173. new PlayerMissionInfo[MAX_PLAYERS][playerdata];
  174. new ObjectiveInfo[obj];
  175.  
  176. new MaxExplosions;
  177. new FlashTimer;
  178.  
  179. //==============================================================================
  180. // Basic script
  181. //==============================================================================
  182.  
  183. main()
  184. {
  185. print("----------------------------------");
  186. print(" Mission: "MISSION_NAME" started.");
  187. print("----------------------------------\n");
  188. }
  189.  
  190. public OnGameModeInit()
  191. {
  192. MissionStarted= true;
  193. format(Team[TEAM_DEFEND][Name],32,"%s",TEAM_DEFEND_NAME);
  194. format(Team[TEAM_ATTACK][Name],32,"%s",TEAM_ATTACK_NAME);
  195.  
  196. format(ObjectiveInfo[ObjectiveName],sizeof(ObjectiveInfo[ObjectiveName]),"%s",OBJ_NAME);
  197.  
  198. CallRemoteFunction("CreateBombingTD","d",PLACING_TIME*10);
  199.  
  200. MaxExplosions= sizeof(ExplosionsInfo);
  201. ObjectivePlaced= false;
  202. ObjectiveInfo[BeingPlaced]=-1;
  203.  
  204. #if MAX_MAP_OBJECTS != 0
  205. CreateMap();
  206. #endif
  207.  
  208. for(new i=0; i<sizeof(SkinData); i++)
  209. {
  210. AddPlayerClassEx(SkinData[i][TeamID],SkinData[i][SkinID],SkinData[i][SpawnX],SkinData[i][SpawnY],SkinData[i][SpawnZ],SkinData[i][SpawnAngle],0,0,0,0,0,0);
  211. }
  212.  
  213. for(new i=0; i<MAX_PLAYERS; i++) PlayerMissionInfo[i][TeamSelection]= NO_TEAM;
  214.  
  215. for(new i=0; i<MAX_VEHICLES; i++) if(IsValidVehicle(i)) SetVehicleHealth(i,VEHICLE_HEALTH);
  216.  
  217. if(CallRemoteFunction("GetCurrentMissionCJWalk","")) UsePlayerPedAnims();
  218. SetTimer("StartMissionFunc",3000,false);
  219. return 1;
  220. }
  221.  
  222. FUNCTION StartMissionFunc()
  223. {
  224. CallRemoteFunction("StartMission","");
  225. ObjectiveStarted= true;
  226. return 1;
  227. }
  228.  
  229. public OnGameModeExit()
  230. {
  231. #if MAX_MAP_OBJECTS != 0
  232. for(new i=0;i<MAX_MAP_OBJECTS;i++) DestroyObject(Object[i]);
  233. #endif
  234. for(new i=0; i<MAX_VEHICLES; i++)
  235. {
  236. DestroyVehicle(i);
  237. }
  238. return 1;
  239. }
  240.  
  241. public OnPlayerDisconnect(playerid)
  242. {
  243. if(PlayerMissionInfo[playerid][TeamChosen])
  244. {
  245. Team[PlayerMissionInfo[playerid][TeamSelection]][Members] --;
  246. PlayerMissionInfo[playerid][TeamChosen]=false;
  247. }
  248. return 1;
  249. }
  250.  
  251. public OnPlayerRequestClass(playerid,classid)
  252. {
  253. SetPlayerPos(playerid,CLASS_POSTION);
  254. SetPlayerCameraPos(playerid,CLASS_CAMERA);
  255. SetPlayerCameraLookAt(playerid,CLASS_POSTION);
  256. SetPlayerFacingAngle(playerid,CLASS_FACING_AGNLE);
  257.  
  258. CallRemoteFunction("ShowClassSelection","iisiii",playerid, SkinData[classid][TeamID],Team[SkinData[classid][TeamID]][Name], SkinData[classid][Weapon1], SkinData[classid][Weapon2], SkinData[classid][Weapon3]);
  259.  
  260. if(PlayerMissionInfo[playerid][TeamChosen])
  261. {
  262. PlayerMissionInfo[playerid][TeamChosen] = false;
  263. Team[PlayerMissionInfo[playerid][TeamSelection]][Members]--;
  264. }
  265.  
  266. PlayerMissionInfo[playerid][TeamSelection] = SkinData[classid][TeamID];
  267. PlayerMissionInfo[playerid][PlayerClassID]=classid;
  268. return 1;
  269. }
  270.  
  271. public OnPlayerRequestSpawn(playerid)
  272. {
  273. new opp_team = (PlayerMissionInfo[playerid][TeamSelection] == 1)? 0:1;
  274. if(Team[PlayerMissionInfo[playerid][TeamSelection]][Members] > Team[opp_team][Members])
  275. {
  276. CallRemoteFunction("ShowInfoBox", "iisi", playerid, -1, "This Team is full, choose another!",0);
  277. return 0;
  278. }
  279. return 1;
  280. }
  281.  
  282.  
  283. public OnPlayerSpawn(playerid)
  284. {
  285. new string[124];
  286. CallRemoteFunction("UpdateAliveState","ii",playerid,1);
  287. if(CallRemoteFunction("GetSpectateStatus","d",playerid)) return CallRemoteFunction("SpecOffAdmin","d",playerid);
  288. if(CallRemoteFunction("GetJailedStatus","d",playerid)) CallRemoteFunction("SetJailed","d",playerid);
  289. else
  290. {
  291. SetPlayerPos(playerid,SkinData[PlayerMissionInfo[playerid][PlayerClassID]][SpawnX],SkinData[PlayerMissionInfo[playerid][PlayerClassID]][SpawnY],SkinData[PlayerMissionInfo[playerid][PlayerClassID]][SpawnZ]);
  292. SetPlayerInterior(playerid,SkinData[PlayerMissionInfo[playerid][PlayerClassID]][SpawnInterior]);
  293. SetPlayerFacingAngle(playerid,SkinData[PlayerMissionInfo[playerid][PlayerClassID]][SpawnAngle]);
  294. SetPlayerVirtualWorld(playerid,SkinData[PlayerMissionInfo[playerid][PlayerClassID]][VirtualWorld]);
  295. if(!PlayerMissionInfo[playerid][TeamChosen])
  296. {
  297. Team[PlayerMissionInfo[playerid][TeamSelection]][Members]++;
  298. PlayerMissionInfo[playerid][TeamChosen] = true;
  299. if(PlayerMissionInfo[playerid][TeamSelection] == TEAM_ATTACK)
  300. {
  301. format(string,sizeof(string),"You are a %s, your mission is to destroy the %s.",Team[TEAM_ATTACK][Name],ObjectiveInfo[ObjectiveName]);
  302. CallRemoteFunction("ShowInfoBox", "iisi", playerid, -1,string,2000);
  303. format(string,sizeof(string),"%s will try to stop you, eliminate them!.",Team[TEAM_DEFEND][Name]);
  304. CallRemoteFunction("ShowInfoBox", "iisi", playerid, -1, string,4000);
  305. format(string,sizeof(string),"Destroy the ~y~%s~w~!",ObjectiveInfo[ObjectiveName]);
  306. CallRemoteFunction("ShowInfoText", "iisi", playerid, -1, string,1000);
  307. }
  308. else
  309. {
  310. format(string,sizeof(string),"You are a %s, your mission is to protect the %s from %s.",Team[TEAM_DEFEND][Name],ObjectiveInfo[ObjectiveName],Team[TEAM_ATTACK][Name]);
  311. CallRemoteFunction("ShowInfoBox", "iisi", playerid, -1,string,2000);
  312. format(string,sizeof(string),"Protect the ~y~%s~w~!.",ObjectiveInfo[ObjectiveName]);
  313. CallRemoteFunction("ShowInfoText", "iisi", playerid, -1, string,1000);
  314. }
  315. }
  316. CallRemoteFunction("GivePlayerWeaponEx","ddd",playerid,SkinData[PlayerMissionInfo[playerid][PlayerClassID]][Weapon1],SkinData[PlayerMissionInfo[playerid][PlayerClassID]][Ammo1]);
  317. CallRemoteFunction("GivePlayerWeaponEx","ddd",playerid,SkinData[PlayerMissionInfo[playerid][PlayerClassID]][Weapon2],SkinData[PlayerMissionInfo[playerid][PlayerClassID]][Ammo2]);
  318. CallRemoteFunction("GivePlayerWeaponEx","ddd",playerid,SkinData[PlayerMissionInfo[playerid][PlayerClassID]][Weapon3],SkinData[PlayerMissionInfo[playerid][PlayerClassID]][Ammo3]);
  319. }
  320. SetPlayerTeam(playerid,PlayerMissionInfo[playerid][TeamSelection]);
  321. if(PlayerMissionInfo[playerid][TeamSelection] == TEAM_ATTACK) SetPlayerColor(playerid,COLOR_TEAM_ATTACK);
  322. else SetPlayerColor(playerid,COLOR_TEAM_DEFEND);
  323.  
  324. SetPlayerHealth(playerid,Health);
  325. #if SPAWN_PROTECTION == true
  326. CallRemoteFunction("SetSpawnProtection","df",playerid,Health);
  327. #endif
  328.  
  329. CallRemoteFunction("OnPlayerBombingData", "ii", playerid, 1);
  330.  
  331. SetPlayerCheckpoint(playerid,CP_POS,CP_SIZE);
  332. return 1;
  333. }
  334.  
  335. public OnPlayerDeath(playerid, killerid, reason)
  336. {
  337. new string[128];
  338. if(killerid != INVALID_PLAYER_ID)
  339. {
  340. SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
  341. Team[PlayerMissionInfo[killerid][TeamSelection]][Kills]++;
  342. }
  343. if(PlayerMissionInfo[playerid][TeamSelection] == TEAM_ATTACK)
  344. {
  345. if(!ObjectivePlaced && ObjectiveInfo[BeingPlaced] == playerid)
  346. {
  347. ObjectiveInfo[BeingPlaced]=-1;
  348. format(string,sizeof(string),"~y~%s ~w~has died while ~r~~h~planting~w~ the bomb.",PlayerMissionInfo[playerid][UserName]);
  349. CallRemoteFunction("ShowInfoText", "iisi", -1, playerid, string, 0);
  350. ObjectiveInfo[Count]=0;
  351. KillTimer(ObjectiveInfo[ObjectiveTimer]);
  352. ObjectiveInfo[ProgressCount]=0;
  353. KillTimer(ObjectiveInfo[ProgressTimer]);
  354. CallRemoteFunction("UpdateBombProgressBar", "d", 0);
  355. }
  356. }
  357. CallRemoteFunction("UpdateAliveState","ii",playerid,0);
  358. return 1;
  359. }
  360.  
  361. public OnPlayerEnterCheckpoint(playerid)
  362. {
  363. if(!MissionStarted || ObjectivePlaced) return 1;
  364. new string[128];
  365. if(PlayerMissionInfo[playerid][TeamSelection] == TEAM_ATTACK && !ObjectivePlaced)
  366. {
  367. if(ObjectiveInfo[BeingPlaced] != -1)
  368. {
  369. format(string,sizeof(string),"%s is already trying to place the bomb. Please wait!",PlayerMissionInfo[ObjectiveInfo[BeingPlaced]][UserName]);
  370. CallRemoteFunction("ShowInfoBox", "iisi", playerid, -1, string, 0);
  371. }
  372. else
  373. {
  374. ObjectiveInfo[BeingPlaced]=playerid;
  375. format(string,sizeof(string),"~y~%s~w~ is placing the bomb..!!",PlayerMissionInfo[playerid][UserName],playerid);
  376. CallRemoteFunction("ShowInfoText", "iisi", -1, playerid, string, 0);
  377. format(string,sizeof(string),"Wait in the checkpoint for %d seconds to place the bomb.",PLACING_TIME);
  378. CallRemoteFunction("ShowInfoBox", "iisi", playerid, -1, string, 0);
  379. ObjectiveInfo[Count]=0;
  380. ObjectiveInfo[ProgressCount]=0;
  381. CallRemoteFunction("UpdateBombProgressBar", "d", 0);
  382. ObjectiveInfo[ObjectiveTimer] = SetTimer("PlacingTimer",1000,true);
  383. ObjectiveInfo[ProgressTimer] = SetTimer("ProgressFillUP",100,true);
  384. }
  385. }
  386. else
  387. {
  388. if(ObjectiveInfo[BeingPlaced] != -1)
  389. {
  390. CallRemoteFunction("ShowInfoBox", "iisi", playerid, -1, "This is bomb placing sight, protect it.", 0);
  391. }
  392. else
  393. {
  394. format(string,sizeof(string),"%s is trying to place the bomb. Stop them!",PlayerMissionInfo[ObjectiveInfo[BeingPlaced]][UserName]);
  395. CallRemoteFunction("ShowInfoBox", "iisi", playerid, -1, string, 0);
  396. }
  397. }
  398. return 1;
  399. }
  400.  
  401. public OnPlayerLeaveCheckpoint(playerid)
  402. {
  403. if(!MissionStarted || ObjectivePlaced) return 1;
  404. new string[128];
  405. if(PlayerMissionInfo[playerid][TeamSelection] == TEAM_ATTACK && !ObjectivePlaced && ObjectiveInfo[BeingPlaced] == playerid)
  406. {
  407. ObjectiveInfo[BeingPlaced]=-1;
  408. format(string,sizeof(string),"~y~%s~w~ has left ~r~~h~planting~w~ the bomb.",PlayerMissionInfo[playerid][UserName],playerid);
  409. CallRemoteFunction("ShowInfoText", "iisi", -1, playerid, string, 0);
  410. ObjectiveInfo[Count]=0;
  411. KillTimer(ObjectiveInfo[ObjectiveTimer]);
  412. ObjectiveInfo[ProgressCount]=0;
  413. KillTimer(ObjectiveInfo[ProgressTimer]);
  414. CallRemoteFunction("UpdateBombProgressBar", "d", 0);
  415. }
  416. return 1;
  417. }
  418.  
  419. public OnVehicleSpawn(vehicleid)
  420. {
  421. SetVehicleHealth(vehicleid,VEHICLE_HEALTH);
  422. return 1;
  423. }
  424.  
  425. FUNCTION EndTheMission()
  426. {
  427. if(!MissionStarted) return 1;
  428. MissionStarted= false;
  429. if(!MissionCancelled)
  430. {
  431. new string[256];
  432. new amount= 10000;
  433. if(!ObjectivePlaced)
  434. {
  435. amount+=Team[TEAM_DEFEND][Kills]*100;
  436. format(string,sizeof(string),""SERVER_KEY_MSG" %s has won the mission, by successfully defending the %s. Reward: $%d",Team[TEAM_DEFEND][Name],ObjectiveInfo[ObjectiveName],amount);
  437. SendClientMessageToAll(COLOR_SERVER,string);
  438. CallRemoteFunction("IRC_SendMessage","ss",string,IRC_SERVER_COLOR);
  439. format(string,sizeof(string),""SERVER_KEY_MSG" You have received $%i because your team has won the mission!",amount);
  440. for(new i=0,j=GetPlayerPoolSize(); i <= j; i++)
  441. {
  442. if(!PlayerMissionInfo[i][TeamChosen]) continue;
  443. if(PlayerMissionInfo[i][TeamSelection] == TEAM_DEFEND)
  444. {
  445. PlayerPlaySound(i,3200,0,0,0);
  446. SendClientMessage(i,COLOR_TEAM_DEFEND,string);
  447. CallRemoteFunction("GivePlayerCash","ii",i,amount);
  448. CallRemoteFunction("PlayerMissionStats","dd",i,0);
  449. }
  450. if(PlayerMissionInfo[i][TeamSelection] != TEAM_DEFEND)
  451. {
  452. PlayerPlaySound(i,17004,0,0,0);
  453. GameTextForPlayer(i,"~R~MISSION FAILED~w~!",3000,3);
  454. CallRemoteFunction("PlayerMissionStats","dd",i,1);
  455. }
  456. }
  457. }
  458. else
  459. {
  460. amount+=Team[TEAM_ATTACK][Kills]*100;
  461. format(string,sizeof(string),""SERVER_KEY_MSG" %s (%d) placed the bomb to destroy %s's %s. %s's has won the mission. Reward: 1 Token.",PlayerMissionInfo[ObjectiveInfo[BeingPlaced]][UserName],ObjectiveInfo[BeingPlaced],Team[TEAM_DEFEND][Name],ObjectiveInfo[ObjectiveName]);
  462. SendClientMessageToAll(COLOR_SERVER,string);
  463. format(string,sizeof(string),""SERVER_KEY_MSG" %s have won the mission. Reward: $%d.",Team[TEAM_ATTACK][Name],amount);
  464. SendClientMessageToAll(COLOR_SERVER,string);
  465. CallRemoteFunction("IRC_SendMessage","ss",string,IRC_SERVER_COLOR);
  466. CallRemoteFunction("PlayerMissionStats","dd",ObjectiveInfo[BeingPlaced],8);
  467. CallRemoteFunction("GivePlayerToken","dd",ObjectiveInfo[BeingPlaced],1);
  468. format(string,sizeof(string),""SERVER_KEY_MSG" You have received $%i because your team has won the Team-Deathmatch!",amount);
  469. for(new i=0,j=GetPlayerPoolSize(); i <= j; i++)
  470. {
  471. if(!PlayerMissionInfo[i][TeamChosen]) continue;
  472. if(PlayerMissionInfo[i][TeamSelection] == TEAM_ATTACK)
  473. {
  474. PlayerPlaySound(i,3200,0,0,0);
  475. SendClientMessage(i,COLOR_TEAM_ATTACK,string);
  476. CallRemoteFunction("GivePlayerCash","ii",i,amount);
  477. CallRemoteFunction("PlayerMissionStats","dd",i,0);
  478. }
  479. if(PlayerMissionInfo[i][TeamSelection] != TEAM_ATTACK)
  480. {
  481. PlayerPlaySound(i,17004,0,0,0);
  482. GameTextForPlayer(i,"~R~MISSION FAILED~w~!",3000,3);
  483. CallRemoteFunction("PlayerMissionStats","dd",i,1);
  484. }
  485. }
  486. }
  487. }
  488. else
  489. {
  490. PlaySoundForAll(1058);
  491. SendClientMessageToAll(COLOR_SERVER,""SERVER_KEY_MSG" The mission has been cancelled.");
  492. CallRemoteFunction("IRC_SendMessage","ss",""SERVER_KEY_MSG" The mission has been cancelled.",IRC_SERVER_COLOR);
  493. CallRemoteFunction("ShowInfoBox", "iisi", -1, -1,"The mission has been cancelled.",0);
  494. GameTextForAll("~R~MISSION CANCELLED~w~!",3000,3);
  495. }
  496. return 1;
  497. }
  498.  
  499. //==============================================================================
  500. // Mission functions
  501. //==============================================================================
  502.  
  503. FUNCTION ProgressFillUP()
  504. {
  505. ObjectiveInfo[ProgressCount]++;
  506. CallRemoteFunction("UpdateBombProgressBar", "d", ObjectiveInfo[ProgressCount]);
  507. }
  508.  
  509. FUNCTION PlacingTimer()
  510. {
  511. if(!MissionStarted || ObjectivePlaced) return 1;
  512. if(ObjectiveInfo[BeingPlaced] == -1)
  513. {
  514. ObjectiveInfo[Count]=0;
  515. ObjectiveInfo[ProgressCount]=0;
  516. KillTimer(ObjectiveInfo[ObjectiveTimer]);
  517. KillTimer(ObjectiveInfo[ProgressTimer]);
  518. }
  519. ObjectiveInfo[Count]++;
  520. if(ObjectiveInfo[Count] == PLACING_TIME)
  521. {
  522. ObjectivePlaced=true;
  523. new string[128],id=ObjectiveInfo[BeingPlaced];
  524. format(string,sizeof(string),""SERVER_KEY_MSG" %s (%d) has successfully planted the bomb, 15 seconds before the bomb explodes.",PlayerMissionInfo[id][UserName],id);
  525. SendClientMessageToAll(COLOR_SERVER,string);
  526. SetTimerEx("Explosion",15000,false,"ii",0,5);
  527. KillTimer(ObjectiveInfo[ObjectiveTimer]);
  528. KillTimer(ObjectiveInfo[ProgressTimer]);
  529. FlashTimer= SetTimer("FlasBomb",500,true);
  530. CallRemoteFunction("FlashBombBar", "");
  531. CallRemoteFunction("UpdateBombInfo", "");
  532. CallRemoteFunction("KillGameModeTimer","");
  533. CallRemoteFunction("TD_Clock","s","_");
  534. DisableCheckpointForAll();
  535. }
  536. return 1;
  537. }
  538. FUNCTION FlasBomb()
  539. {
  540. CallRemoteFunction("FlashBombBar", "");
  541. return 1;
  542. }
  543.  
  544. FUNCTION Explosion(start, until)
  545. {
  546. for(new i = start; i < until; i++)
  547. {
  548. if(i >= MaxExplosions) break;
  549. CreateExplosion(ExplosionsInfo[i][0], ExplosionsInfo[i][1], ExplosionsInfo[i][2] , 7, 20.0);
  550. }
  551.  
  552. start += 5;
  553. until += 5;
  554.  
  555. if(until > MaxExplosions)
  556. {
  557. CallRemoteFunction("EndMission","");
  558. KillTimer(FlashTimer);
  559. }
  560. else
  561. {
  562. SetTimerEx("Explosion", 1000, false, "ii", start, until);
  563. }
  564. return 1;
  565. }
  566. DisableCheckpointForAll()
  567. {
  568. for(new i=0,j=GetPlayerPoolSize(); i <=j ; i++)
  569. {
  570. if(!IsPlayerConnected(i)) continue;
  571. DisablePlayerCheckpoint(i);
  572. }
  573. }
  574. PlaySoundForAll(sound)
  575. {
  576. for(new i=0,j=GetPlayerPoolSize(); i <=j ; i++)
  577. {
  578. if(IsPlayerConnected(i)) PlayerPlaySound(i,sound,0,0,0);
  579. }
  580. }
  581.  
  582. //==============================================================================
  583. // Important functions required
  584. //==============================================================================
  585.  
  586. FUNCTION OnPlayerNameRecieve(playerid,name[])
  587. {
  588. format(PlayerMissionInfo[playerid][UserName],MAX_PLAYER_NAME,"%s",name);
  589. return 1;
  590. }
  591.  
  592. FUNCTION CancelTheMission()
  593. {
  594. MissionCancelled= true;
  595. return 1;
  596. }
  597.  
  598. FUNCTION MissionObjectiveStarted() return ObjectiveStarted;
  599.  
  600. FUNCTION OnPlayerSpectateObjective(playerid)
  601. {
  602. SetPlayerCameraPos(playerid, CP_POS + 2.5);
  603. SetPlayerCameraLookAt(playerid, CP_POS);
  604. SetPlayerPos(playerid, CP_POS - 5);
  605.  
  606. SetPlayerColor(playerid, (PlayerMissionInfo[playerid][TeamSelection] == TEAM_ATTACK) ? COLOR_TEAM_ATTACK_INV : COLOR_TEAM_DEFEND_INV);
  607. return 1;
  608. }
Advertisement
Add Comment
Please, Sign In to add comment