Advertisement
Guest User

Untitled

a guest
Nov 16th, 2011
1,149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.18 KB | None | 0 0
  1. /******************\
  2. *__________________*
  3. |*Capture the flag*|
  4. ____________________
  5. |*By Ronnie 'Moadi' Pearce*|
  6. ********************************/
  7.  
  8. #include <a_samp>
  9. #include <zcmd>
  10. #include <sscanf2>
  11. #define FILTERSCRIPT
  12.  
  13. #define CBLUE "{39AACC}"
  14. #define CDGREEN "{6FA828}"
  15. #define CWHITE "{FFFFFF}"
  16. #define CRED "{FF0000}"
  17.  
  18. #define COLOR_RED 0xFF0000FF
  19. #define COLOR_GREEN 0x008000FF
  20. #define COLOR_LIGHTBLUE 0xADD8E6FF
  21. #define COLOR_AQUA 0x00FFFFFF
  22. #define COLOR_WHITE 0xFFFFFFAA
  23. #define COLOR_BLUE 0x2641FEAA
  24. #define COLOR_LIGHTRED 0xFF6347AA
  25. #define COLOR_DARKGREEN 0x006400FF
  26.  
  27. new
  28. ob[4];
  29.  
  30. new
  31. ison,pctp[MAX_PLAYERS],ctpu[2],ctpup,flag[MAX_PLAYERS],skin[MAX_PLAYERS],egun,egun1,ptslimit,
  32. Float:ctx[MAX_PLAYERS],Float:cty[MAX_PLAYERS],Float:ctz[MAX_PLAYERS],Float:cth[MAX_PLAYERS],Float:ctarm[MAX_PLAYERS],ctint[MAX_PLAYERS],ctvw[MAX_PLAYERS];
  33. enum cTp
  34. {
  35. red,
  36. blue
  37. }
  38. new pts[cTp];
  39.  
  40. new
  41. Float:randomctp[][4] =
  42. {
  43. {1340.2469,-1172.0527,369.1609,180.1620},
  44. {1341.4927,-1362.7784,369.8609,2.6931}
  45. };
  46.  
  47. new
  48. randomc[] =
  49. {
  50. 1,
  51. 2
  52. };
  53.  
  54. public OnFilterScriptInit()
  55. {
  56. ob[0] = CreateObject(13607,1343.09997559,-1364.19995117,371.70001221,0.00000000,0.00000000,0.00000000); //object(ringwalls) (1)
  57. ob[1] = CreateObject(7445,1340.19995117,-1266.90002441,368.29998779,0.00000000,0.00000000,0.00000000); //object(vegasnroad39) (1)
  58. ob[2] = CreateObject(13607,1339.50000000,-1167.00000000,371.70001221,0.00000000,0.00000000,0.00000000); //object(ringwalls) (2)
  59. ob[3] = CreateObject(2914,1340.0812,-1267.0023,372.1815,0.0,0.0,0.0,10);
  60. return 1;
  61. }
  62.  
  63. public OnFilterScriptExit()
  64. {
  65. DestroyObject(ob[0]);
  66. DestroyObject(ob[1]);
  67. DestroyObject(ob[2]);
  68. DestroyObject(ob[3]);
  69. return 1;
  70. }
  71. //;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  72. public OnPlayerDeath(playerid,killerid,reason)
  73. {
  74. if(pctp[playerid] == 1)
  75. {
  76. new rand = random(sizeof(randomctp));
  77. new team;
  78. team = GetPlayerTeam(playerid);
  79. SetSpawnInfo(playerid,team,0,randomctp[rand][0],randomctp[rand][1],randomctp[rand][2],randomc[rand],egun,500,egun1,500,0,0);
  80. SetPlayerHealth(playerid,90);
  81. SpawnPlayer(playerid);
  82. if(GetPlayerTeam(playerid) == 1)
  83. {
  84. SetPlayerSkin(playerid,292);
  85. }
  86. if(GetPlayerTeam(playerid) == 2)
  87. {
  88. SetPlayerSkin(playerid,0);
  89. }
  90. }
  91.  
  92. if(flag[playerid] == 1)
  93. {
  94. new
  95. pname[MAX_PLAYER_NAME],
  96. str[128];
  97. GetPlayerName(playerid,pname,sizeof(pname));
  98. format(str,sizeof(str),"Capture the flag: %s has dropped the flag!",pname);
  99. RemovePlayerAttachedObject(playerid,0);
  100. flag[playerid] = 0;
  101. for(new i=0; i<MAX_PLAYERS; i++)
  102. {
  103. if(pctp[i]==1)
  104. {
  105. SendClientMessage(i,COLOR_GREEN,str);
  106. }
  107. }
  108. }
  109. return 1;
  110. }
  111. //;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  112. public OnPlayerPickUpPickup(playerid, pickupid)
  113. {
  114. if(pctp[playerid] == 1)
  115. {
  116. if(ison == 1)
  117. {
  118. if(pickupid == ctpup)
  119. {
  120. new
  121. pname[MAX_PLAYER_NAME];
  122. GetPlayerName(playerid,pname,sizeof(pname));
  123. if(GetPlayerTeam(playerid) == 1)
  124. {
  125. new str[128];
  126. format(str,sizeof(str),"Capture the flag:"CBLUE"[Blue team] %s"CDGREEN" has picked up the flag!",pname);
  127. flag[playerid] = 1;
  128. SetPlayerCheckpoint(playerid,1340.2469,-1172.0527,369.1609,2);
  129. SetPlayerAttachedObject( playerid, 0, 2914, 15, 0.014013, 0.077415, -0.424313, 354.422760, 358.421966, 92.942932, 1.000000, 1.000000, 1.000000 );
  130. for(new i=0; i<MAX_PLAYERS; i++)
  131. {
  132. if(pctp[i] == 1)
  133. {
  134. SendClientMessage(playerid,COLOR_GREEN,str);
  135. }
  136. }
  137. }
  138. if(GetPlayerTeam(playerid) == 2)
  139. {
  140. new str[128];
  141. format(str,sizeof(str),"Capture the flag: "CRED"[Red team] %s"CDGREEN" has picked up the flag!",pname);
  142. flag[playerid] = 1;
  143. SetPlayerCheckpoint(playerid,1341.4927,-1362.7784,369.8609,2);
  144. SetPlayerAttachedObject( playerid, 0, 2914, 15, 0.014013, 0.077415, -0.424313, 354.422760, 358.421966, 92.942932, 1.000000, 1.000000, 1.000000 );
  145. for(new i=0; i<MAX_PLAYERS; i++)
  146. {
  147. if(pctp[i] == 1)
  148. {
  149. SendClientMessage(playerid,COLOR_GREEN,str);
  150. }
  151. }
  152. }
  153. }
  154. //------------------------------------------------------------------------------
  155. if(pickupid == ctpu[0])
  156. {
  157. if(GetPlayerTeam(playerid) == 1)
  158. {
  159. if(flag[playerid] == 1)
  160. {
  161. new
  162. pname[MAX_PLAYER_NAME],
  163. str[128];
  164. GetPlayerName(playerid,pname,sizeof(pname));
  165. flag[playerid] = 0;
  166. pts[blue] ++;
  167. new
  168. strpt[128];
  169. RemovePlayerAttachedObject(playerid,0);
  170. format(strpt,sizeof(strpt),"Capture the flag: "CBLUE"Blue"CDGREEN" team points: %i",pts[blue]);
  171. format(str,sizeof(str),"Capture the flag: "#CBLUE"%s "CDGREEN"has successfully delivered the flag to his base!",pname);
  172. for(new i=0; i<MAX_PLAYERS; i++)
  173. {
  174. if(pctp[i] == 1)
  175. {
  176. SendClientMessage(playerid,COLOR_GREEN,str);
  177. SendClientMessage(playerid,COLOR_GREEN,strpt);
  178. }
  179. }
  180. }
  181. if(pts[blue] == ptslimit)
  182. {
  183. DestroyPickup(ctpu[0]);
  184. DestroyPickup(ctpu[1]);
  185. DestroyPickup(ctpup);
  186. new
  187. wstr[128];
  188. format(wstr,sizeof(wstr),"Capture the flag: Blue team points: %i - Red team points: %i.",pts[blue],pts[red]);
  189. SendClientMessageToAll(COLOR_GREEN,wstr);
  190. if(pts[blue] > pts[red])
  191. {
  192. SendClientMessageToAll(COLOR_GREEN,"Capture the flag: Blue team won the match!");
  193. }
  194. if(pts[red] > pts[blue])
  195. {
  196. SendClientMessageToAll(COLOR_GREEN,"Capture the flag: Red team won the match!");
  197. }
  198. pts[red] = 0;
  199. pts[blue] = 0;
  200. for(new i=0; i<MAX_PLAYERS; i++)
  201. {
  202. if(pctp[i] == 1)
  203. {
  204. SetPlayerPos(i,ctx[i],cty[i],ctz[i]);
  205. SetPlayerArmour(i,ctarm[i]);
  206. SetPlayerHealth(i,cth[i]);
  207. SetPlayerInterior(i,ctint[i]);
  208. SetPlayerVirtualWorld(i,ctvw[i]);
  209. SetPlayerColor(i,COLOR_WHITE);
  210. ResetPlayerWeapons(i);
  211. SetPlayerTeam(i,0);
  212. pctp[i] = 0;
  213. flag[i] = 0;
  214. ison = 0;
  215. }
  216. }
  217. }
  218. }
  219. }
  220. //------------------------------------------------------------------------------
  221. if(pickupid == ctpu[1])
  222. {
  223. if(GetPlayerTeam(playerid) == 2)
  224. {
  225. if(flag[playerid] == 1)
  226. {
  227. new
  228. pname[MAX_PLAYER_NAME],
  229. str[128];
  230. GetPlayerName(playerid,pname,sizeof(pname));
  231. flag[playerid] = 0;
  232. pts[red] ++;
  233. RemovePlayerAttachedObject(playerid,0);
  234. new
  235. strpt[128];
  236. format(strpt,sizeof(strpt),"Capture the flag: "CRED"Red "CDGREEN"team points: %i",pts[red]);
  237. format(str,sizeof(str),"Capture the flag: "#CRED"%s "#CDGREEN"has successfully delivered the flag to his base!",pname);
  238. for(new i=0; i<MAX_PLAYERS; i++)
  239. {
  240. if(pctp[i] == 1)
  241. {
  242. SendClientMessage(playerid,COLOR_GREEN,str);
  243. SendClientMessage(playerid,COLOR_GREEN,strpt);
  244. }
  245. }
  246. }
  247. if(pts[red] == ptslimit)
  248. {
  249. DestroyPickup(ctpu[0]);
  250. DestroyPickup(ctpu[1]);
  251. DestroyPickup(ctpup);
  252. new
  253. wstr[128];
  254. format(wstr,sizeof(wstr),"Capture the flag: Blue team points: %i - Red team points: %i.",pts[blue],pts[red]);
  255. SendClientMessageToAll(COLOR_GREEN,wstr);
  256. if(pts[blue] > pts[red])
  257. {
  258. SendClientMessageToAll(COLOR_GREEN,"Capture the flag: Blue team won the match!");
  259. }
  260. if(pts[red] > pts[blue])
  261. {
  262. SendClientMessageToAll(COLOR_GREEN,"Capture the flag: Red team won the match!");
  263. }
  264. pts[red] = 0;
  265. pts[blue] = 0;
  266. for(new i=0; i<MAX_PLAYERS; i++)
  267. {
  268. if(pctp[i] == 1)
  269. {
  270. SetPlayerPos(i,ctx[i],cty[i],ctz[i]);
  271. SetPlayerArmour(i,ctarm[i]);
  272. SetPlayerHealth(i,cth[i]);
  273. SetPlayerInterior(i,ctint[i]);
  274. SetPlayerVirtualWorld(i,ctvw[i]);
  275. SetPlayerColor(i,COLOR_WHITE);
  276. ResetPlayerWeapons(i);
  277. SetPlayerTeam(i,0);
  278. pctp[i] = 0;
  279. flag[i] = 0;
  280. ison = 0;
  281. }
  282. }
  283. }
  284. }
  285. }
  286. }
  287. }
  288. return 1;
  289. }
  290. //;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  291. public OnPlayerEnterCheckpoint(playerid)
  292. {
  293. DisablePlayerCheckpoint(playerid);
  294. return 1;
  295. }
  296. //;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  297. CMD:ctp(playerid,params[])
  298. {
  299. if(isnull(params)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"USAGE: /ctp [join/quit/start/end]");
  300. if(ison == 1)
  301. {
  302. if(!strcmp(params,"join"))
  303. {
  304. if(pctp[playerid] == 1) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"You are already inside of an event!");
  305. else
  306. {
  307. new rand = random(sizeof(randomctp));
  308. new randc = random(sizeof(randomc));
  309. new
  310. pname[MAX_PLAYER_NAME],
  311. str[128];
  312. GetPlayerName(playerid,pname,sizeof(pname));
  313. GetPlayerPos(playerid,ctx[playerid],cty[playerid],ctz[playerid]);
  314. GetPlayerHealth(playerid,cth[playerid]);
  315. GetPlayerArmour(playerid,ctarm[playerid]);
  316. skin[playerid]=GetPlayerSkin(playerid);
  317. SetPlayerPos(playerid,randomctp[rand][0],randomctp[rand][1],randomctp[rand][2]);
  318. SetPlayerTeam(playerid,randomc[randc]);
  319. if(GetPlayerTeam(playerid) == 1)
  320. {
  321. SetPlayerSkin(playerid,292);
  322. SetPlayerColor(playerid,COLOR_BLUE);
  323. }
  324. if(GetPlayerTeam(playerid) == 0)
  325. {
  326. SetPlayerSkin(playerid,0);
  327. SetPlayerColor(playerid,COLOR_RED);
  328. }
  329. SetPlayerFacingAngle(playerid,randomctp[rand][3]);
  330. ctint[playerid] = GetPlayerInterior(playerid);
  331. ctvw[playerid] = GetPlayerVirtualWorld(playerid);
  332. ResetPlayerWeapons(playerid);
  333. SetPlayerInterior(playerid,15);
  334. SetPlayerVirtualWorld(playerid,15);
  335. GivePlayerWeapon(playerid,egun,5000);
  336. GivePlayerWeapon(playerid,egun1,5000);
  337. SetPlayerArmour(playerid,0);
  338. SetPlayerHealth(playerid,80);
  339.  
  340. format(str,sizeof(str),"%s has joined the event!",pname);
  341.  
  342. pctp[playerid] = 1;
  343. for(new i = 0; i<MAX_PLAYERS; i++)
  344. {
  345. if(pctp[i] == 1)
  346. {
  347. SendClientMessage(i,COLOR_GREEN,str);
  348. }
  349. }
  350. }
  351. }
  352. if(!strcmp(params,"quit"))
  353. {
  354. if(pctp[playerid] == 1)
  355. {
  356. new
  357. pname[MAX_PLAYER_NAME],
  358. str[128];
  359. GetPlayerName(playerid,pname,sizeof(pname));
  360. SetPlayerPos(playerid,ctx[playerid],cty[playerid],ctz[playerid]);
  361. SetPlayerArmour(playerid,ctarm[playerid]);
  362. SetPlayerHealth(playerid,cth[playerid]);
  363. SetPlayerInterior(playerid,ctint[playerid]);
  364. SetPlayerVirtualWorld(playerid,ctvw[playerid]);
  365. ResetPlayerWeapons(playerid);
  366. SetPlayerTeam(playerid,0);
  367. SetPlayerColor(playerid,COLOR_WHITE);
  368. format(str,sizeof(str),"%s has quitted the event!",pname);
  369. pctp[playerid] = 0;
  370. for(new i=0; i<MAX_PLAYERS; i++)
  371. {
  372. if(pctp[i] == 1)
  373. {
  374. SendClientMessage(i,COLOR_DARKGREEN,str);
  375. }
  376. }
  377. }
  378. }
  379. }
  380. if(!strcmp(params,"start"))
  381. {
  382. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"You are not authorized to use this command!");
  383. else
  384. {
  385. if(ison == 1) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"You cannot start an event before finishing the current one!");
  386. else
  387. {
  388. new
  389. pname[MAX_PLAYER_NAME],
  390. str[128];
  391. GetPlayerName(playerid,pname,sizeof(pname));
  392. format(str,sizeof(str),"An event has been started by administrator %s, type (/ctp join)",pname);
  393. SendClientMessageToAll(COLOR_AQUA,str);
  394. ison = 1;
  395. ctpu[0] = CreatePickup(1318,1,1340.2469,-1172.0527,369.1609,15);
  396. ctpu[1] = CreatePickup(1318,1,1341.4927,-1362.7784,369.8609,15);
  397. ctpup = CreatePickup(1254,2,1340.0812,-1267.0023,372.1815,15);
  398. }
  399. }
  400. }
  401. if(!strcmp(params,"end"))
  402. {
  403. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"You are not authorized to use this command!");
  404. if(ison == 0) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"There are no events going on at the mean while!");
  405. else
  406. {
  407. new
  408. pname[MAX_PLAYER_NAME],
  409. str[128];
  410. ison = 0;
  411. GetPlayerName(playerid,pname,sizeof(pname));
  412. format(str,sizeof(str),"The current event has been finished by administrator %s",pname);
  413. SendClientMessageToAll(COLOR_LIGHTRED,str);
  414. DestroyPickup(ctpu[0]);
  415. DestroyPickup(ctpu[1]);
  416. DestroyPickup(ctpup);
  417. new
  418. wstr[128];
  419. format(wstr,sizeof(wstr),"Capture the flag: Blue team points: %i - Red team points: %i.",pts[blue],pts[red]);
  420. SendClientMessageToAll(COLOR_GREEN,wstr);
  421. if(pts[blue] > pts[red])
  422. {
  423. SendClientMessageToAll(COLOR_GREEN,"Capture the flag: Blue team won the match!");
  424. }
  425. if(pts[red] > pts[blue])
  426. {
  427. SendClientMessageToAll(COLOR_GREEN,"Capture the flag: Red team won the match!");
  428. }
  429. pts[red] = 0;
  430. pts[blue] = 0;
  431. for(new i=0; i<MAX_PLAYERS; i++)
  432. {
  433. if(pctp[i] == 1)
  434. {
  435. SetPlayerPos(i,ctx[i],cty[i],ctz[i]);
  436. SetPlayerArmour(i,ctarm[i]);
  437. SetPlayerHealth(i,cth[i]);
  438. SetPlayerInterior(i,ctint[i]);
  439. SetPlayerVirtualWorld(i,ctvw[i]);
  440. SetPlayerColor(i,COLOR_WHITE);
  441. ResetPlayerWeapons(i);
  442. SetPlayerTeam(i,0);
  443. pctp[i] = 0;
  444. flag[i] = 0;
  445. }
  446. }
  447. }
  448. }
  449. if(!strcmp(params,"lock"))
  450. {
  451. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"You are not authorized to use this command!");
  452. if(ison == 1)
  453. {
  454. new
  455. pname[MAX_PLAYER_NAME],
  456. str[128];
  457. ison = 3;
  458. GetPlayerName(playerid,pname,sizeof(pname));
  459. format(str,sizeof(str),"The current event has been locked by administrator %s",pname);
  460. SendClientMessageToAll(COLOR_GREEN,str);
  461. }
  462. }
  463. if(!strcmp(params,"unlock"))
  464. {
  465. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"You are not authorized to use this command!");
  466. if(ison == 3)
  467. {
  468. new
  469. pname[MAX_PLAYER_NAME],
  470. str[128];
  471. ison = 1;
  472. GetPlayerName(playerid,pname,sizeof(pname));
  473. format(str,sizeof(str),"The current event has been unlocked by administrator %s",pname);
  474. SendClientMessageToAll(COLOR_GREEN,str);
  475. }
  476. }
  477. return 1;
  478. }
  479. //;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  480. CMD:ctpset(playerid,params[])
  481. {
  482. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"You are not authrozied to use this command!");
  483. new
  484. value[10],
  485. ammount;
  486. if(sscanf(params,"s[10]i",value,ammount)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"USAGE:/ctpset [gun1/gun2/limit] [gunid/ammount]");
  487. if(!strcmp(value,"gun1"))
  488. {
  489. egun = ammount;
  490. new str[128];
  491. format(str,sizeof(str),"CTP: You have set the event's gun1 to %i",ammount);
  492. SendClientMessage(playerid,COLOR_LIGHTRED,str);
  493. }
  494. if(!strcmp(value,"gun2"))
  495. {
  496. egun1 = ammount;
  497. new str[128];
  498. format(str,sizeof(str),"CTP: You have set the event's gun2 to %i",ammount);
  499. SendClientMessage(playerid,COLOR_LIGHTRED,str);
  500. }
  501. if(!strcmp(value,"limit"))
  502. {
  503. ptslimit = ammount;
  504. new str[128];
  505. format(str,sizeof(str),"CTP: You have set the event's captured flags limit to %i",ammount);
  506. SendClientMessage(playerid,COLOR_LIGHTRED,str);
  507. }
  508.  
  509.  
  510. return 1;
  511. }
  512.  
  513.  
  514.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement