Guest User

Crusher

a guest
Sep 18th, 2009
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.13 KB | None | 0 0
  1. /*
  2. Crushers TDM.
  3.  
  4. This is an TDM (Team deathmatch) GameMode.
  5. Made by Crusher.
  6. Version 1.0.
  7. First release
  8. */
  9. #include <a_samp>
  10. #define RoundTime 300000
  11. #define MAX_TEAM_KILLS 3
  12. #define COLOR_BASIC 0x0066FFAA
  13. new
  14. Team_1_Life_Players = 0,
  15. Team_2_Life_Players = 0,
  16. Team_1_Score = 0,
  17. Team_2_Score = 0,
  18. RoundTimer,
  19. EndRoundTimer,
  20. RifleRound = 0,
  21. GameStarted = 0,
  22. ALife[MAX_PLAYERS],
  23. TeamKill[MAX_PLAYERS],
  24. Text:Time,
  25. GameEnds = 0,
  26. GameStarts = 0,
  27. Text:textdraw,
  28. Time_0,
  29. Time_1,
  30. Time_2,
  31. Time_3,
  32. Time_4,
  33. Time_5,
  34. Players,
  35. talking;
  36. forward EndGame(playerid);
  37. forward NewGame(playerid);
  38. forward end();
  39. forward start();
  40. forward Time0();
  41. forward Time1();
  42. forward Time2();
  43. forward Time3();
  44. forward Time4();
  45. forward Time5();
  46. forward FailCmd(playerid);
  47. forward SAT(playerid,text[]); //SendAdminText ~ SAT
  48. // '[:. Randoms .:]'
  49. new
  50. Float:Team_1_Random[][6] =
  51. {
  52. // Positions, (X, Y, Z and Facing Angle)
  53. {1764.796,-1924.766,13.228,58.0},
  54. {1797.719,-1894.259,13.063,58.0},
  55. {1716.036,-1932.410,13.229,58.0},
  56. {1708.088,-1883.313,13.229,181.0},
  57. {1694.660,-1892.206,13.229,181.0}
  58. },
  59. Float:Team_2_Random[][5] =
  60. {
  61. // Positions, (X, Y, Z and Facing Angle)
  62. {1802.684,-2072.868,13.225,0.0},
  63. {1786.163,-2072.864,13.225,0.0},
  64. {1751.390,-2060.402,13.225,0.0},
  65. {1690.142,-2072.064,13.254,0.0}
  66. };
  67.  
  68. main() return 1;
  69. public OnGameModeInit()
  70. {
  71. // '[:. Some things .:]'
  72. SetGameModeText("Crushers TDM");
  73. UsePlayerPedAnims();
  74. DisableInteriorEnterExits();
  75. SetNameTagDrawDistance(0.1);
  76. Players = 0;
  77.  
  78. // '[:. Classes .:]'
  79. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); // class id 0
  80. AddPlayerClassEx(1, 1, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); // team1 swat
  81. AddPlayerClassEx(2, 95, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); // team1 army
  82.  
  83. // '[:. Textdraws .:]'
  84. Time = TextDrawCreate(489.000000,120.000000,"~r~0 ~w~Minutes left");
  85. TextDrawAlignment(Time,0);
  86. TextDrawBackgroundColor(Time,0x000000ff);
  87. TextDrawFont(Time,1);
  88. TextDrawLetterSize(Time,0.399999,1.700000);
  89. TextDrawColor(Time,0xffffffff);
  90. TextDrawSetOutline(Time,1);
  91. TextDrawSetProportional(Time,1);
  92. TextDrawSetShadow(Time,1);
  93.  
  94. textdraw = TextDrawCreate(1.000000,7.000000,"~b~ Scores: Team 1: 0, Team 2: 0");
  95. TextDrawAlignment(textdraw,0);
  96. TextDrawFont(textdraw,2);
  97. TextDrawLetterSize(textdraw,0.500000,1.200000);
  98. TextDrawColor(textdraw,COLOR_BASIC);
  99. TextDrawSetProportional(textdraw,1);
  100. TextDrawUseBox(textdraw,1);
  101. TextDrawSetShadow(textdraw,0);
  102. // '[:. Objects .:]'
  103. CreateObject(1655,1689.772,-2010.895,14.148,0.0,0.0,0.0); // object
  104. CreateObject(1655,1689.865,-2004.226,14.125,0.0,0.0,-179.622); // object (1)
  105. CreateObject(16302,1752.060,-1994.067,11.609,0.0,0.0,0.0); // object (3)
  106. CreateObject(16305,1712.518,-1991.709,15.937,0.0,0.0,0.0); // object (4)
  107. CreateObject(972,1687.852,-1881.955,12.529,0.0,0.0,-71.333); // object (5)
  108. CreateObject(972,1709.373,-1874.069,12.564,0.0,0.0,-90.241); // object (6)
  109. CreateObject(972,1725.864,-1876.929,12.556,0.0,0.0,-110.008); // object (7)
  110. CreateObject(972,1813.720,-1885.249,11.111,0.0,0.0,182.578); // object (8)
  111. CreateObject(972,1798.743,-1962.463,11.922,0.0,0.0,126.328); // object (9)
  112. CreateObject(972,1808.385,-1952.639,11.919,0.0,0.0,144.377); // object (10)
  113. CreateObject(972,1678.703,-1964.248,10.544,0.0,0.0,0.095); // object (11)
  114. CreateObject(972,1676.370,-2067.167,11.547,0.0,0.0,0.0); // object (12)
  115. CreateObject(972,1816.439,-2063.288,8.976,0.0,0.0,180.000); // object (13)
  116. CreateObject(969,1813.321,-2057.982,16.226,0.0,0.0,90.000); // object (15)
  117. CreateObject(969,1813.279,-2066.775,16.229,0.0,0.0,90.000); // object (16)
  118. CreateObject(3279,1796.848,-2039.000,12.330,0.0,0.0,22.500); // object (17)
  119. CreateObject(3279,1796.031,-1931.949,12.087,0.0,0.0,22.500); // object (18)
  120. return 1;
  121. }
  122.  
  123. public OnGameModeExit()
  124. {
  125. return 1;
  126. }
  127.  
  128. public EndGame(playerid)
  129. {
  130. GameEnds += 1;
  131. SetPlayerCameraPos(playerid,1678.4041,-2012.7576,21.9542);
  132. SetPlayerCameraLookAt(playerid,1759.4498,-1957.8380,13.5469);
  133. if (Team_1_Life_Players < Team_2_Life_Players)
  134. {
  135. GameTextForPlayer(playerid,"~y~]~w~Team ~r~2 ~b~win~y~]",40000,5);
  136. }
  137. if (Team_2_Life_Players < Team_1_Life_Players)
  138. {
  139. GameTextForPlayer(playerid,"~y~]~w~Team ~r~1 ~b~win~y~]",40000,5);
  140. }
  141. if (Team_1_Life_Players == Team_2_Life_Players)
  142. {
  143. GameTextForPlayer(playerid,"~y~]~w~Draw~y~]~n~~n~~n~~w~The round is draw.",10000,5);
  144. }
  145. EndRoundTimer = SetTimer("NewGame",40000,0);
  146. return 1;
  147. }
  148. public end()
  149. {
  150. GameEnds += 1;
  151. printf("Game stopped!, total games stopped: %d",GameEnds);
  152. TextDrawSetString(Time,"~w~Waiting for~n~ new game");
  153. TextDrawSetString(textdraw,"~b~ Waiting for new game!");
  154. TextDrawShowForAll(textdraw);
  155. TextDrawShowForAll(Time);
  156. GameStarted = 0;
  157. KillTimer(RoundTimer);
  158. KillTimer(Time_5);
  159. KillTimer(Time_4);
  160. KillTimer(Time_3);
  161. KillTimer(Time_2);
  162. KillTimer(Time_1);
  163. KillTimer(Time_0);
  164. RifleRound = 0;
  165. SetTimer("start",40000,0);
  166. for(new i=0; i<MAX_PLAYERS; i++)
  167. {
  168. EndGame(i);
  169. }
  170. return 1;
  171. }
  172. public start()
  173. {
  174. printf("Game started!, total games started: %d",GameStarts);
  175. KillTimer(EndRoundTimer);
  176. GameStarts += 1;
  177. Team_1_Life_Players = 0;
  178. Team_2_Life_Players = 0;
  179. Time_5 = SetTimer("Time5",60,0);
  180. Time_4 = SetTimer("Time4",60000,0);
  181. Time_3 = SetTimer("Time3",120000,0);
  182. Time_2 = SetTimer("Time2",180000,0);
  183. Time_1 = SetTimer("Time1",240000,0);
  184. Time_0 = SetTimer("Time0",290000,0);
  185. SetTimer("end",300000,0);
  186. GameStarted = 1;
  187. for(new i=0; i<MAX_PLAYERS; i++)
  188. {
  189. NewGame(i);
  190. }
  191. TextDrawSetString(textdraw,"~b~ Scores: Team 1: 0, Team 2: 0");
  192. TextDrawShowForAll(textdraw);
  193. TextDrawSetString(Time,"~w~Waiting for ~n~new game...");
  194. TextDrawShowForAll(Time);
  195. return 1;
  196. }
  197. public NewGame(playerid)
  198. {
  199. SetCameraBehindPlayer(playerid);
  200. ResetPlayerWeapons(playerid);
  201.  
  202. TogglePlayerControllable(playerid, 1);
  203. TogglePlayerSpectating(playerid, 0);
  204. ALife[playerid] = 1;
  205. if (RifleRound == 1)
  206. {
  207. SetPlayerHealth(playerid, 15); // health 15%
  208. GivePlayerWeapon(playerid, 33, 50);// rifle ammo 50
  209. }
  210. else
  211. {
  212. SetPlayerHealth(playerid, 40); // health 40%
  213. GivePlayerWeapon(playerid, 28, 100);
  214. GivePlayerWeapon(playerid, 31, 500);
  215. GivePlayerWeapon(playerid, 16, 1);
  216. }
  217.  
  218. if (GetPlayerTeam(playerid) == 1)
  219. {
  220. new iRandom = random(sizeof(Team_1_Random));
  221. SetPlayerPos(playerid,Team_1_Random[iRandom][0],Team_1_Random[iRandom][1],Team_1_Random[iRandom][2]);
  222. SetPlayerFacingAngle(playerid, Team_1_Random[iRandom][3]);
  223.  
  224. Team_1_Life_Players += 1;
  225. GameTextForPlayer(playerid,"~w~Kill the ~r~Army ~w~guys",3000,5);
  226. }
  227. if (GetPlayerTeam(playerid) == 2)
  228. {
  229. new aRandom = random(sizeof(Team_2_Random));
  230. SetPlayerPos(playerid,Team_2_Random[aRandom][0],Team_2_Random[aRandom][1],Team_2_Random[aRandom][2]);
  231. SetPlayerFacingAngle(playerid, Team_2_Random[aRandom][3]);
  232.  
  233. Team_2_Life_Players += 1;
  234. GameTextForPlayer(playerid,"~w~Kill the ~r~S.W.A.T ~w~guys",3000,5);
  235. }
  236. return 1;
  237. }
  238.  
  239. public Time5() { TextDrawSetString(Time,"~r~5 ~w~Minutes left"), TextDrawShowForAll(Time); return 1; }
  240. public Time4() { TextDrawSetString(Time,"~r~4 ~w~Minutes left"), TextDrawShowForAll(Time); return 1; }
  241. public Time3() { TextDrawSetString(Time,"~r~3 ~w~Minutes left"), TextDrawShowForAll(Time); return 1; }
  242. public Time2() { TextDrawSetString(Time,"~r~2 ~w~Minutes left"), TextDrawShowForAll(Time); return 1; }
  243. public Time1() { TextDrawSetString(Time,"~r~1 ~w~Minutes left"), TextDrawShowForAll(Time); return 1; }
  244. public Time0() { TextDrawSetString(Time,"~r~0 ~w~Minutes left"), TextDrawShowForAll(Time); return 1; }
  245.  
  246. public OnPlayerRequestClass(playerid, classid)
  247. {
  248. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  249. SetPlayerCameraPos(playerid, 1959.3783, 135.1572, 15.3746);
  250. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  251. if (classid == 0)
  252. {
  253. GameTextForPlayer(playerid,"~w~Choise an team~n~~b~~<~~>~",3000,5);
  254. }
  255. if (classid == 1)
  256. {
  257. GameTextForPlayer(playerid,"~w~Team~n~~b~1",3000,5);
  258. }
  259. if (classid == 2)
  260. {
  261. GameTextForPlayer(playerid,"~w~Team~n~~b~2",3000,5);
  262. }
  263. return 1;
  264. }
  265.  
  266. public OnPlayerRequestSpawn(playerid)
  267. {
  268. if (GetPlayerSkin(playerid) == 0)
  269. {
  270. ForceClassSelection(playerid);
  271. SetPlayerHealth(playerid,0);
  272. return 1;
  273. }
  274. TogglePlayerSpectating(playerid, 1);
  275. if (GameStarted == 1)
  276. {
  277. if (Team_1_Life_Players == 0 || Team_2_Life_Players == 0)
  278. {
  279. end();
  280. }
  281. SetPlayerCameraPos(playerid,1678.4041,-2012.7576,21.9542);
  282. SetPlayerCameraLookAt(playerid,1759.4498,-1957.8380,13.5469);
  283. GameTextForPlayer(playerid,"~b~W~w~aiting for next round...", 4000, 5);
  284. }
  285. return 1;
  286. }
  287.  
  288. public OnPlayerConnect(playerid)
  289. {
  290. GameTextForPlayer(playerid,"~w~Crushers ~r~TDM~n~~b~Have Fun",5000,5);
  291. ALife[playerid] = 0;
  292. new Name[MAX_PLAYER_NAME];
  293. GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
  294. for(new i=0; i<MAX_PLAYERS; i++)
  295. {
  296. if (IsPlayerConnected(i))
  297. {
  298. new Connects[256];
  299. format(Connects, sizeof(Connects), ".:. %s (ID:%d) has joined the server .:.", Name, playerid);
  300. SendClientMessageToAll(COLOR_BASIC,Connects);
  301. }
  302. }
  303. Players ++;
  304. return 1;
  305. }
  306.  
  307. public OnPlayerDisconnect(playerid, reason)
  308. {
  309. if(GameStarted == 1)
  310. {
  311. if (GetPlayerTeam(playerid) == 1)
  312. {
  313. Team_1_Life_Players -= 1;
  314. }
  315. if (GetPlayerTeam(playerid) == 2)
  316. {
  317. Team_2_Life_Players -= 1;
  318. }
  319. }
  320. new Name[MAX_PLAYER_NAME];
  321. GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
  322. for(new i=0; i<MAX_PLAYERS; i++)
  323. {
  324. if (IsPlayerConnected(i))
  325. {
  326. new Disconnects[256];
  327. format(Disconnects, sizeof(Disconnects), ".:. %s (ID:%d) has leaved the server .:.", Name, playerid);
  328. SendClientMessageToAll(COLOR_BASIC,Disconnects);
  329. }
  330. }
  331. Players --;
  332. return 1;
  333. }
  334.  
  335. public OnPlayerDeath(playerid, killerid, reason)
  336. {
  337. if (GetPlayerTeam(killerid) == GetPlayerTeam(playerid))
  338. {
  339. SetPlayerScore(killerid, GetPlayerScore(killerid)-10);
  340. if (GetPlayerTeam(killerid) == 1)
  341. {
  342. Team_1_Score -= 10;
  343. }
  344. if (GetPlayerTeam(killerid) == 2)
  345. {
  346. Team_2_Score -= 10;
  347. }
  348. TeamKill[killerid] += 1;
  349. if (TeamKill[killerid] == MAX_TEAM_KILLS)
  350. {
  351. new Name[MAX_PLAYER_NAME];
  352. GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
  353. new Reason[256] = "Teamkilling";
  354. for(new i=0; i<MAX_PLAYERS; i++)
  355. {
  356. if (IsPlayerConnected(i))
  357. {
  358. new Connects[256];
  359. format(Connects, sizeof(Connects), ".:. %s (ID:%d) has kicked from the server. the server, reason: %s .:.", Name, playerid, Reason);
  360. SendClientMessageToAll(COLOR_BASIC,Connects);
  361. }
  362. }
  363. SendClientMessage(killerid,COLOR_BASIC,"You are kicked from the server!");
  364. SendClientMessage(killerid,COLOR_BASIC,"Because you have killed team mates!");
  365. TogglePlayerControllable(killerid, 0);
  366. Kick(killerid);
  367. return 1;
  368. }
  369. }
  370. if (GetPlayerTeam(killerid) != GetPlayerTeam(playerid))
  371. {
  372. SetPlayerScore(killerid, GetPlayerScore(killerid)+5);
  373. if (GetPlayerTeam(killerid) == 1)
  374. {
  375. Team_1_Score += 5;
  376. }
  377. if (GetPlayerTeam(killerid) == 2)
  378. {
  379. Team_2_Score += 5;
  380. }
  381. }
  382. if (GetPlayerTeam(playerid) == 1)
  383. {
  384. Team_1_Life_Players -= 1;
  385. }
  386. if (GetPlayerTeam(playerid) == 2)
  387. {
  388. Team_2_Life_Players -= 1;
  389. }
  390. if (Team_1_Life_Players == 0)return end();
  391. if (Team_2_Life_Players == 0)return end();
  392. TogglePlayerSpectating(playerid, 1);
  393. PlayerSpectatePlayer(playerid, killerid);
  394. ALife[playerid] = 0;
  395. new SCOREs[256];
  396. format(SCOREs, sizeof(SCOREs), "~b~ Scores: Team 1: %d, Team 2: %d", Team_1_Score, Team_2_Score);
  397. TextDrawSetString(textdraw,SCOREs);
  398. TextDrawShowForAll(textdraw);
  399. return 1;
  400. }
  401.  
  402. public OnVehicleSpawn(vehicleid)
  403. {
  404. return 1;
  405. }
  406.  
  407. public OnVehicleDeath(vehicleid, killerid)
  408. {
  409. return 1;
  410. }
  411.  
  412. public OnPlayerText(playerid, text[])
  413. {
  414. if(GameStarted == 1)
  415. {
  416. if(talking == 1)
  417. {
  418. return 0;
  419. }
  420. else
  421. {
  422. return 1;
  423. }
  424. }
  425. else
  426. {
  427. return 1;
  428. }
  429. }
  430.  
  431. public OnPlayerPrivmsg(playerid, recieverid, text[])
  432. {
  433. for(new MSG=0; MSG<MAX_PLAYERS; MSG++)
  434. {
  435. if (IsPlayerConnected(MSG))
  436. {
  437. if (IsPlayerAdmin(MSG))
  438. {
  439. new MSGs[256];
  440. format(MSGs, sizeof(MSGs),"Player:%d PM Player: %d, Text: %s",playerid,recieverid,text);
  441. SendClientMessage(MSG,COLOR_BASIC,MSGs);
  442. }
  443. }
  444. }
  445. return 1;
  446. }
  447.  
  448. public OnPlayerCommandText(playerid, cmdtext[])
  449. {
  450. if (strcmp("/kill", cmdtext, true, 10) == 0)
  451. {
  452. SetPlayerHealth(playerid, 0);
  453. SAT(playerid,"Kill");
  454. return 1;
  455. }
  456.  
  457. if (strcmp("/Talk", cmdtext, true, 10) == 0)
  458. {
  459. if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_BASIC,"You are not an rcon admin");
  460. SAT(playerid,"Talk");
  461. if (talking == 1)
  462. {
  463. talking = 0;
  464. SendClientMessageToAll(COLOR_BASIC,"Talk = on!");
  465. }
  466. else
  467. {
  468. talking = 1;
  469. SendClientMessageToAll(COLOR_BASIC,"Talk = off!");
  470. }
  471. return 1;
  472. }
  473.  
  474. if (strcmp("/Rifle", cmdtext, true, 10) == 0)
  475. {
  476. if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_BASIC,"You are not an rcon admin");
  477. if (GameStarted == 1) return SendClientMessage(playerid,COLOR_BASIC,"You must be at the game end to use cmds.");
  478. RifleRound = 1;
  479. SAT(playerid,"Rifle");
  480. SendClientMessageToAll(COLOR_BASIC,"Next round wil be an Rifle Round");
  481. return 1;
  482. }
  483.  
  484. if (strcmp("/Start", cmdtext, true, 10) == 0)
  485. {
  486. if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_BASIC,"You are not an rcon admin");
  487. if (GameStarted == 1) return SendClientMessage(playerid,COLOR_BASIC,"You must be at the game end to use cmds.");
  488. start();
  489. SAT(playerid,"start");
  490. SendClientMessage(playerid,COLOR_BASIC,"New round started!");
  491. return 1;
  492. }
  493.  
  494. return FailCmd(playerid);
  495. }
  496. public SAT(playerid,text[]) //SendAdminText ~ SAT
  497. {
  498. for(new MSG=0; MSG<MAX_PLAYERS; MSG++)
  499. {
  500. if (IsPlayerConnected(MSG))
  501. {
  502. if (IsPlayerAdmin(MSG))
  503. {
  504. new MSGs[256];
  505. format(MSGs, sizeof(MSGs),"Player:%d has used /%s",playerid,text);
  506. SendClientMessage(MSG,COLOR_BASIC,MSGs);
  507. }
  508. }
  509. }
  510. return 1;
  511. }
  512. public FailCmd(playerid)
  513. {
  514. SendClientMessage(playerid,COLOR_BASIC,"UNKNOWN COMMAND USE /HELP");
  515. for(new MSG=0; MSG<MAX_PLAYERS; MSG++)
  516. {
  517. if (IsPlayerConnected(MSG))
  518. {
  519. if (IsPlayerAdmin(MSG))
  520. {
  521. new MSGs[256];
  522. format(MSGs, sizeof(MSGs),"Player:%d Typed an wrong command",playerid);
  523. SendClientMessage(MSG,COLOR_BASIC,MSGs);
  524. }
  525. }
  526. }
  527. return 1;
  528. }
  529. public OnPlayerStateChange(playerid, newstate, oldstate)
  530. {
  531. if (newstate == PLAYER_STATE_DRIVER)
  532. {
  533. GameTextForPlayer(playerid,"~W~you must shoot~N~~R~not drive~n~~w~!!!!!!!!!!!!",5000,5);
  534. RemovePlayerFromVehicle(playerid);
  535. for(new MSG=0; MSG<MAX_PLAYERS; MSG++)
  536. {
  537. if (IsPlayerConnected(MSG))
  538. {
  539. if (IsPlayerAdmin(MSG))
  540. {
  541. new MSGs[256];
  542. format(MSGs, sizeof(MSGs),"Player:%d is kicked from an vehicle",playerid);
  543. SendClientMessage(MSG,COLOR_BASIC,MSGs);
  544. }
  545. }
  546. }
  547. }
  548. return 1;
  549. }
  550.  
Advertisement
Add Comment
Please, Sign In to add comment