Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 22nd, 2012  |  syntax: None  |  size: 5.64 KB  |  hits: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. enum eZone (!!!!!!!!!!!!!!ALL THIS IS CREting zones until the line!!!!!!!!!!!!!)
  2. {
  3.     Float:zMinX,
  4.     Float:zMinY,
  5.     Float:zMaxX,
  6.     Float:zMaxY,
  7.     zTeam
  8. }
  9. new ZoneInfo[][eZone] = {
  10.     {2337.9004,-1808.8383,2590.2043,-1610.3673,TEAM_GROVE},
  11.     {2084.7,-1808.8383,2337.9004,-1610.3673,TEAM_BALLAS},
  12.     {2590.2043,-1808.8383,2842.3,-1610.3673,TEAM_VAGOS}
  13. };
  14. new ZoneID[sizeof(ZoneInfo)];
  15. for(new i=0; i < sizeof(ZoneInfo); i++)
  16. {
  17.     ZoneID[i] = GangZoneCreate(ZoneInfo[i][zMinX], ZoneInfo[i][zMinY], ZoneInfo[i][zMaxX], ZoneInfo[i][zMaxY]);
  18. }
  19. for(new i=0; i < sizeof(ZoneInfo); i++)
  20. {
  21.     GangZoneShowForPlayer(playerid, ZoneID[i], GetTeamZoneColor(ZoneInfo[i][zTeam]));
  22. }
  23. stock GetTeamZoneColor(teamid)
  24. {
  25.     switch(teamid)
  26.     {
  27.         case TEAM_GROVE: return 0x00FF0088;
  28.         case TEAM_BALLAS: return 0xFF00FF88;
  29.         case TEAM_VAGOS: return 0xFFFF0088;
  30.     }
  31.     return -1;
  32. }
  33.  
  34. ---------------------------------------------------------------------------------------------------
  35.  
  36. new ZoneAttacker[sizeof(ZoneInfo)] = {-1, ...};
  37. new ZoneAttackTime[sizeof(ZoneInfo)];
  38. for(new i=0; i < sizeof(ZoneInfo); i++)
  39. {
  40.     GangZoneShowForPlayer(playerid, ZoneID[i], GetTeamZoneColor(ZoneInfo[i][zTeam]));
  41.     if(ZoneAttacker[i] != -1) GangZoneFlashForPlayer(playerid, ZoneID[i], GetTeamZoneColor(ZoneAttacker[i]));
  42. }
  43. new Teams[] = {
  44.     (ur teams here)
  45. };
  46. stock IsPlayerInZone(playerid, zoneid)
  47. {
  48.     new Float:x, Float:y, Float:z;
  49.     GetPlayerPos(playerid, x, y, z);
  50.     return (x > ZoneInfo[zoneid][zMinX] && x < ZoneInfo[zoneid][zMaxX] && y > ZoneInfo[zoneid][zMinY] && y < ZoneInfo[zoneid][zMaxY]);
  51. }
  52.  
  53. stock GetPlayersInZone(zoneid, teamid)
  54. {
  55.     new count;
  56.     for(new i=0; i < MAX_PLAYERS; i++)
  57.     {
  58.         if(IsPlayerConnected(i) && GetPlayerTeam(i) == teamid && IsPlayerInZone(i, zoneid))
  59.         {
  60.             count++;
  61.         }
  62.     }
  63.     return count;
  64. }
  65. SetTimer("ZoneTimer", 1000, true);
  66.  
  67. public ZoneTimer()
  68. {
  69.     for(new i=0; i < sizeof(ZoneInfo); i++) // loop all zones
  70.     {
  71.         if(ZoneAttacker[i] != -1) // zone is being attacked
  72.         {
  73.             if(GetPlayersInZone(i, ZoneAttacker[i]) >= MIN_MEMBERS_TO_START_WAR) // team has enough members in the zone
  74.             {
  75.                 ZoneAttackTime[i]++;
  76.                 if(ZoneAttackTime[i] == TAKEOVER_TIME) // zone has been under attack for enough time and attackers take over the zone
  77.                 {
  78.                     GangZoneStopFlashForAll(ZoneID[i]);
  79.                     ZoneInfo[i][zTeam] = ZoneAttacker[i];
  80.                     GangZoneShowForAll(ZoneID[i], GetTeamZoneColor(ZoneInfo[i][zTeam])); // update the zone color for new team
  81.                     ZoneAttacker[i] = -1;
  82.                 }
  83.             }
  84.             else // attackers failed to take over the zone
  85.             {
  86.                 GangZoneStopFlashForAll(ZoneID[i]);
  87.                 ZoneAttacker[i] = -1;
  88.             }
  89.         }
  90.         else // check if somebody is attacking
  91.         {
  92.             for(new t=0; t < sizeof(Teams); t++) // loop all teams
  93.             {
  94.                 if(Teams[t] != ZoneInfo[i][zTeam] && GetPlayersInZone(i, Teams[t]) >= MIN_MEMBERS_TO_START_WAR) // if there are enough enemies in the zone
  95.                 {
  96.                     ZoneAttacker[i] = Teams[t];
  97.                     ZoneAttackTime[i] = 0;
  98.                     GangZoneFlashForAll(ZoneID[i], GetTeamZoneColor(ZoneAttacker[i]));
  99.                 }
  100.             }
  101.         }
  102.     }
  103. }
  104.  ((ATTACKING ZONE 2 )) ANYTHING LIKE THIS DONT ADD TO THE CODE -.-
  105. #define TAKEOVER_TIME 120 // how many seconds needed to take over the zone
  106. #define MIN_DEATHS_TO_START_WAR 3 // how many team members must be killed in a zone to start a war
  107. SetTimer("ZoneTimer", 1000, true);
  108. public ZoneTimer()
  109. {
  110.     for(new i=0; i < sizeof(ZoneInfo); i++) // loop all zones
  111.     {
  112.         if(ZoneAttacker[i] != -1) // zone is being attacked
  113.         {
  114.             if(GetPlayersInZone(i, ZoneAttacker[i]) >= 1) // there must be at least 1 attacker left
  115.             {
  116.                 ZoneAttackTime[i]++;
  117.                 if(ZoneAttackTime[i] == TAKEOVER_TIME) // zone has been under attack for enough time and attackers take over the zone
  118.                 {
  119.                     GangZoneStopFlashForAll(ZoneID[i]);
  120.                     ZoneInfo[i][zTeam] = ZoneAttacker[i];
  121.                     GangZoneShowForAll(ZoneID[i], GetTeamZoneColor(ZoneInfo[i][zTeam])); // update the zone color for new team
  122.                     ZoneAttacker[i] = -1;
  123.                 }
  124.             }
  125.             else // attackers failed to take over the zone
  126.             {
  127.                 GangZoneStopFlashForAll(ZoneID[i]);
  128.                 ZoneAttacker[i] = -1;
  129.             }
  130.         }
  131.     }
  132. }
  133. if(IsPlayerConnected(killerid) && GetPlayerTeam(playerid) != GetPlayerTeam(killerid)) // not a suicide or team kill
  134. {
  135.     new zoneid = GetPlayerZone(playerid);
  136.     if(zoneid != -1 && ZoneInfo[zoneid][zTeam] == GetPlayerTeam(playerid)) // zone member has been killed in the zone
  137.     {
  138.         ZoneDeaths[zoneid]++;
  139.         if(ZoneDeaths[zoneid] == MIN_DEATHS_TO_START_WAR)
  140.         {
  141.             ZoneDeaths[zoneid] = 0;
  142.             ZoneAttacker[zoneid] = GetPlayerTeam(killerid);
  143.             ZoneAttackTime[zoneid] = 0;
  144.             GangZoneFlashForAll(ZoneID[zoneid], GetTeamZoneColor(ZoneAttacker[zoneid]));
  145.         }
  146.     }
  147. }
  148. new ZoneDeaths[sizeof(ZoneInfo)];
  149. stock GetPlayerZone(playerid)
  150. {
  151.     for(new i=0; i < sizeof(ZoneInfo); i++)
  152.     {
  153.         if(IsPlayerInZone(playerid, i))
  154.         {
  155.             return i;
  156.         }
  157.     }
  158.     return -1;
  159. }
  160.  
  161.  
  162.  
  163. ((done but thts the attacking zones just add the teams names and all the coords