14.07.2011, 16:07
pawn Код:
GetMembersInZone(zoneid, team)
{
new count = 0;
new Float:px, Float:py, Float:pz;
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GetPlayerState(i) != PLAYER_STATE_WASTED && gTeam[i] == team)
{
GetPlayerPos(i, px, py, pz);
if(px > ZoneInfo[zoneid][z_minx] && py > ZoneInfo[zoneid][z_miny] && px < ZoneInfo[zoneid][z_maxx] && py < ZoneInfo[zoneid][z_maxy])
{
count++;
}
}
}
}
return count;
}
GetTeamColor(team)
{
switch(team)
{
case TEAM_PIMP: return 0xEE30A7A96;
case TEAM_STONER: return 0x8E232396;
case TEAM_PILOT: return 0x0000FF96;
case TEAM_AREA69: return 0x00FF0096;
case TEAM_TRUCKER: return 0xFF990096;
case TEAM_LUMBERJACK: return 0xA6A60096;
case TEAM_AMMUNATIONGUY: return 0x458B0096;
case TEAM_JAYS: return 0xFFFFFF96;
case TEAM_REDNECK: return 0x0000BB96;
}
return 0;
}
stock GetPlayerZone(playerid)
{
if(GetPlayerState(playerid) != PLAYER_STATE_WASTED)
{
new Float:px, Float:py, Float:pz;
GetPlayerPos(playerid, px, py, pz);
for(new i=0; i<MAX_ZONES; i++)
{
if(px > ZoneInfo[i][z_minx] && py > ZoneInfo[i][z_miny] && px < ZoneInfo[i][z_maxx] && py < ZoneInfo[i][z_maxy]) return i;
}
}
return -1;
}
public ZoneUpdate()
{
for(new z=0; z < MAX_ZONES; z++)
{
if(ZoneTakeOverTeam[z] == -1)
{
for(new t=0; t < MAX_TEAMS; t++)
{
if(t == ZoneInfo[z][z_team]) continue;
if(GetMembersInZone(z, t) >= 2)
{
ZoneTakeOverTeam[z] = t;
GangZoneFlashForAll(ZoneInfo[z][z_id], GetTeamColor(t));
ZoneTakeOverTime[z] = 0;
}
}
}
else
{
if(GetMembersInZone(z, ZoneTakeOverTeam[z]) > 0)
{
ZoneTakeOverTime[z]++;
if(ZoneTakeOverTime[z] >= 60)
{
GangZoneStopFlashForAll(ZoneInfo[z][z_id]);
GangZoneShowForAll(ZoneInfo[z][z_id], GetTeamColor(ZoneTakeOverTeam[z]));
ZoneInfo[z][z_team] = ZoneTakeOverTeam[z];
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GetPlayerZone(i) == z && gTeam[i] == ZoneTakeOverTeam[z])
{
SetPlayerScore(i, GetPlayerScore(i) + 2);
pInfo[i][pKills] += 2;
GameTextForPlayer(i, "~g~Turf ~r~taken over~n~~b~~h~+2 score", 6000, 3);
}
}
}
ZoneTakeOverTeam[z] = -1;
ZoneTakeOverTime[z] = 0;
}
}
else
{
ZoneTakeOverTeam[z] = -1;
GangZoneStopFlashForAll(ZoneInfo[z][z_id]);
ZoneTakeOverTime[z] = 0;
}
}
}
}
Regards,
Rat.