23.06.2012, 12:10
(
Последний раз редактировалось ivanVU; 23.06.2012 в 15:30.
)
I worked with this tutorial: https://sampforum.blast.hk/showthread.php?tid=276352
Creation of zones
Zone Showing
OnGameModeInIt
callback ZoneTimer
I want to make that players can take over gang zones!
Код:
new ZoneInfo[][eZone] = {
{-992.6194, 1903.494, -373.692, 2195.441,NICIJA}, // brana
{233.5575, 677.3168, 992.6194, 1039.331,NICIJA}, // kamenolom
{-2826.046, 2183.763, -2137.051, 2674.233,NICIJA}, // marina
{-163.4902, 2370.609, 490.4708, 2639.2,NICIJA}, // stari aero
{-105.1009, 1623.225, 432.0814, 2148.729,NICIJA}, // area51
{-1669.936, 443.7593, -712.3504, 1424.701,NICIJA} // mostovi
};
Код:
for(new i=0; i < sizeof(ZoneInfo); i++)
{
ZoneID[i] = GangZoneCreate(ZoneInfo[i][zMinX], ZoneInfo[i][zMinY], ZoneInfo[i][zMaxX], ZoneInfo[i][zMaxY]);
}
Код:
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]));
}
Код:
SetTimer("ZoneTimer", 1000, true);
Код:
forward ZoneTimer();
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]));
}
}
}
}
}

