27.11.2018, 18:07
hello guys, I have a problem with the gang zones when I conquer a territory is superimposed one color to another and it is not the same color as the rest of the gang zones of my team, why does this happen?
this my code:
this my code:
PHP код:
enum eZone
{
Float:zMinX,
Float:zMinY,
Float:zMaxX,
Float:zMaxY,
zTeam,
}
new ZoneInfo[][eZone] = {
{-2155.1960, -108.1418, -1992.9630, 124.6110,TEAM_MAFIA}, //TEAM_MAFIA},
{-2155.1960, 124.6110, -1992.9630, 353.4189, TEAM_MAFIA}, //TEAM_MAFIA},
{-1992.9630, -108.1418, -1799.8289, 353.4189, TEAM_MAFIA}, //TEAM_MAFIA},
{-2247.9008, 120.6660, -2155.1960, 353.4189, TEAM_MAFIA}, //TEAM_MAFIA},
{-2807.9899, 353.4189, -2518.2890, 590.1168, TEAM_BIKER}, //TEAM_BIKER},
{-2807.9899, 590.1168, -2518.2890, 740.0255, TEAM_BIKER}, //TEAM_BIKER},
{-2518.2890, 353.4189, -2267.2141, 594.0618, TEAM_BIKER}, //TEAM_BIKER},
{-2518.2890, 594.0618, -2267.2141, 743.9703, TEAM_BIKER}, //TEAM_BIKER},
{-2510.5629, 743.9703, -2267.2141, 842.5944, TEAM_BIKER}, //TEAM_BIKER},
{-1989.1009, 353.4189, -1726.4379, 463.8779, TEAM_SWAT}, //TEAM_SWAT},
{-1992.9630, 463.8779, -1726.4379, 617.7316, TEAM_SWAT}, //TEAM_SWAT},
{-1726.4379, 455.9880, -1529.4410, 661.1262, TEAM_SWAT}, //TEAM_SWAT},
{-2000.6889, 617.7316, -1714.8499, 759.7503, TEAM_SWAT}, //TEAM_SWAT},
{-1695.5369, 755.8052, -1417.4229, 854.4293, TEAM_SWAT}, //TEAM_SWAT},
{-2251.7629, 1154.2469, -1826.8680, 1296.2650, TEAM_CIVILES}, //TEAM_CIVILES},
{-1726.4379, 274.5197, -1208.8380, 455.9880, TEAM_SOLDADOS}, //TEAM_SOLDADOS},
{-2641.8950, -368.5094, -2259.4890, -194.9311, TEAM_NEGROS}, //TEAM_NEGROS},
{-2807.9899, -431.6289, -2641.8950, -194.9311, TEAM_NEGROS}, //TEAM_NEGROS},
{-2807.9899, -194.9311, -2406.2709, -52.9123, TEAM_NEGROS}, //TEAM_NEGROS},
{-2406.2709, -194.9311, -2155.1960, 120.6660, TEAM_NEGROS}, //TEAM_NEGROS},
{-2502.8378, 1158.1920, -2247.9008, 1359.3850, TEAM_PIMP}, //TEAM_PIMP},
{-2742.3239, 1047.7330, -2502.8378, 1359.3850, TEAM_PIMP}, //TEAM_PIMP},
{-2831.1660, 1118.7419, -2742.3239, 1367.2750, TEAM_PIMP}, //TEAM_PIMP},
{-2247.9008, 1296.2650, -1842.3189, 1505.3489, TEAM_NANG}, //TEAM_NANG},
{-1502.4019, 1449.6789, -1332.4439, 1568.4680, TEAM_NANG}, //TEAM_NANG},
{-1626.0080, 1047.7330, -1452.1879, 1288.3750, TEAM_NANG}, //TEAM_NANG},
{-1695.5369, 850.4843, -1409.6979, 1047.7330, TEAM_NANG}, //TEAM_NANG},
{-1830.7309, 1047.7330, -1626.0080, 1296.2650, TEAM_NANG}, //TEAM_NANG},
{-2510.5629, 842.5944, -2267.2141, 1043.7879, TEAM_RICH}, //TEAM_RICH},
{-2742.3239, 949.1085, -2506.6999, 1047.7330, TEAM_RICH}, //TEAM_RICH},
{-2807.9899, 949.1085, -2742.3239, 1118.7419, TEAM_RICH}, //TEAM_RICH},
{-2502.8378, 1043.7879, -2267.2141, 1158.1920, TEAM_RICH}, //TEAM_RICH},
{-2267.2141, 968.8333, -1989.1009, 1158.1920, TEAM_RICH}, //TEAM_RICH},
{-2807.9899, -52.9123, -2595.5419, 160.1157, TEAM_NEGROS}, //TEAM_NEGROS},
{-2807.9899, 160.1157, -2684.3840, 353.4189, TEAM_NEGROS}, //TEAM_NEGROS},
{-2406.2709, 120.6660, -2247.9008, 353.4189, TEAM_MAFIA}, //TEAM_MAFIA},
{-2124.2949, 353.4189, -1989.1009, 617.7316, TEAM_MAFIA}, //TEAM_MAFIA},
{-2587.8168, 160.1157, -2406.2709, 353.4189, TEAM_MAFIA}, //TEAM_MAFIA},
{-618.9274, -782.4177, -385.3699, -595.5717, TEAM_MECHANIC}, //TEAM_MECHANIC},
{-934.2299, -992.6193, -618.9274, -560.5380, TEAM_MECHANIC}, //TEAM_MECHANIC},
{-1191.1429, -759.0618, -934.2299, -432.0813, TEAM_MECHANIC}, //TEAM_MECHANIC},
{-595.5717, -256.9132, -408.7255, -46.7114, TEAM_FARMERS}, //TEAM_FARMERS},
{-887.5186, -256.9132, -595.5717, -46.7114, TEAM_FARMERS}, //TEAM_FARMERS},
{-887.5186, -46.7114, -408.7255, 128.4566, TEAM_FARMERS}, //TEAM_FARMERS},
{-1734.1639, -680.1616, -1191.1429, -432.0813, TEAM_SOLDADOS}, //TEAM_SOLDADOS},},
{-1726.4379, -432.0813, -1386.5219, 57.5466, TEAM_SOLDADOS}, //TEAM_SOLDADOS},},
{-1726.4379, 57.5466, -1123.8590, 274.5197, TEAM_SOLDADOS}, //TEAM_SOLDADOS},},
{-1386.5219, -432.0813, -1123.8590, 57.5466, TEAM_SOLDADOS}, //TEAM_SOLDADOS},},
{-1803.6920, -108.1418, -1726.4379, 353.4189, TEAM_SOLDADOS}, //TEAM_SOLDADOS},},
{-2267.2141, 767.6401, -1989.1009, 968.8333,TEAM_CIVILES}, //TEAM_CIVILES},
{-1989.1009, 759.7503, -1830.7309, 1158.1920, TEAM_CIVILES}, //TEAM_CIVILES},},
{-2124.2949, 617.7316, -1989.1009, 767.6401, TEAM_CIVILES}, //TEAM_CIVILES},},
{-2267.2141, 353.4189, -2124.2949, 586.1718,TEAM_BIKER}, //TEAM_BIKER},},
{-618.9274, -1027.6529, -362.0140, -852.4849, TEAM_FARMERS}, //TEAM_FARMERS},
{-618.9274, -1191.1429, -467.1149, -1027.6529,TEAM_FARMERS}, //TEAM_FARMERS},
{-782.4177, -1191.1429, -618.9274, -992.6193, TEAM_FARMERS}, //TEAM_FARMERS},
{-2159.059, -171.2613, -2008.414, -52.91238, TEAM_MARAS}, //TEAM_MARAS},
{-2232.45, -475.0236, -1992.963, -254.1056, TEAM_MARAS}, //TEAM_MARAS},
{-2004.552, -277.7754, -1819.143, -48.96741, TEAM_MARAS}, //TEAM_MARAS},
{-2000.689, -435.5739, -1830.731, -305.3901, TEAM_MARAS} //TEAM_MARAS},
};
new ZoneID[sizeof(ZoneInfo)];
new ZoneAttacker[sizeof(ZoneInfo)] = {-1, ...};
new ZoneAttackTime[sizeof(ZoneInfo)];
new ZoneDeaths[sizeof(ZoneInfo)];
new Teams[] = {
TEAM_NEGROS,
TEAM_CIVILES,
TEAM_MAFIA,
TEAM_NANG,
TEAM_SWAT,
TEAM_MARAS,
TEAM_BIKER,
TEAM_RICH,
TEAM_FARMERS,
TEAM_MECHANIC,
TEAM_PIMP,
TEAM_SOLDADOS
};
public OnGameModeInit()
{
for(new i=0; i < sizeof(ZoneInfo); i++)
{
ZoneID[i] = GangZoneCreate(ZoneInfo[i][zMinX], ZoneInfo[i][zMinY], ZoneInfo[i][zMaxX], ZoneInfo[i][zMaxY]);
}
return 1;
}
public OnPlayerSpawn(playerid)
{
for(new i=0; i < sizeof(ZoneInfo); i++)
{
GangZoneShowForPlayer(playerid, ZoneID[i], GetTeamZoneColor(ZoneInfo[i][zTeam]));
if(ZoneAttacker[i] != -1) GangZoneFlashForPlayer(playerid, ZoneID[i], GetTeamZoneColor(ZoneAttacker[i]));
}
return 1;
}
public ZoneTimer()
{
for(new i=0; i < sizeof(ZoneInfo); i++) // loop all zones
{
if(ZoneAttacker[i] != -1) // zone is being attacked
{
if(GetPlayersInZone(i, ZoneAttacker[i]) >= MIN_MEMBERS_TO_START_WAR) // team has enough members in the zone
{
ZoneAttackTime[i]++;
if(ZoneAttackTime[i] == TAKEOVER_TIME) // zone has been under attack for enough time and attackers take over the zone
{
GangZoneStopFlashForAll(ZoneID[i]);
ZoneInfo[i][zTeam] = ZoneAttacker[i];
GangZoneShowForAll(ZoneID[i], GetTeamZoneColor(ZoneInfo[i][zTeam])); // update the zone color for new team
ZoneAttacker[i] = -1;
}
}
else // attackers failed to take over the zone
{
GangZoneStopFlashForAll(ZoneID[i]);
ZoneAttacker[i] = -1;
}
}
else // check if somebody is attacking
{
for(new t=0; t < sizeof(Teams); t++) // loop all teams
{
if(Teams[t] != ZoneInfo[i][zTeam] && GetPlayersInZone(i, Teams[t]) >= MIN_MEMBERS_TO_START_WAR) // if there are enough enemies in the zone
{
ZoneAttacker[i] = Teams[t];
ZoneAttackTime[i] = 0;
GangZoneFlashForAll(ZoneID[i], GetTeamZoneColor(ZoneAttacker[i]));
}
}
}
}
}
stock GetTeamZoneColor(teamid)
{
switch(teamid)
{
case TEAM_NEGROS: return 0x99660099;
case TEAM_CIVILES: return 0xF5F5F599;
case TEAM_MAFIA: return 0x69696999;
case TEAM_NANG: return 0xB2222299;
case TEAM_SWAT: return 0x00990099;
case TEAM_MARAS: return 0xFFD70099;
case TEAM_BIKER: return 0xFF660099;
case TEAM_RICH: return 0xFF996699;
case TEAM_FARMERS: return 0x9ACD3299;
case TEAM_MECHANIC: return 0x4169E199;
case TEAM_PIMP: return 0xA52A2A99;
case TEAM_SOLDADOS: return 0x33660099;
}
return -1;
}
stock IsPlayerInZone(playerid, zoneid)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
return (x > ZoneInfo[zoneid][zMinX] && x < ZoneInfo[zoneid][zMaxX] && y > ZoneInfo[zoneid][zMinY] && y < ZoneInfo[zoneid][zMaxY]);
}
stock GetPlayersInZone(zoneid, teamid)
{
new count;
for(new i=0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && GetPlayerTeam(i) == teamid && IsPlayerInZone(i, zoneid))
{
count++;
}
}
return count;
}
stock GetPlayerZone(playerid)
{
for(new i=0; i < sizeof(ZoneInfo); i++)
{
if(IsPlayerInZone(playerid, i))
{
return i;
}
}
return -1;
}