Bulletje

Untitled

Feb 20th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.04 KB | None | 0 0
  1. /*
  2. Script by: Sasuke_Uchiha
  3. Map by: FuTuRe
  4. Mission Base: Race
  5. Mission Type: Race
  6. Mission Type ID: 0
  7. */
  8. //==============================================================================
  9. // Includes
  10. //==============================================================================
  11. #include <a_samp>
  12. #include <crashdetect>
  13. #include <fixes2>
  14.  
  15. #include "..\filterscripts\MM\stuff\defines"
  16. #include "..\filterscripts\MM\stuff\serverkeymsg"
  17.  
  18. //==============================================================================
  19. // Defines
  20. //==============================================================================
  21.  
  22. #define MISSION_NAME "San Fierro Drift"
  23. #define Health 99.0
  24. #define VEH 603
  25. #define GHOST_MODE 60
  26. #define MAX_MAP_OBJECTS 0
  27. #define CLASS_POSTION -1659.2405,1209.4226,8.1406
  28. #define CLASS_CAMERA -1658.4868,1211.2462,7.2500
  29. #define CLASS_FACING_AGNLE 355.4094
  30. #define ENABLE_NEON true
  31. #define START_TIME 20
  32.  
  33. //==============================================================================
  34. // Per mission functions
  35. //==============================================================================
  36.  
  37. enum cp_enum
  38. {
  39. Float:cp_x,
  40. Float:cp_y,
  41. Float:cp_z,
  42. cp_type,
  43. Float:cp_size
  44. };
  45.  
  46. new cp[][cp_enum] =
  47. {
  48. {-1594.62744, 1136.01160, 6.16558,0,10.0},
  49. {-1569.24097, 924.99640, 6.01359,0,10.0},
  50. {-1713.45813, 925.32776, 23.72550,0,10.0},
  51. {-1794.21899, 890.55292, 23.71911,0,10.0},
  52. {-1775.53625, 845.17340, 23.72313,0,10.0},
  53. {-1729.35901, 845.44354, 23.72835,0,10.0},
  54. {-1714.05676, 822.31274, 23.72021,0,10.0},
  55. {-1713.97412, 683.61053, 23.69951,0,10.0},
  56. {-1741.69849, 606.84094, 23.72434,0,10.0},
  57. {-1876.85205, 605.87311, 34.00550,0,10.0},
  58. {-1899.20740, 628.49323, 34.00849,0,10.0},
  59. {-1899.10071, 715.74921, 44.28532,0,10.0},
  60. {-1914.33362, 731.53619, 44.28055,0,10.0},
  61. {-1983.45728, 731.26416, 44.28770,0,10.0},
  62. {-2004.14636, 752.91669, 44.28279,0,10.0},
  63. {-2004.18970, 833.67834, 44.28887,0,10.0},
  64. {-1983.57764, 845.39661, 44.28029,0,10.0},
  65. {-1921.25818, 845.29333, 35.44251,0,10.0},
  66. {-1899.14465, 870.07568, 34.00938,0,10.0},
  67. {-1898.84595, 947.10016, 33.99102,0,10.0},
  68. {-1884.15820, 1063.48547, 44.28746,0,10.0},
  69. {-1884.19727, 1150.02087, 44.28067,0,10.0},
  70. {-1900.57849, 1176.47754, 44.28330,0,10.0},
  71. {-2121.31763, 1176.36938, 54.55038,0,10.0},
  72. {-2235.07129, 1176.36157, 54.54927,0,10.0},
  73. {-2402.25879, 1176.69690, 33.99487,0,10.0},
  74. {-2455.53955, 1200.51086, 34.05154,0,10.0},
  75. {-2475.20801, 1200.37903, 34.52285,0,10.0},
  76. {-2645.30542, 1207.61780, 54.14656,0,10.0},
  77. {-2675.14453, 1222.41309, 54.40678,0,10.0},
  78. {-2681.44067, 1943.72156, 62.92292,1,10.0}
  79. };
  80.  
  81. new Float:spawns[][4] =
  82. {
  83. {-1629.8545000,1248.4291000,6.7319000,-135.1201000},
  84. {-1632.5818000,1245.5577000,6.7319000,-135.1201000},
  85. {-1635.8564000,1242.4094000,6.7319000,-135.1201000},
  86. {-1635.3148000,1253.9724000,6.7319000,-135.1201000},
  87. {-1638.1663000,1251.3351000,6.7319000,-135.1201000},
  88. {-1641.3727000,1247.7578000,6.7319000,-135.1201000},
  89. {-1646.9188000,1253.2170000,6.7319000,-135.1201000},
  90. {-1644.1530000,1257.0940000,6.7319000,-135.1201000},
  91. {-1640.9828000,1259.7958000,6.7319000,-135.1201000},
  92. {-1646.3693000,1265.5712000,6.7319000,-135.1201000},
  93. {-1649.7823000,1262.8943000,6.7319000,-135.1201000},
  94. {-1653.0741000,1259.5309000,6.7319000,-135.1201000},
  95. {-1658.2887000,1264.8042000,6.7319000,-135.1201000},
  96. {-1655.2653000,1268.3777000,6.7319000,-135.1201000},
  97. {-1652.4067000,1271.6437000,6.7319000,-135.1201000},
  98. {-1657.3292000,1276.5154000,6.7319000,-135.1201000},
  99. {-1660.3801000,1273.8848000,6.7319000,-135.1201000},
  100. {-1663.7664000,1270.5311000,6.7319000,-135.1201000},
  101. {-1668.8921000,1275.6315000,6.7319000,-135.1201000},
  102. {-1665.6993000,1279.4570000,6.7319000,-135.1201000},
  103. {-1662.9774000,1282.3628000,6.7319000,-135.1201000},
  104. {-1668.2203000,1287.4918000,6.7319000,-135.1201000},
  105. {-1671.4022000,1284.7943000,6.7319000,-135.1201000},
  106. {-1674.4905000,1281.4668000,6.7319000,-135.1201000},
  107. {-1673.1425000,1292.5172000,6.7319000,-135.1201000},
  108. {-1676.0686000,1289.8345000,6.7319000,-135.1201000},
  109. {-1679.2971000,1286.6550000,6.7319000,-135.1201000},
  110. {-1678.1476000,1297.7715000,6.7319000,-135.1201000},
  111. {-1681.3748000,1294.8358000,6.7319000,-135.1201000},
  112. {-1684.5839000,1291.5449000,6.7319000,-135.1201000},
  113. {-1683.2721000,1302.8901000,6.7319000,-135.1201000},
  114. {-1686.5020000,1300.0546000,6.7319000,-135.1201000},
  115. {-1689.6841000,1296.9402000,6.7319000,-135.1201000},
  116. {-1688.1501000,1307.9071000,6.7319000,-135.1201000},
  117. {-1691.6289000,1305.1002000,6.7319000,-135.1201000},
  118. {-1694.6852000,1301.9216000,6.7319000,-135.1201000},
  119. {-1693.0881000,1312.9165000,6.7319000,-135.1201000},
  120. {-1696.9089000,1310.2965000,6.7319000,-135.1201000},
  121. {-1699.6553000,1307.3002000,6.7319000,-135.1201000},
  122. {-1698.2395000,1317.9698000,6.7319000,-135.1201000},
  123. {-1701.5410000,1315.2009000,6.7319000,-135.1201000},
  124. {-1704.5157000,1312.5842000,6.7319000,-135.1201000},
  125. {-1644.0074000,1233.8462000,6.7319000,-135.1201000},
  126. {-1646.9434000,1230.6471000,6.7319000,-135.1201000},
  127. {-1650.0283000,1227.5557000,6.7319000,-135.1201000},
  128. {-1648.8837000,1238.6093000,6.7319000,-135.1201000},
  129. {-1651.8314000,1235.6936000,6.7319000,-135.1201000},
  130. {-1654.8398000,1232.6967000,6.7319000,-135.1201000},
  131. {-1653.6462000,1243.5763000,6.7319000,-135.1201000},
  132. {-1656.6750000,1240.8347000,6.7319000,-135.1201000},
  133. {-1659.5765000,1237.8529000,6.7319000,-135.1201000},
  134. {-1661.9302000,1246.2150000,6.7319000,-135.1201000},
  135. {-1659.0320000,1249.0007000,6.7319000,-135.1201000},
  136. {-1664.8054000,1243.4785000,6.7319000,-135.1201000},
  137. {-1663.8452000,1253.9268000,6.7319000,-135.1201000},
  138. {-1666.7422000,1250.9668000,6.7319000,-135.1201000},
  139. {-1669.7517000,1248.4132000,6.7319000,-135.1201000},
  140. {-1668.7600000,1258.8916000,6.7319000,-135.1201000},
  141. {-1671.7219000,1256.1843000,6.7319000,-135.1201000},
  142. {-1674.5609000,1253.6086000,6.7319000,-135.1201000},
  143. {-1673.5575000,1263.7034000,6.7319000,-135.1201000},
  144. {-1676.4435000,1260.9568000,6.7319000,-135.1201000},
  145. {-1679.3312000,1258.1814000,6.7319000,-135.1201000},
  146. {-1678.3170000,1268.5015000,6.7319000,-135.1201000},
  147. {-1681.4276000,1266.0593000,6.7319000,-135.1201000},
  148. {-1684.4370000,1263.1340000,6.7319000,-135.1201000},
  149. {-1683.0923000,1273.1683000,6.7319000,-135.1201000},
  150. {-1686.1472000,1270.7148000,6.7319000,-135.1201000},
  151. {-1688.9408000,1267.7156000,6.7319000,-135.1201000},
  152. {-1687.7461000,1278.0189000,6.7319000,-135.1201000},
  153. {-1690.9408000,1275.3397000,6.7319000,-135.1201000},
  154. {-1693.4639000,1272.3022000,6.7319000,-135.1201000},
  155. {-1692.4491000,1282.9762000,6.7319000,-135.1201000},
  156. {-1695.6150000,1280.2172000,6.7319000,-135.1201000},
  157. {-1698.3401000,1277.3624000,6.7319000,-135.1201000},
  158. {-1697.2225000,1287.8403000,6.7319000,-135.1201000},
  159. {-1700.6698000,1285.0026000,6.7319000,-135.1201000},
  160. {-1703.2460000,1282.4064000,6.7319000,-135.1201000},
  161. {-1701.8821000,1292.7827000,6.7319000,-135.1201000},
  162. {-1705.2672000,1290.1982000,6.7319000,-135.1201000},
  163. {-1708.0918000,1287.3660000,6.7319000,-135.1201000},
  164. {-1706.3148000,1297.9919000,6.7319000,-135.1201000},
  165. {-1710.1111000,1294.7523000,6.7319000,-135.1201000},
  166. {-1713.0168000,1292.3708000,6.7319000,-135.1201000},
  167. {-1711.2457000,1303.1583000,6.7319000,-135.1201000},
  168. {-1714.9867000,1299.8538000,6.7319000,-135.1201000},
  169. {-1717.8710000,1297.5022000,6.7319000,-135.1201000},
  170. {-1709.0314000,1317.3516000,6.7319000,-135.1201000},
  171. {-1706.4867000,1319.7876000,6.7319000,-135.1201000},
  172. {-1703.4510000,1322.9078000,6.7319000,-135.1201000},
  173. {-1716.1768000,1308.1292000,6.7319000,-135.1201000},
  174. {-1719.9777000,1304.6821000,6.7319000,-135.1201000},
  175. {-1722.6945000,1302.4148000,6.7319000,-135.1201000},
  176. {-1720.8745000,1313.0215000,6.7319000,-135.1201000},
  177. {-1724.5375000,1309.7726000,6.7319000,-135.1201000},
  178. {-1727.6582000,1307.2693000,6.7319000,-135.1201000},
  179. {-1711.3175000,1324.7393000,6.7319000,-135.1201000},
  180. {-1708.1512000,1327.6727000,6.7319000,-135.1201000},
  181. {-1713.8826000,1322.0602000,6.7319000,-135.1201000},
  182. {-1712.8665000,1332.5868000,6.7319000,-135.1201000}
  183. };
  184.  
  185. enum ped_enum
  186. {
  187. TeamID,
  188. Skin,
  189. Float:SpawnX,
  190. Float:SpawnY,
  191. Float:SpawnZ,
  192. Float:SpawnAngle,
  193. SpawnInterior,
  194. VirtualWorld,
  195. Weapon1,
  196. Ammo1,
  197. Weapon2,
  198. Ammo2,
  199. Weapon3,
  200. Ammo3,
  201. };
  202.  
  203. new PedInfo[][ped_enum] =
  204. {
  205. {TEAM_DEFEND,59,211.8, 382.3, 136.8, 0.0,0,0,0,0,0,0,0,0}
  206. };
  207.  
  208. #if MAX_MAP_OBJECTS != 0
  209. new Object[MAX_MAP_OBJECTS];
  210.  
  211. CreateMap()
  212. {
  213. //Objects Here
  214. }
  215. #endif
  216.  
  217.  
  218. //==============================================================================
  219. // Basic vars
  220. //==============================================================================
  221.  
  222. new bool:ObjectiveStarted= false;
  223. new bool:MissionStarted;
  224. new GMTimer;
  225. new GMSec;
  226. new bool:MissionCancelled;
  227.  
  228. native IsValidVehicle(vehicleid);
  229.  
  230. #if ENABLE_NEON == true
  231. new NEON[200];
  232. #endif
  233.  
  234. new CurrentSpawn=-1;
  235. new TotalPlayers;
  236. new CurrentRacePos;
  237. new MAX_CPs;
  238. new RaceMin,RaceSec,RaceMili;
  239. new BARRELS_ALLOWED= false;
  240. new Ghost_Mode_Time;
  241. new RandomColor;
  242.  
  243.  
  244. enum playersdata
  245. {
  246. UserName[MAX_PLAYER_NAME],
  247. rSec,
  248. rMin,
  249. rMili,
  250. CurrentCheckpoint,
  251. PlayerSpawnID,
  252. PlayerVehicle,
  253. MissionFinished,
  254. PlayerClassID,
  255. PlayerCounted,
  256. rBestMin,
  257. rBestSec,
  258. rBestMili
  259. };
  260. new PlayerMissionInfo[MAX_PLAYERS][playersdata];
  261.  
  262. //==============================================================================
  263. // Basic script
  264. //==============================================================================
  265.  
  266. main()
  267. {
  268. print("----------------------------------");
  269. print(" Mission: "MISSION_NAME" started.");
  270. print("----------------------------------\n");
  271. }
  272.  
  273. public OnGameModeInit()
  274. {
  275. MissionStarted= true;
  276.  
  277. #if MAX_MAP_OBJECTS != 0
  278. CreateMap();
  279. #endif
  280.  
  281. #if ENABLE_NEON == true
  282. for(new i=0; i<100; i++)
  283. {
  284. new neon = random(6);
  285.  
  286. switch(neon)
  287. {
  288. case 0:
  289. {
  290. NEON[i]= CreateObject(18648,0,0,0,0,0,0);
  291. NEON[i+100]= CreateObject(18648,0,0,0,0,0,0);
  292. }
  293. case 1:
  294. {
  295. NEON[i]= CreateObject(18647,0,0,0,0,0,0);
  296. NEON[i+100]= CreateObject(18647,0,0,0,0,0,0);
  297. }
  298. case 2:
  299. {
  300. NEON[i]= CreateObject(18649,0,0,0,0,0,0);
  301. NEON[i+100]= CreateObject(18649,0,0,0,0,0,0);
  302. }
  303. case 3:
  304. {
  305. NEON[i]= CreateObject(18652,0,0,0,0,0,0);
  306. NEON[i+100]= CreateObject(18652,0,0,0,0,0,0);
  307. }
  308. case 4:
  309. {
  310. NEON[i]= CreateObject(18651,0,0,0,0,0,0);
  311. NEON[i+100]= CreateObject(18651,0,0,0,0,0,0);
  312. }
  313. case 5:
  314. {
  315. NEON[i]= CreateObject(18650,0,0,0,0,0,0);
  316. NEON[i+100]= CreateObject(18650,0,0,0,0,0,0);
  317. }
  318. }
  319. }
  320. #endif
  321.  
  322. for(new i=0; i<sizeof(PedInfo); i++)
  323. {
  324.  
  325. 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);
  326. }
  327.  
  328. GMTimer = SetTimer("GMClock",1000,true);
  329. MAX_CPs = sizeof(cp);
  330. if(random(4) == 1) Ghost_Mode_Time= GHOST_MODE;
  331. else Ghost_Mode_Time= -1;
  332. for(new i=0; i<MAX_PLAYERS; i++)
  333. {
  334. PlayerMissionInfo[i][PlayerSpawnID]=-1;
  335. PlayerMissionInfo[i][PlayerVehicle]=-1;
  336. }
  337. RandomColor=random(2);
  338. if(random(4) == 2)
  339. {
  340. CallRemoteFunction("SetUpBarrelSystem", "");
  341. BARRELS_ALLOWED = true;
  342. }
  343. CallRemoteFunction("UpdateRaceRecordsFunc","dd",INVALID_PLAYER_ID,0);
  344. if(CallRemoteFunction("GetCurrentMissionCJWalk","")) UsePlayerPedAnims();
  345.  
  346. EnableVehicleFriendlyFire();
  347. return 1;
  348. }
  349.  
  350. public OnGameModeExit()
  351. {
  352. #if MAX_MAP_OBJECTS != 0
  353. for(new i=0;i<MAX_MAP_OBJECTS;i++) DestroyObject(Object[i]);
  354. #endif
  355.  
  356. KillTimer(GMTimer);
  357. for(new i=0; i<MAX_VEHICLES; i++)
  358. {
  359. if(IsValidVehicle(i))
  360. {
  361. DestroyVehicle(i);
  362. }
  363. }
  364. #if ENABLE_NEON == true
  365. for(new i=0;i<200;i++) DestroyObject(NEON[i]);
  366. #endif
  367. return 1;
  368. }
  369.  
  370. FUNCTION GMClock()
  371. {
  372. GMSec++;
  373. switch(ObjectiveStarted)
  374. {
  375. case false:
  376. {
  377. switch(GMSec)
  378. {
  379. case 1:
  380. {
  381. new string[40];
  382. format(string,sizeof(string),"The race will start in %d seconds.",START_TIME);
  383. CallRemoteFunction("ShowInfoBox", "iisi", -1, -1, string,0);
  384. }
  385. case START_TIME-2:
  386. {
  387. GameTextForAll("~r~~h~~h~ON YOUR MARKS!",1000,3);
  388. PlaySoundForAll(1056);
  389. }
  390. case START_TIME-1:
  391. {
  392. GameTextForAll("~y~GET SET!",1000,3);
  393. PlaySoundForAll(1056);
  394. }
  395. case START_TIME:
  396. {
  397. PlaySoundForAll(1057);
  398. CallRemoteFunction("StartMission","");
  399. GameTextForAll("~g~~h~~h~GO!",1000,3);
  400. ObjectiveStarted= true;
  401. ToggleControllable(true);
  402. SendClientMessageToAll(COLOR_SERVER,""SERVER_KEY_MSG" KA BOOM! The race has started. Good luck.");
  403. CallRemoteFunction("ShowInfoBox", "iisi", -1, -1,"KA BOOM! The race has started. Good luck.",0);
  404. RaceMili=GetTickCount();
  405. }
  406. }
  407. if(Ghost_Mode_Time > 0 || Ghost_Mode_Time == -1)
  408. {
  409. for(new i=0; i<MAX_PLAYERS; i++) DisableRemoteVehicleCollisions(i,1);
  410. }
  411. }
  412. case true:
  413. {
  414. if(Ghost_Mode_Time > 0)
  415. {
  416. Ghost_Mode_Time--;
  417. if(Ghost_Mode_Time == 0)
  418. {
  419. for(new i=0; i<MAX_PLAYERS; i++) DisableRemoteVehicleCollisions(i,0);
  420. SendClientMessageToAll(COLOR_SERVER,""SERVER_KEY_MSG" Ghost mode has been disabled by the server.");
  421. CallRemoteFunction("ShowInfoBox", "iisi", -1, -1,"Ghost mode has been disabled by the server.",0);
  422. CallRemoteFunction("IRC_SendMessage","ss",""SERVER_KEY_MSG" Ghost mode has been disabled by the server.",IRC_SERVER_COLOR);
  423. }
  424. }
  425. for(new i=0,j=GetPlayerPoolSize(); i<=j; i++)
  426. {
  427. if(IsPlayerConnected(i) && CallRemoteFunction("GetAliveState","i",i) && !PlayerMissionInfo[i][MissionFinished])
  428. {
  429. GetPlayerPosition(i);
  430. }
  431. }
  432. RaceSec++;
  433. if(RaceSec == 60)
  434. {
  435. RaceSec=0;
  436. RaceMin++;
  437. }
  438. }
  439. }
  440. }
  441.  
  442. public OnPlayerDisconnect(playerid,reason)
  443. {
  444. if(IsValidVehicle(PlayerMissionInfo[playerid][PlayerVehicle])) DestroyVehicle(PlayerMissionInfo[playerid][PlayerVehicle]);
  445. PlayerMissionInfo[playerid][PlayerVehicle]=-1;
  446. if(!PlayerMissionInfo[playerid][MissionFinished])
  447. {
  448. if(PlayerMissionInfo[playerid][PlayerCounted])
  449. {
  450. TotalPlayers--;
  451. PlayerMissionInfo[playerid][PlayerCounted]= false;
  452. }
  453. }
  454. else PlayerMissionInfo[playerid][MissionFinished] = false;
  455. RemovePlayerMapIcon(playerid,MAP_ICON_NEXT_CP);
  456. DisablePlayerRaceCheckpoint(playerid);
  457. CallRemoteFunction("PlayerRaceRecords","dd",playerid,1);
  458. return 1;
  459. }
  460.  
  461. public OnPlayerRequestClass(playerid, classid)
  462. {
  463. SetPlayerPos(playerid,CLASS_POSTION);
  464. SetPlayerCameraPos(playerid,CLASS_CAMERA);
  465. SetPlayerCameraLookAt(playerid,CLASS_POSTION);
  466. SetPlayerFacingAngle(playerid,CLASS_FACING_AGNLE);
  467.  
  468. CallRemoteFunction("ShowClassSelection","ddsddd",playerid,2,"Drift King", PedInfo[classid][Weapon1], PedInfo[classid][Weapon2], PedInfo[classid][Weapon3]);
  469. SetPlayerColor(playerid,COLOR_SERVER);
  470. PlayerMissionInfo[playerid][PlayerClassID]=classid;
  471. return 1;
  472. }
  473.  
  474. public OnPlayerRequestSpawn(playerid)
  475. {
  476. CallRemoteFunction("UpdateRaceRecordsFunc","dd",INVALID_PLAYER_ID,0);
  477. if(PlayerMissionInfo[playerid][PlayerSpawnID] == -1)
  478. {
  479. CurrentSpawn++;
  480. PlayerMissionInfo[playerid][PlayerSpawnID]=CurrentSpawn;
  481. PlayerMissionInfo[playerid][CurrentCheckpoint]=0;
  482. }
  483. if(!IsPlayerJailed(playerid))
  484. {
  485. new Float:x,Float:y,Float:z,Float:a;
  486. x=spawns[PlayerMissionInfo[playerid][PlayerSpawnID]][0];
  487. y=spawns[PlayerMissionInfo[playerid][PlayerSpawnID]][1];
  488. z=spawns[PlayerMissionInfo[playerid][PlayerSpawnID]][2];
  489. a=spawns[PlayerMissionInfo[playerid][PlayerSpawnID]][3];
  490. if(IsValidVehicle(PlayerMissionInfo[playerid][PlayerVehicle])) DestroyVehicle(PlayerMissionInfo[playerid][PlayerVehicle]);
  491. PlayerMissionInfo[playerid][PlayerVehicle] = CreateVehicle(VEH,x,y,z,a,random(255),random(255),-1);
  492. #if ENABLE_NEON == true
  493. AddNeon(PlayerMissionInfo[playerid][PlayerVehicle]);
  494. #endif
  495. }
  496. return 1;
  497. }
  498.  
  499. public OnPlayerSpawn(playerid)
  500. {
  501. new string[124];
  502. CallRemoteFunction("UpdateAliveState","ii",playerid,1);
  503. SetPlayerHealth(playerid,Health);
  504. if(PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Skin] == 0)
  505. {
  506. back:
  507. new skin=random(312);
  508. if(skin == 74 || skin < 1) goto back;
  509. SetPlayerSkin(playerid,skin);
  510. }
  511. if(CallRemoteFunction("GetSpectateStatus","d",playerid)) return CallRemoteFunction("SpecOffAdmin","d",playerid);
  512. SetPlayerColor(playerid,(RandomColor == TEAM_ATTACK) ? COLOR_TEAM_ATTACK : COLOR_TEAM_DEFEND);
  513. SetPlayerTeam(playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][TeamID]);
  514. switch(ObjectiveStarted)
  515. {
  516. case false:
  517. {
  518. TogglePlayerControllable(playerid,false);
  519. format(string,sizeof(string),"The race will start in %d seconds. Get ready.",(GMSec-START_TIME)*-1);
  520. CallRemoteFunction("ShowInfoBox", "iisi", playerid, -1,string,100);
  521. }
  522. case true:
  523. {
  524. TogglePlayerControllable(playerid,true);
  525. CallRemoteFunction("ShowInfoBox", "iisi", playerid, -1,"HURRY UP! The race has already started.",2000);
  526. }
  527. }
  528. if(Ghost_Mode_Time > 0)
  529. {
  530. DisableRemoteVehicleCollisions(playerid,1);
  531. format(string,sizeof(string),""SERVER_KEY_MSG" The ghost mode will last for %d seconds.",Ghost_Mode_Time);
  532. SendClientMessage(playerid,COLOR_SERVER,string);
  533. }
  534. if(Ghost_Mode_Time == -1) DisableRemoteVehicleCollisions(playerid,1);
  535. CallRemoteFunction("ShowInfoText", "iisi", playerid, -1,"Try to finish first!",2000);
  536. if(CallRemoteFunction("GetJailedStatus","d",playerid))
  537. {
  538. CallRemoteFunction("SetJailed","d",playerid);
  539. }
  540. else
  541. {
  542. if(BARRELS_ALLOWED)
  543. {
  544. SendClientMessage(playerid, COLOR_SERVER, ""SERVER_KEY_MSG" The system has chosen that barrels are enabled in this mission.");
  545. format(string,sizeof(string),""SERVER_KEY_MSG" You can throw a barrel by pressing 'submission key (2)' on your keyboard. (Costs: $%d / barrel)",BARREL_PRICE);
  546. SendClientMessage(playerid, COLOR_SERVER, string);
  547. }
  548. else
  549. {
  550. SendClientMessage(playerid, COLOR_SERVER, ""SERVER_KEY_MSG" The system has chosen that barrels are disabled in this mission.");
  551. }
  552. SetVehicleToRespawn(PlayerMissionInfo[playerid][PlayerVehicle]);
  553. PutPlayerInVehicle(playerid,PlayerMissionInfo[playerid][PlayerVehicle],0);
  554. LinkVehicleToInterior(PlayerMissionInfo[playerid][PlayerVehicle],PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][SpawnInterior]);
  555. CallRemoteFunction("GivePlayerWeaponEx","ddd",playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Weapon1],PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Ammo1]);
  556. CallRemoteFunction("GivePlayerWeaponEx","ddd",playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Weapon2],PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Ammo2]);
  557. CallRemoteFunction("GivePlayerWeaponEx","ddd",playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Weapon3],PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Ammo3]);
  558. if(!PlayerMissionInfo[playerid][MissionFinished])
  559. {
  560. PlayerMissionInfo[playerid][CurrentCheckpoint]= 0;
  561. PlayerMissionInfo[playerid][rMili]=0,PlayerMissionInfo[playerid][rMin]=0,PlayerMissionInfo[playerid][rSec]=0;
  562. SetVehicleVirtualWorld(PlayerMissionInfo[playerid][PlayerVehicle], 0);
  563. SetPlayerVirtualWorld(playerid,0);
  564. SetPlayerRaceCheckpoint(playerid,cp[PlayerMissionInfo[playerid][CurrentCheckpoint]][cp_type],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]][cp_x],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]][cp_y],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]][cp_z],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_x],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_y],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_z],10.0);
  565. SetPlayerMapIcon(playerid, MAP_ICON_NEXT_CP,cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_x],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_y],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_z], 0, 0xFF000033, MAPICON_LOCAL);
  566. }
  567. else
  568. {
  569. SetVehicleVirtualWorld(PlayerMissionInfo[playerid][PlayerVehicle], 2);
  570. SetPlayerVirtualWorld(playerid,2);
  571. CallRemoteFunction("OnPlayerMissionComplete","d",playerid);
  572. }
  573. if(!PlayerMissionInfo[playerid][PlayerCounted])
  574. {
  575. TotalPlayers++;
  576. PlayerMissionInfo[playerid][PlayerCounted]= true;
  577. }
  578. }
  579. CallRemoteFunction("GetPlayerPersonalBest","d",playerid);
  580. CallRemoteFunction("UpdateMissionHud","iiiiiiiiiiii",playerid,2,GetPlayerPosition(playerid),TotalPlayers,RaceMin,PlayerMissionInfo[playerid][rSec],PlayerMissionInfo[playerid][CurrentCheckpoint],MAX_CPs,PlayerMissionInfo[playerid][rBestMin],PlayerMissionInfo[playerid][rBestSec],PlayerMissionInfo[playerid][rBestMili],Ghost_Mode_Time);
  581. CallRemoteFunction("PlayerRaceRecords","dd",playerid,2);
  582. return 1;
  583. }
  584.  
  585. public OnPlayerDeath(playerid,killerid,reason)
  586. {
  587. CallRemoteFunction("UpdateAliveState","ii",playerid,0);
  588. if(!PlayerMissionInfo[playerid][MissionFinished]) PlayerMissionInfo[playerid][CurrentCheckpoint]=0;
  589. CallRemoteFunction("PlayerRaceRecords","dd",playerid,1);
  590. CallRemoteFunction("UpdateLastCheckpoint","dfff",playerid,-1.0,-1.0,-1.0);
  591. return 1;
  592. }
  593.  
  594. public OnPlayerEnterRaceCheckpoint(playerid)
  595. {
  596. if(!MissionStarted || !ObjectiveStarted) return 0;
  597. new string[124],type;
  598. PlayerPlaySound(playerid,1139,0,0,0);
  599. CallRemoteFunction("UpdateLastCheckpoint","dfff",playerid,cp[PlayerMissionInfo[playerid][CurrentCheckpoint]][cp_x],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]][cp_y],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]][cp_z]);
  600. if(PlayerMissionInfo[playerid][CurrentCheckpoint] != MAX_CPs-1)
  601. {
  602. type=cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_type];
  603. }
  604. if(PlayerMissionInfo[playerid][CurrentCheckpoint] == MAX_CPs-2)
  605. {
  606. SetPlayerRaceCheckpoint(playerid,type,cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_x],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_y],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_z],0.0,0.0,0.0,cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_size]);
  607. RemovePlayerMapIcon(playerid,MAP_ICON_NEXT_CP);
  608. }
  609. else if(PlayerMissionInfo[playerid][CurrentCheckpoint] == MAX_CPs-1)
  610. {
  611. PlaySoundForAll(1058);
  612. PlayerMissionInfo[playerid][MissionFinished]= true;
  613. DisablePlayerRaceCheckpoint(playerid);
  614. RemovePlayerMapIcon(playerid,MAP_ICON_NEXT_CP);
  615. new Pos=GetPlayerPosition(playerid);
  616. CurrentRacePos++;
  617. PlayerMissionInfo[playerid][rMin]=RaceMin;
  618. PlayerMissionInfo[playerid][rSec]=RaceSec;
  619. new Prize=floatround(10000/Pos, floatround_round)+(1000*TotalPlayers);
  620. PlayerMissionInfo[playerid][rMili]=(((GetTickCount()-RaceMili)-(1000*PlayerMissionInfo[playerid][rSec]))-((1000*60)*PlayerMissionInfo[playerid][rMin]));
  621. while(PlayerMissionInfo[playerid][rMili] >= 1000)
  622. {
  623. PlayerMissionInfo[playerid][rMili]-=1000;
  624. PlayerMissionInfo[playerid][rSec]++;
  625. if(PlayerMissionInfo[playerid][rSec] == 60)
  626. {
  627. PlayerMissionInfo[playerid][rSec]=0;
  628. PlayerMissionInfo[playerid][rMin]++;
  629. }
  630. }
  631. CallRemoteFunction("GetPlayerPersonalBest","d",playerid);
  632. CallRemoteFunction("UpdateMissionHud","iiiiiiiiiiii",playerid,2,Pos,TotalPlayers,PlayerMissionInfo[playerid][rMin],PlayerMissionInfo[playerid][rSec],PlayerMissionInfo[playerid][CurrentCheckpoint]+1,MAX_CPs,PlayerMissionInfo[playerid][rBestMin],PlayerMissionInfo[playerid][rBestSec],PlayerMissionInfo[playerid][rBestMili],Ghost_Mode_Time);
  633. CallRemoteFunction("GivePlayerCash","ii",playerid,Prize);
  634. if(Pos == 1)
  635. {
  636. CallRemoteFunction("PlayerMissionStats","dd",playerid,3);
  637. format(string,sizeof(string),""SERVER_KEY_MSG" %s (%d) has finished 1st in the race. Time Taken: %02d:%02d:%03d [Prize: $%d + Token].",PlayerMissionInfo[playerid][UserName],playerid,PlayerMissionInfo[playerid][rMin],PlayerMissionInfo[playerid][rSec],PlayerMissionInfo[playerid][rMili],Prize);
  638. CallRemoteFunction("GivePlayerToken","dd",playerid,1);
  639. CallRemoteFunction("CheckForBetWinners","d",playerid);
  640. }
  641. else format(string,sizeof(string),""SERVER_KEY_MSG" %s (%d) has finished %d%s in the race. Time Taken: %02d:%02d:%03d | Prize: $%d.",PlayerMissionInfo[playerid][UserName],playerid,Pos,GetEndStyle(Pos),PlayerMissionInfo[playerid][rMin],PlayerMissionInfo[playerid][rSec],PlayerMissionInfo[playerid][rMili],Prize);
  642. if(Pos == 2) CallRemoteFunction("PlayerMissionStats","dd",playerid,4);
  643. if(Pos == 3) CallRemoteFunction("PlayerMissionStats","dd",playerid,5);
  644. CallRemoteFunction("PlayerMissionStats","dd",playerid,0);
  645. CallRemoteFunction("IRC_SendMessage","ss",string,IRC_SERVER_COLOR);
  646. new time = ((PlayerMissionInfo[playerid][rMin]*60000)+(PlayerMissionInfo[playerid][rSec]*1000)+(PlayerMissionInfo[playerid][rMili]));
  647. CallRemoteFunction("CheckRaceRecord","dd",playerid,time);
  648. SetVehicleVirtualWorld(PlayerMissionInfo[playerid][PlayerVehicle], 2);
  649. SetPlayerVirtualWorld(playerid,2);
  650. SendClientMessageToAll(COLOR_SERVER,string);
  651. CallRemoteFunction("OnPlayerMissionComplete","d",playerid);
  652. CallRemoteFunction("UpdateLastCheckpoint","dfff",playerid,-2.0,-2.0,-2.0);
  653. CallRemoteFunction("PlayerMissionStats","dd",playerid,9);
  654. }
  655. else if(PlayerMissionInfo[playerid][CurrentCheckpoint] < MAX_CPs-1)
  656. {
  657. SetPlayerRaceCheckpoint(playerid,type,cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_x],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_y],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_z],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+2][cp_x],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+2][cp_y],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+2][cp_z],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_size]);
  658. SetPlayerMapIcon(playerid, MAP_ICON_NEXT_CP,cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+2][cp_x],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+2][cp_y],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+2][cp_z], 0, 0xFF000033, MAPICON_LOCAL);
  659. }
  660. PlayerMissionInfo[playerid][CurrentCheckpoint]++;
  661. return 1;
  662. }
  663.  
  664. #if ENABLE_NEON == true
  665. public OnVehicleSpawn(vehicleid)
  666. {
  667. for(new i=0; i<100; i++)
  668. {
  669. if(!IsValidVehicle(i)) continue;
  670.  
  671. AttachObjectToVehicle(NEON[i-1],i, -0.90, -0.15, -0.58, 0.0, 0.0, 0.0);
  672. AttachObjectToVehicle(NEON[i-1]+100,i, 0.90, -0.15, -0.58, 0.0, 0.0, 0.0);
  673. }
  674. return 1;
  675. }
  676. #endif
  677.  
  678.  
  679. FUNCTION EndTheMission()
  680. {
  681. if(!MissionStarted) return 1;
  682. MissionStarted= false;
  683. KillTimer(GMTimer);
  684. if(!MissionCancelled && ObjectiveStarted)
  685. {
  686. SendClientMessageToAll(COLOR_SERVER,""SERVER_KEY_MSG" The race has ended.");
  687. CallRemoteFunction("IRC_SendMessage","ss",""SERVER_KEY_MSG" The race has ended.",IRC_SERVER_COLOR);
  688. CallRemoteFunction("ShowInfoBox", "iisi", -1, -1,"The race has ended.",0);
  689. for(new i=0,j=GetPlayerPoolSize(); i<=j; i++)
  690. {
  691. if(IsPlayerConnected(i) && !PlayerMissionInfo[i][MissionFinished])
  692. {
  693. PlayerPlaySound(i,17004,0,0,0);
  694. GameTextForPlayer(i,"~R~MISSION FAILED~w~!",3000,3);
  695. DisablePlayerCheckpoint(i);
  696. CallRemoteFunction("PlayerMissionStats","dd",i,1);
  697. }
  698. }
  699. }
  700. else
  701. {
  702. PlaySoundForAll(1058);
  703. SendClientMessageToAll(COLOR_SERVER,""SERVER_KEY_MSG" The mission has been cancelled.");
  704. CallRemoteFunction("IRC_SendMessage","ss",""SERVER_KEY_MSG" The mission has been cancelled.",IRC_SERVER_COLOR);
  705. CallRemoteFunction("ShowInfoBox", "iisi", -1, -1,"The mission has been cancelled.",0);
  706. for(new i=0,j=GetPlayerPoolSize(); i<=j; i++)
  707. {
  708. if(IsPlayerConnected(i))
  709. {
  710. GameTextForPlayer(i,"~R~MISSION CANCELLED~w~!",3000,3);
  711. DisablePlayerCheckpoint(i);
  712. RemovePlayerMapIcon(i,MAP_ICON_NEXT_CP);
  713. }
  714. }
  715. }
  716. return 1;
  717. }
  718.  
  719. //==============================================================================
  720. // Mission functions
  721. //==============================================================================
  722.  
  723. GetPlayerPosition(playerid)
  724. {
  725. if(!IsPlayerConnected(playerid)) return 0;
  726. if(PlayerMissionInfo[playerid][MissionFinished]) return GetPlayerScore(playerid);
  727. new PlayerPositon=CurrentRacePos+1;
  728. new Float:PlayerDistance=GetPlayerDistanceFromPoint(playerid,cp[PlayerMissionInfo[playerid][CurrentCheckpoint]][cp_x],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]][cp_y],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]][cp_z]);
  729. new Float:OtherPlayerDistance;
  730. for(new i=0,j=GetPlayerPoolSize(); i<=j; i++)
  731. {
  732. if(!IsPlayerConnected(i)) continue;
  733. if(!CallRemoteFunction("GetAliveState","i",i) || !ObjectiveStarted || PlayerMissionInfo[i][MissionFinished]) continue;
  734. if(PlayerMissionInfo[playerid][CurrentCheckpoint] < PlayerMissionInfo[i][CurrentCheckpoint])
  735. {
  736. PlayerPositon++;
  737. continue;
  738. }
  739. else if(PlayerMissionInfo[playerid][CurrentCheckpoint] == PlayerMissionInfo[i][CurrentCheckpoint])
  740. {
  741. OtherPlayerDistance=GetPlayerDistanceFromPoint(i,cp[PlayerMissionInfo[i][CurrentCheckpoint]][cp_x],cp[PlayerMissionInfo[i][CurrentCheckpoint]][cp_y],cp[PlayerMissionInfo[i][CurrentCheckpoint]][cp_z]);
  742. if(PlayerDistance > OtherPlayerDistance)
  743. {
  744. PlayerPositon++;
  745. continue;
  746. }
  747. }
  748. }
  749. SetPlayerScore(playerid,PlayerPositon);
  750. CallRemoteFunction("UpdateMissionHud","iiiiiiiiiiii",playerid,2,PlayerPositon,TotalPlayers,RaceMin,RaceSec,PlayerMissionInfo[playerid][CurrentCheckpoint],MAX_CPs,PlayerMissionInfo[playerid][rBestMin],PlayerMissionInfo[playerid][rBestSec],PlayerMissionInfo[playerid][rBestMili],Ghost_Mode_Time);
  751. return PlayerPositon;
  752. }
  753.  
  754. #if ENABLE_NEON == true
  755. AddNeon(vehicleid)
  756. {
  757. AttachObjectToVehicle(NEON[vehicleid],vehicleid, -0.90, -0.15, -0.58, 0.0, 0.0, 0.0);
  758. AttachObjectToVehicle(NEON[vehicleid]+100,vehicleid, 0.90, -0.15, -0.58, 0.0, 0.0, 0.0);
  759. }
  760. #endif
  761.  
  762. GetEndStyle(pos)
  763. {
  764. new end[3];
  765. if(pos == 11 || pos == 12 || pos == 13) { end = "TH"; }
  766. else if(pos - (pos / 10) * 10 == 1) { end = "ST"; }
  767. else if(pos - (pos / 10) * 10 == 2) { end = "ND"; }
  768. else if(pos - (pos / 10) * 10 == 3) { end = "RD"; }
  769. else { end = "TH"; }
  770.  
  771. return end;
  772. }
  773.  
  774. PlaySoundForAll(sound)
  775. {
  776. for (new i=0,j=GetPlayerPoolSize(); i <=j ; i++)
  777. {
  778. if(IsPlayerConnected(i)) PlayerPlaySound(i,sound,0,0,0);
  779. }
  780. }
  781.  
  782.  
  783. ToggleControllable(control)
  784. {
  785. for(new i=0,j=GetPlayerPoolSize(); i<=j; i++)
  786. {
  787. if(IsPlayerConnected(i))
  788. {
  789. if(CallRemoteFunction("GetAliveState","i",i)) TogglePlayerControllable(i,control);
  790. }
  791. }
  792. return 1;
  793. }
  794.  
  795. //==============================================================================
  796. // Important functions required
  797. //==============================================================================
  798.  
  799. FUNCTION OnPlayerGetPersonalBest(playerid,Min,Sec,Mili)
  800. {
  801. PlayerMissionInfo[playerid][rBestMin]=Min;
  802. PlayerMissionInfo[playerid][rBestSec]=Sec;
  803. PlayerMissionInfo[playerid][rBestMili]=Mili;
  804. CallRemoteFunction("UpdateMissionHud","iiiiiiiiiiii",playerid,2,GetPlayerPosition(playerid),TotalPlayers,PlayerMissionInfo[playerid][rMin],PlayerMissionInfo[playerid][rSec],PlayerMissionInfo[playerid][CurrentCheckpoint]+1,MAX_CPs,PlayerMissionInfo[playerid][rBestMin],PlayerMissionInfo[playerid][rBestSec],PlayerMissionInfo[playerid][rBestMili],Ghost_Mode_Time);
  805. return 1;
  806. }
  807.  
  808. FUNCTION CancelTheMission()
  809. {
  810. MissionCancelled= true;
  811. return 1;
  812. }
  813.  
  814. FUNCTION GetPlayerRaceVehicleID(playerid) return PlayerMissionInfo[playerid][PlayerVehicle];
  815.  
  816. FUNCTION OnPlayerNameRecieve(playerid,name[])
  817. {
  818. format(PlayerMissionInfo[playerid][UserName],MAX_PLAYER_NAME,"%s",name);
  819. return 1;
  820. }
  821.  
  822. FUNCTION MissionObjectiveStarted() return ObjectiveStarted;
Add Comment
Please, Sign In to add comment