Guest User

Gang Zones

a guest
Mar 5th, 2010
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.91 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define COLOR_GREY 0xAFAFAFAA
  4. #define COLOR_RED 0xFF000096
  5. #define COLOR_YELLOW 0xFFFF00AA
  6. #define COLOR_PINK 0xFF66FFAA
  7. #define COLOR_BLUE 0x0000BBAA
  8. #define COLOR_WHITE 0xFFFFFFAA
  9. #define COLOR_ORANGE 0xFF9900AA
  10. #define COLOR_VIOLET 0x9955DEEE
  11. #define COLOR_LEMON 0xDDDD2357
  12. #define COLOR_BLACK 0x00000000
  13. #define COLOR_PINK 0xFF66FFAA
  14. #define COLOR_PURPLE 0x800080AA
  15. #define COLOR_GREEN 0x33AA33AA
  16. #define COLOR_YELLOW 0xFFFF00AA
  17. #define COLOR_WHITE 0xFFFFFFAA
  18. #define COLOR_BROWN 0x993300AA
  19. #define COLOR_LIME 0x99FF00AA
  20. #define COLOR_SYSTEM 0xEFEFF7AA
  21. #define COLOR_AQUA 0x7CFC00AA
  22. #define COLOR_GOLD 0xB8860BAA
  23. #define COLOR_MAV 0xF5704996
  24. #define COLOR_BKV 0xFF800096
  25. #define COLOR_INAS 0x40808096
  26. #define COLOR_TAXI 0xFFFF0096
  27. #define COLOR_MENTOS 0xAE111196
  28. #define COLOR_BANKOS 0x5E5EA296
  29. #define COLOR_RABLO 0x5B9EAC96
  30. #define COLOR_KAMIONOS 0x80FF8096
  31. #define COLOR_ZSARU 0x00408096
  32. #define COLOR_POLITIKUS 0x00FF0096
  33. #define COLOR_KATONA 0x5F772D96
  34. #define COLOR_RIFA 0x00FFFF96
  35. #define COLOR_TRIAD 0x44005596
  36. #define COLOR_MAFFIA 0xFF800096
  37. #define COLOR_DANANG 0x65868796
  38. #define COLOR_NEON 0x00FF00AA
  39. #define COLOR_SYSTEM 0xEFEFF7AA
  40. #define HOMER 0x33AA33AA
  41. #define ORANGE 0xFFFFFFAA
  42.  
  43. #define TEAM_RIFA 0
  44. #define TEAM_TRIAD 1
  45. #define TEAM_MAFFIA 2
  46. #define TEAM_DANANG 3
  47.  
  48. #define dcmd(%1,%2,%3) if((strcmp((%3)[1],#%1,true,(%2))==0)&&((((%3)[(%2)+1]==0)&&(dcmd_%1(playerid,"")))||(((%3)[(%2)+1]==32)&&(dcmd_%1(playerid,(%3)[(%2)+2]))))) return 1
  49.  
  50. #define MAX_TURFS 2
  51. #define MAX_TEAMS 4
  52.  
  53. new msg3[ 256 ];
  54. new pom[128];
  55.  
  56. static gTeam[MAX_PLAYERS];
  57.  
  58. enum teaminfo
  59. {
  60. TeamName[ 32 ],
  61. TeamColor
  62. }
  63.  
  64. new TeamInfo[ MAX_TEAMS ][ teaminfo ]= {
  65. { "Rifa", COLOR_RIFA},
  66. { "Triad", COLOR_TRIAD},
  67. { "Maffia", COLOR_MAFFIA},
  68. { "Danang", COLOR_DANANG}
  69. };
  70.  
  71. #define SLOTS 100
  72.  
  73.  
  74. enum tinfo
  75. {
  76. turfID,
  77. turfName[ 40 ],
  78. Float:zMinX,
  79. Float:zMinY,
  80. Float:zMaxX,
  81. Float:zMaxY,
  82. TurfColor,
  83. TurfOwner,
  84. TurfAttacker,
  85. TurfWarStarted,
  86. attacktime
  87. }
  88.  
  89. new turfs[ MAX_TURFS ][ tinfo ] = {
  90. { 0, "Ganton", -2267.21, -64.74, -1992.96, 124.61, COLOR_TRIAD, TEAM_TRIAD, -1, 0, 0},
  91. { 1, "Ganton", 2222.50, -1722.30, 2632.80, -1628.50, COLOR_TRIAD, TEAM_TRIAD, -1, 0, 0}
  92. };
  93.  
  94. forward isPlayerInArea( playerID, Float:data[ 4 ] );
  95. forward IsPlayerInTurf( playerid, Float:min_x, Float:min_y, Float:max_x, Float:max_y );
  96. forward CheckPlayers( );
  97. forward TimeTextForPlayer( playerid, Text:text, time );
  98. forward DelayTimeTextForPlayer( playerid, Text:text, time );
  99. forward DestroyTextTimer( playerid, Text:text );
  100.  
  101. public OnGameModeInit()
  102. {
  103. for (new t=0; t<MAX_TURFS; t++)
  104. {
  105. GangZoneCreate( turfs[ t ][zMinX], turfs[ t ][zMinY], turfs[ t ][zMaxX], turfs[ t ][zMaxY] );
  106. }
  107.  
  108. SetTimer( "CheckPlayers", 1000, 1 );
  109. return 1;
  110. }
  111.  
  112.  
  113. dcmd_attack(playerid,params[]) {
  114. #pragma unused params
  115. new Float:x, Float:y, Float:z;
  116. new killerteam = gTeam[playerid];
  117. GetPlayerPos(playerid, x, y, z);
  118.  
  119. for (new i = 0; i < MAX_TURFS; i++)
  120. {
  121. if (IsPlayerInTurf(playerid, turfs[i][zMinX], turfs[i][zMinY], turfs[i][zMaxX], turfs[i][zMaxY]) )
  122. {
  123. if (turfs[ i ][ TurfWarStarted ] != 1 && !IsPlayerInAnyVehicle(playerid))
  124. {
  125. turfs[ i ][ TurfAttacker ] = killerteam;
  126. GangZoneFlashForAll(turfs[ i ][turfID],COLOR_RED);
  127. for (new b=0; b<SLOTS; b++)
  128. {
  129. if (gTeam[b] == turfs[ i ][ TurfAttacker ])
  130. {
  131. new msg1[ 256 ];
  132. format(msg1,sizeof(msg1), "~w~We have provokated a gang war for %s with ~r~%s ~w~gang.",
  133. turfs[ i ][ turfName ], TeamInfo[ turfs[ i ][ TurfOwner ] ][ TeamName ]);
  134. new Text:txt1 = TextDrawCreate( 200.0, 385.0, msg1 );
  135. TextDrawFont( txt1, 0 );
  136. TextDrawSetShadow( txt1, 0 );
  137. TextDrawSetOutline( txt1, 1 );
  138. TextDrawColor( txt1, 0xDFDFDFFF );
  139. TimeTextForPlayer( b, txt1, 6000 );
  140. GangZoneFlashForPlayer( b, turfs[ i ][turfID], COLOR_RED );
  141. }
  142. else if (gTeam[b] == turfs[ i ][ TurfOwner ])
  143. {
  144. new msg2[ 256 ];
  145. format(msg2,sizeof(msg2), "Team ~y~%s ~r~has attacked our~y~%s~r~gang zone!",
  146. TeamInfo[ turfs[ i ][ TurfAttacker ] ][ TeamName ], turfs[ i ][ turfName ]);
  147. new Text:txt2 = TextDrawCreate( 200.0, 370.0, msg2 );
  148. TextDrawFont( txt2, 0 );
  149. TextDrawSetShadow( txt2, 0 );
  150. TextDrawSetOutline( txt2, 1 );
  151. TextDrawColor( txt2, COLOR_RED );
  152. TimeTextForPlayer( b, txt2, 6000 );
  153. GangZoneFlashForPlayer( b, turfs[ i ][turfID], COLOR_RED );
  154. }
  155. turfs[ i ][ TurfWarStarted ] = 1;
  156. turfs[i][attacktime] = 120000;
  157. }
  158. }
  159. }
  160. }
  161. return true;
  162. }
  163.  
  164. public OnPlayerCommandText(playerid, cmdtext[])
  165. {
  166. dcmd(attack,6,cmdtext);
  167. return 0;
  168. }
  169.  
  170. public isPlayerInArea(playerID, Float:data[4])
  171. {
  172. new Float:X, Float:Y, Float:Z;
  173.  
  174. GetPlayerPos(playerID, X, Y, Z);
  175. if(X >= data[0] && X <= data[2] && Y >= data[1] && Y <= data[3]) {
  176. return 1;
  177. }
  178. return 0;
  179. }
  180. //==============================================================================
  181.  
  182. public IsPlayerInTurf(playerid,Float:min_x,Float:min_y,Float:max_x,Float:max_y)
  183. {
  184. new Float:X,Float:Y,Float:Z;
  185. GetPlayerPos(playerid, X, Y, Z);
  186. if((X <= max_x && X >= min_x) && (Y <= max_y && Y >= min_y)) return 1;
  187. return 0;
  188. }
  189. //==============================================================================
  190.  
  191. public TimeTextForPlayer( playerid, Text:text, time )
  192. {
  193. TextDrawShowForPlayer( playerid, text );
  194. SetTimerEx( "DestroyTextTimer", time, 0, "ii", playerid, _:text );
  195. }
  196. //------------------------------------------------------------------------------
  197.  
  198. public DelayTimeTextForPlayer( playerid, Text:text, time )
  199. {
  200. SetTimerEx( "TimeTextForPlayer", time, 0, "iii", playerid, _:text, 4000 );
  201. }
  202. //------------------------------------------------------------------------------
  203.  
  204. public DestroyTextTimer( playerid, Text:text )
  205. {
  206. TextDrawDestroy( text );
  207. }
  208.  
  209.  
  210. FlashZoneForPlayer( playerid )
  211. {
  212. for (new i = 0; i < MAX_TURFS; i++)
  213. {
  214. if (turfs[ i ][ TurfWarStarted ] == 1)
  215. {
  216. if (gTeam[playerid] == turfs[ i ][ TurfAttacker ]) GangZoneFlashForPlayer( playerid, i, COLOR_RED );
  217. else if (gTeam[playerid] == turfs[ i ][ TurfOwner ]) GangZoneFlashForPlayer( playerid, i, COLOR_RED );
  218. else GangZoneFlashForPlayer( playerid, i, COLOR_RED );
  219. }
  220. }
  221. }
  222.  
  223. public CheckPlayers( )
  224. {
  225. for (new i = 0; i < MAX_TURFS; i++)
  226. {
  227. for (new g = 0; g < SLOTS; g++)
  228. {
  229. for (new a = 0; a < SLOTS; a++)
  230. {
  231. for (new d = 0; d < SLOTS; d++)
  232. {
  233. if (turfs[ i ][ TurfWarStarted ] == 1)
  234. {
  235. if(gTeam[g] == TEAM_RIFA || gTeam[g] == TEAM_TRIAD || gTeam[g] == TEAM_DANANG || gTeam[g] == TEAM_MAFFIA)
  236. {
  237. if (gTeam[a] == turfs[ i ][ TurfAttacker ])
  238. {
  239. if (gTeam[d] == turfs[ i ][ TurfOwner ])
  240. {
  241.  
  242. if (turfs[ i ][ attacktime ] > 0)
  243. {
  244. if (IsPlayerInTurf(a, turfs[i][zMinX], turfs[i][zMinY], turfs[i][zMaxX], turfs[i][zMaxY] ))
  245. {
  246. SendClientMessage(105,COLOR_RED,"FUCK YOU!!!!!");
  247. }else{
  248. GangZoneStopFlashForAll(i);
  249. SendClientMessage(a,COLOR_RED,"We have lost the war");
  250. format(msg3,sizeof(msg3), "~g~We have defended the ~y~%s ~g~zone.", turfs[ i ][ turfName ]);
  251. new Text:txt3 = TextDrawCreate(200.0, 355.0, msg3);
  252. TextDrawFont( txt3, 0 );
  253. TextDrawSetShadow( txt3, 0 );
  254. TextDrawSetOutline( txt3, 1 );
  255. TextDrawColor( txt3, COLOR_GREEN );
  256. TimeTextForPlayer( d, txt3, 6000 );
  257. }
  258. }
  259.  
  260. if (1 > turfs[ i ][ attacktime ])
  261. {
  262. if (IsPlayerInTurf(d, turfs[i][zMinX], turfs[i][zMinY], turfs[i][zMaxX], turfs[i][zMaxY]))
  263. {
  264. SendClientMessage(a,COLOR_YELLOW,"Kill the rival gang members");
  265. SendClientMessage(d,COLOR_YELLOW,"Kill the rival gang members");
  266. }else{
  267. GangZoneStopFlashForAll(i);
  268. SendClientMessage(d,COLOR_RED,"We have lost the war");
  269. format(msg3,sizeof(msg3), "~g~We have get ~y~%s ~g~zone.", turfs[ i ][ turfName ]);
  270. new Text:txt3 = TextDrawCreate(200.0, 355.0, msg3);
  271. TextDrawFont( txt3, 0 );
  272. TextDrawSetShadow( txt3, 0 );
  273. TextDrawSetOutline( txt3, 1 );
  274. TextDrawColor( txt3, COLOR_GREEN );
  275. TimeTextForPlayer( d, txt3, 6000 );
  276. turfs[ i ][ TurfOwner ] = a;
  277. turfs[ i ][ TurfColor ] = GetPlayerColor(a);
  278. GangZoneShowForPlayer(g, i, turfs[ i ][ TurfColor ] );
  279. turfs[ i ][ TurfAttacker ] = -1;
  280. }
  281. }
  282.  
  283. }
  284. }
  285. }
  286. }
  287. }
  288. }
  289. }
  290. }
  291. }
  292.  
  293. public SecondTimer()
  294. {
  295. for (new i = 0; i < MAX_TURFS; i++)
  296. {
  297. for (new b=0; b<SLOTS; b++)
  298. {
  299. if (gTeam[b] == turfs[ i ][ TurfAttacker ] || gTeam[b] == turfs[ i ][ TurfOwner ])
  300. {
  301. if(turfs[i][attacktime] > 0)
  302. {
  303. turfs[i][attacktime]--;
  304. }
  305. if(turfs[i][attacktime]<60)
  306. {
  307. if(turfs[i][attacktime]<10)
  308. format(pom,sizeof(pom),"~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~g~~w~00:0%d",turfs[i][attacktime]);
  309. else
  310. format(pom,sizeof(pom),"~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~g~~w~00:%d",turfs[i][attacktime]);
  311. }else{
  312. new minutes = floatround(turfs[i][attacktime]/60);
  313. new seconds = turfs[i][attacktime]-minutes*60;
  314. if(minutes < 10 && seconds < 10)
  315. format(pom,sizeof(pom),"~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~g~~w~0%d:0%d",minutes,seconds);
  316. else if(minutes < 10 && seconds >= 10)
  317. format(pom,sizeof(pom),"~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~g~~w~0%d:%d",minutes,seconds);
  318. else if(minutes >= 10 && seconds < 10)
  319. format(pom,sizeof(pom),"~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~g~~w~%d:0%d",minutes,seconds);
  320. else if(minutes >= 10 && seconds >= 10)
  321. format(pom,sizeof(pom),"~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~g~~w~%d:%d",minutes,seconds);
  322. }
  323.  
  324. GameTextForPlayer(b,pom,2000,3);
  325.  
  326. if(0>turfs[i][attacktime])
  327. {
  328. turfs[i][attacktime] = 0;
  329. }
  330.  
  331. }
  332. }
  333. }
  334. return 1;
  335. }
Advertisement
Add Comment
Please, Sign In to add comment