Help: Gang Zones Color
#1

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:

PHP код:
enum eZone
{
    
Float:zMinX,
    
Float:zMinY,
    
Float:zMaxX,
    
Float:zMaxY,
    
zTeam,
}
new 
ZoneInfo[][eZone] = {
    {-
2155.1960, -108.1418, -1992.9630124.6110,TEAM_MAFIA}, //TEAM_MAFIA},
    
{-2155.1960124.6110, -1992.9630353.4189TEAM_MAFIA}, //TEAM_MAFIA},
    
{-1992.9630, -108.1418, -1799.8289353.4189TEAM_MAFIA}, //TEAM_MAFIA},
    
{-2247.9008120.6660, -2155.1960353.4189TEAM_MAFIA}, //TEAM_MAFIA},
    
{-2807.9899353.4189, -2518.2890590.1168TEAM_BIKER}, //TEAM_BIKER},
    
{-2807.9899590.1168, -2518.2890740.0255TEAM_BIKER}, //TEAM_BIKER},
    
{-2518.2890353.4189, -2267.2141594.0618TEAM_BIKER}, //TEAM_BIKER},
    
{-2518.2890594.0618, -2267.2141743.9703TEAM_BIKER}, //TEAM_BIKER},
    
{-2510.5629743.9703, -2267.2141842.5944TEAM_BIKER}, //TEAM_BIKER},
    
{-1989.1009353.4189, -1726.4379463.8779TEAM_SWAT}, //TEAM_SWAT},
    
{-1992.9630463.8779, -1726.4379617.7316TEAM_SWAT}, //TEAM_SWAT},
    
{-1726.4379455.9880, -1529.4410661.1262TEAM_SWAT}, //TEAM_SWAT},
    
{-2000.6889617.7316, -1714.8499759.7503TEAM_SWAT}, //TEAM_SWAT},
    
{-1695.5369755.8052, -1417.4229854.4293TEAM_SWAT}, //TEAM_SWAT},
    
{-2251.76291154.2469, -1826.86801296.2650TEAM_CIVILES}, //TEAM_CIVILES},
    
{-1726.4379274.5197, -1208.8380455.9880TEAM_SOLDADOS}, //TEAM_SOLDADOS},
    
    
{-2641.8950, -368.5094, -2259.4890, -194.9311TEAM_NEGROS}, //TEAM_NEGROS},
    
{-2807.9899, -431.6289, -2641.8950, -194.9311TEAM_NEGROS}, //TEAM_NEGROS},
    
{-2807.9899, -194.9311, -2406.2709, -52.9123TEAM_NEGROS}, //TEAM_NEGROS},
    
{-2406.2709, -194.9311, -2155.1960120.6660TEAM_NEGROS}, //TEAM_NEGROS},
    
    
{-2502.83781158.1920, -2247.90081359.3850TEAM_PIMP}, //TEAM_PIMP},
    
{-2742.32391047.7330, -2502.83781359.3850TEAM_PIMP}, //TEAM_PIMP},
    
{-2831.16601118.7419, -2742.32391367.2750TEAM_PIMP}, //TEAM_PIMP},
    
{-2247.90081296.2650, -1842.31891505.3489TEAM_NANG}, //TEAM_NANG},
    
{-1502.40191449.6789, -1332.44391568.4680TEAM_NANG}, //TEAM_NANG},
    
{-1626.00801047.7330, -1452.18791288.3750TEAM_NANG}, //TEAM_NANG},
    
{-1695.5369850.4843, -1409.69791047.7330TEAM_NANG}, //TEAM_NANG},
    
{-1830.73091047.7330, -1626.00801296.2650TEAM_NANG}, //TEAM_NANG},
    
{-2510.5629842.5944, -2267.21411043.7879TEAM_RICH}, //TEAM_RICH},
    
{-2742.3239949.1085, -2506.69991047.7330TEAM_RICH}, //TEAM_RICH},
    
{-2807.9899949.1085, -2742.32391118.7419TEAM_RICH}, //TEAM_RICH},
    
{-2502.83781043.7879, -2267.21411158.1920TEAM_RICH}, //TEAM_RICH},
    
{-2267.2141968.8333, -1989.10091158.1920TEAM_RICH}, //TEAM_RICH},
    
    
{-2807.9899, -52.9123, -2595.5419160.1157TEAM_NEGROS}, //TEAM_NEGROS},
    
{-2807.9899160.1157, -2684.3840353.4189TEAM_NEGROS}, //TEAM_NEGROS},
    
{-2406.2709120.6660, -2247.9008353.4189TEAM_MAFIA}, //TEAM_MAFIA},
    
{-2124.2949353.4189, -1989.1009617.7316TEAM_MAFIA}, //TEAM_MAFIA},
    
{-2587.8168160.1157, -2406.2709353.4189TEAM_MAFIA}, //TEAM_MAFIA},
    
    
{-618.9274, -782.4177, -385.3699, -595.5717TEAM_MECHANIC}, //TEAM_MECHANIC},
    
{-934.2299, -992.6193, -618.9274, -560.5380TEAM_MECHANIC}, //TEAM_MECHANIC},
    
{-1191.1429, -759.0618, -934.2299, -432.0813TEAM_MECHANIC}, //TEAM_MECHANIC},
    
    
{-595.5717, -256.9132, -408.7255, -46.7114TEAM_FARMERS}, //TEAM_FARMERS},
    
{-887.5186, -256.9132, -595.5717, -46.7114TEAM_FARMERS}, //TEAM_FARMERS},
    
{-887.5186, -46.7114, -408.7255128.4566TEAM_FARMERS}, //TEAM_FARMERS},
    
{-1734.1639, -680.1616, -1191.1429, -432.0813TEAM_SOLDADOS}, //TEAM_SOLDADOS},},
    
{-1726.4379, -432.0813, -1386.521957.5466TEAM_SOLDADOS},  //TEAM_SOLDADOS},},
    
{-1726.437957.5466, -1123.8590274.5197TEAM_SOLDADOS}, //TEAM_SOLDADOS},},
    
{-1386.5219, -432.0813, -1123.859057.5466TEAM_SOLDADOS}, //TEAM_SOLDADOS},},
    
{-1803.6920, -108.1418, -1726.4379353.4189TEAM_SOLDADOS}, //TEAM_SOLDADOS},},
    
    
{-2267.2141767.6401, -1989.1009968.8333,TEAM_CIVILES}, //TEAM_CIVILES},
    
{-1989.1009759.7503, -1830.73091158.1920TEAM_CIVILES}, //TEAM_CIVILES},},
    
{-2124.2949617.7316, -1989.1009767.6401TEAM_CIVILES}, //TEAM_CIVILES},},
    
{-2267.2141353.4189, -2124.2949586.1718,TEAM_BIKER}, //TEAM_BIKER},},
    
{-618.9274, -1027.6529, -362.0140, -852.4849TEAM_FARMERS}, //TEAM_FARMERS},
    
{-618.9274, -1191.1429, -467.1149, -1027.6529,TEAM_FARMERS}, //TEAM_FARMERS},
    
{-782.4177, -1191.1429, -618.9274, -992.6193TEAM_FARMERS}, //TEAM_FARMERS},
    
    
{-2159.059, -171.2613, -2008.414, -52.91238TEAM_MARAS}, //TEAM_MARAS},
    
{-2232.45, -475.0236, -1992.963, -254.1056TEAM_MARAS}, //TEAM_MARAS},
    
{-2004.552, -277.7754, -1819.143, -48.96741TEAM_MARAS}, //TEAM_MARAS},
    
{-2000.689, -435.5739, -1830.731, -305.3901TEAM_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=0sizeof(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=0sizeof(ZoneInfo); i++)
{
    
GangZoneShowForPlayer(playeridZoneID[i], GetTeamZoneColor(ZoneInfo[i][zTeam]));
    if(
ZoneAttacker[i] != -1GangZoneFlashForPlayer(playeridZoneID[i], GetTeamZoneColor(ZoneAttacker[i]));
}
return 
1;
}
public 
ZoneTimer()
{
    for(new 
i=0sizeof(ZoneInfo); i++) // loop all zones
    
{
        if(
ZoneAttacker[i] != -1// zone is being attacked
        
{
            if(
GetPlayersInZone(iZoneAttacker[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=0sizeof(Teams); t++) // loop all teams
            
{
                if(
Teams[t] != ZoneInfo[i][zTeam] && GetPlayersInZone(iTeams[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(playeridzoneid)
{
    new 
Float:xFloat:yFloat:z;
    
GetPlayerPos(playeridxyz);
    return (
ZoneInfo[zoneid][zMinX] && ZoneInfo[zoneid][zMaxX] && ZoneInfo[zoneid][zMinY] && ZoneInfo[zoneid][zMaxY]);
}
stock GetPlayersInZone(zoneidteamid)
{
    new 
count;
    for(new 
i=0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i) && GetPlayerTeam(i) == teamid && IsPlayerInZone(izoneid))
        {
            
count++;
        }
    }
    return 
count;
}
stock GetPlayerZone(playerid)
{
    for(new 
i=0sizeof(ZoneInfo); i++)
    {
        if(
IsPlayerInZone(playeridi))
        {
            return 
i;
        }
    }
    return -
1;

Reply
#2

Just do this:
PHP код:
/*Top of script*/
#define TEAM_MAFIA 0x69696999;
#define TEAM_BIKER 0xFF660099;
/*etc...*/
/*replace yours with*/  
GangZoneShowForPlayer(playeridZoneID[i], ZoneInfo[i][zTeam]); 
That way it is storing the gangs color to zTeam already, the way you have it right now, you haven't defined your team ids, which means when you're assigning them, they're all equal to 0, hence why you're getting the same color.
Reply
#3

Quote:
Originally Posted by ItsRobinson
Посмотреть сообщение
Just do this:
PHP код:
/*Top of script*/
#define TEAM_MAFIA 0x69696999;
#define TEAM_BIKER 0xFF660099;
/*etc...*/
/*replace yours with*/  
GangZoneShowForPlayer(playeridZoneID[i], ZoneInfo[i][zTeam]); 
That way it is storing the gangs color to zTeam already, the way you have it right now, you haven't defined your team ids, which means when you're assigning them, they're all equal to 0, hence why you're getting the same color.
thank you very much friend (i copy it), but I am talking about when you attack a base and it flashes when changing color, it keeps the previous color and superposes the new color of your team. Can you help me? +rep
Reply
#4

GangZoneFlashForAll

I can't remember if this flashes white and then the color you set or the current color and then the new color, give it a go though.

If it's not what you're after (which I think is the current gang holding color flashing with the attacking gang) then you can set a timer to loop ever second that sets the color back and forth (performance hit on the server probably wouldn't be worth it though)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)