[Tutorial] Gang Zone Wars
#22

I have a problem.

I used the first method. I followed all the steps. Everything is ok until you start by war, going on rival territory but nothing happens.

Below is what I am introduced to GM for gang wars


1.
pawn Code:
AddPlayerClass(113, 1124.2415, -2037.1274, 69.8847, 269.15, 7, 1, 24, 60, 0, 0);
AddPlayerClass(120, -2192.3020, 646.8816, 49.4375, 269.15, 8, 1, 24, 60, 0, 0);
2.
Code:
#define TEAM_LCN 1 
#define TEAM_YAKUZA 2 
#define TAKEOVER_TIME 300 
#define MIN_MEMBERS_TO_START_WAR 1
3.
Code:
static gTeam[MAX_PLAYERS];
4.
Code:
public SetPlayerTeamFromClass(playerid,classid)
{
 	if (classid == 0)
	{
  		gTeam[playerid] = TEAM_LCN;
	}
	else
	{
  		gTeam[playerid] = TEAM_YAKUZA;
	}
}
5.
Code:
if (gTeam[playerid] == TEAM_LCN)
{
	SetPlayerColor(playerid, COLOR_LCN);
}
else if (gTeam[playerid] == TEAM_YAKUZA)
{
	SetPlayerColor(playerid, COLOR_YKZ);
}
6.
Code:
enum eZone
{
    Float:zMinX,
    Float:zMinY,
    Float:zMaxX,
    Float:zMaxY,
    zTeam
}
new ZoneInfo[][eZone] = {
    {-2263.0850,52.9664,-2355.4988,-178.6447,TEAM_LCN}, // Teritoriu factiunea 1 (LCN)
    {-2150.3877,313.4182,-2241.1433,102.3497,TEAM_YAKUZA} // Teritoriu factiunea 2 (Yakuza)
};
new ZoneID[sizeof(ZoneInfo)];
7.
Code:
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]));
}
8.
Code:
for(new i=0; i < sizeof(ZoneInfo); i++)
{
	ZoneID[i] = GangZoneCreate(ZoneInfo[i][zMinX], ZoneInfo[i][zMinY], ZoneInfo[i][zMaxX], ZoneInfo[i][zMaxY]);
}
9.
Code:
stock GetTeamZoneColor(teamid)
{
    switch(teamid)
    {
        case TEAM_LCN: return 0x00FF0088;
        case TEAM_YAKUZA: return 0xFF00FF88;
    }
    return -1;
}
10.
Code:
new ZoneAttacker[sizeof(ZoneInfo)] = {-1, ...};
new ZoneAttackTime[sizeof(ZoneInfo)];
11.
Code:
new Teams[] = {
    TEAM_LCN,
    TEAM_YAKUZA
};
12.
Code:
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) && IsALcn(i) == teamid && IsAYakuza(i) == teamid && IsPlayerInZone(i, zoneid))
        {
            count++;
        }
    }
    return count;
}
13.
Code:
SetTimer("ZoneTimer", 1000, true);
14.
Code:
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]));
                }
            }
        }
    }
}
Reply


Messages In This Thread
Gang Zone Wars - by MadeMan - 13.08.2011, 13:38
Re: Gang Zone Wars - by Darnell - 13.08.2011, 13:48
Re: Gang Zone Wars - by emokidx - 13.08.2011, 15:36
AW: Gang Zone Wars - by samtey - 13.08.2011, 16:18
Re: Gang Zone Wars - by CoLLYY - 13.08.2011, 22:22
AW: Gang Zone Wars - by samtey - 14.08.2011, 17:37
Re: Gang Zone Wars - by Darnell - 14.08.2011, 18:04
Re: AW: Gang Zone Wars - by MadeMan - 14.08.2011, 20:45
Re: Gang Zone Wars - by CoLLYY - 16.08.2011, 10:21
Re: Gang Zone Wars - by SpiderWalk - 16.08.2011, 10:23
Re: Gang Zone Wars - by DeadAhead - 16.08.2011, 10:24
Re: Gang Zone Wars - by MaTrIx4057 - 16.08.2011, 11:04
Re: Gang Zone Wars - by RaZvY - 28.08.2011, 11:15
Re: Gang Zone Wars - by qUick1337 - 03.09.2011, 17:01
Re: Gang Zone Wars - by davve95 - 03.09.2011, 17:23
Re: Gang Zone Wars - by Davz*|*Criss - 03.09.2011, 22:02
Re: Gang Zone Wars - by MadeMan - 04.09.2011, 08:29
Re: Gang Zone Wars - by RaZvY - 08.09.2011, 22:22
Re: Gang Zone Wars - by Anzhelov - 09.09.2011, 08:55
Re: Gang Zone Wars - by eemalekorraks - 11.09.2011, 17:10
Respuesta: Gang Zone Wars - by ||ponpon|| - 11.09.2011, 18:18
Re: Gang Zone Wars - by R3dX - 12.11.2011, 08:42
Re: Gang Zone Wars - by MadeMan - 12.11.2011, 12:48
Re: Gang Zone Wars - by Naruto_Emilio - 18.11.2011, 15:14
Re: Gang Zone Wars - by Astralis - 18.11.2011, 16:15
Re: Gang Zone Wars - by DawioX - 24.01.2012, 12:33
Re: Gang Zone Wars - by dickyodie - 01.02.2012, 09:26
Re: Respuesta: Gang Zone Wars - by Dustly - 01.03.2012, 00:30
Re: Gang Zone Wars - by GNGification - 03.03.2012, 09:43
Re: Gang Zone Wars - by susuke97 - 16.08.2012, 11:38
Re: Gang Zone Wars - by Arxalan - 04.01.2015, 04:07
Re: Gang Zone Wars - by Cr3dO - 07.02.2015, 17:10
Re: Gang Zone Wars - by Tookapack - 26.02.2015, 01:19
Re: Gang Zone Wars - by Ugaustin - 24.06.2015, 10:12
Re: Gang Zone Wars - by Ugaustin - 24.06.2015, 20:11
Re: Gang Zone Wars - by Ugaustin - 25.06.2015, 17:27
Re: Gang Zone Wars - by TonyCan - 06.06.2016, 08:34
Re: Gang Zone Wars - by iamjems - 14.10.2016, 23:02
Re: Gang Zone Wars - by Oxygenated - 30.04.2017, 13:06

Forum Jump:


Users browsing this thread: 13 Guest(s)