Jump to content
Autentificarea cu Google și Facebook nu mai este disponibilă. ×

Question

Posted

Cum as putea face un WarGangZone?

Help:

[pawn]#include <a_samp>

#define TEAM_GROVE 1

#define TEAM_BALLAS 2

#define TEAM_VAGOS 3

enum eZone

{

    Float:zMinX,

    Float:zMinY,

    Float:zMaxX,

    Float:zMaxY,

    zTeam

}

new ZoneInfo[][eZone] = {

    {2337.9004,-1808.8383,2590.2043,-1610.3673,TEAM_GROVE},

    {2084.7,-1808.8383,2337.9004,-1610.3673,TEAM_BALLAS},

    {2590.2043,-1808.8383,2842.3,-1610.3673,TEAM_VAGOS}

};

new ZoneID[sizeof(ZoneInfo)];

{2337.9004,-1808.8383,2590.2043,-1610.3673,TEAM_GROVE},

for(new i=0; i < sizeof(ZoneInfo); i++)

{

    ZoneID = GangZoneCreate(ZoneInfo[zMinX], ZoneInfo[zMinY], ZoneInfo[zMaxX], ZoneInfo[zMaxY]);

}

for(new i=0; i < sizeof(ZoneInfo); i++)

{

    GangZoneShowForPlayer(playerid, ZoneID, GetTeamZoneColor(ZoneInfo[zTeam]));

}

stock GetTeamZoneColor(teamid)

{

    switch(teamid)

    {

        case TEAM_GROVE: return 0x00FF0088;

        case TEAM_BALLAS: return 0xFF00FF88;

        case TEAM_VAGOS: return 0xFFFF0088;

    }

    return -1;

}

new ZoneInfo[][eZone] = {

    {2337.9004,-1808.8383,2590.2043,-1610.3673,TEAM_GROVE},

    {2084.7,-1808.8383,2337.9004,-1610.3673,TEAM_BALLAS},

    {2590.2043,-1808.8383,2842.3,-1610.3673,TEAM_VAGOS},

    {1429.3770,-1732.4554,1529.1932,-1592.1989,TEAM_GROVE}

};

new ZoneAttacker[sizeof(ZoneInfo)] = {-1, ...};

new ZoneAttackTime[sizeof(ZoneInfo)];

for(new i=0; i < sizeof(ZoneInfo); i++)

{

    GangZoneShowForPlayer(playerid, ZoneID, GetTeamZoneColor(ZoneInfo[zTeam]));

    if(ZoneAttacker != -1) GangZoneFlashForPlayer(playerid, ZoneID, GetTeamZoneColor(ZoneAttacker));

}

#define TAKEOVER_TIME 120 // how many seconds needed to take over the zone

#define MIN_MEMBERS_TO_START_WAR 3 // how many team members needed in a zone to start a war

new Teams[] = {

    TEAM_GROVE,

    TEAM_BALLAS,

    TEAM_VAGOS

};

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;

}

public ZoneTimer()

{

    for(new i=0; i < sizeof(ZoneInfo); i++) // loop all zones

    {

        if(ZoneAttacker != -1) // zone is being attacked

        {

            if(GetPlayersInZone(i, ZoneAttacker) >= MIN_MEMBERS_TO_START_WAR) // team has enough members in the zone

            {

                ZoneAttackTime++;

                if(ZoneAttackTime == TAKEOVER_TIME) // zone has been under attack for enough time and attackers take over the zone

                {

                    GangZoneStopFlashForAll(ZoneID);

                    ZoneInfo[zTeam] = ZoneAttacker;

                    GangZoneShowForAll(ZoneID, GetTeamZoneColor(ZoneInfo[zTeam])); // update the zone color for new team

                    ZoneAttacker = -1;

                }

            }

            else // attackers failed to take over the zone

            {

                GangZoneStopFlashForAll(ZoneID);

                ZoneAttacker = -1;

            }

        }

        else // check if somebody is attacking

        {

            for(new t=0; t < sizeof(Teams); t++) // loop all teams

            {

                if(Teams[t] != ZoneInfo[zTeam] && GetPlayersInZone(i, Teams[t]) >= MIN_MEMBERS_TO_START_WAR) // if there are enough enemies in the zone

                {

                    ZoneAttacker = Teams[t];

                    ZoneAttackTime = 0;

                    GangZoneFlashForAll(ZoneID, GetTeamZoneColor(ZoneAttacker));

                }

            }

        }

    }

}

#define TAKEOVER_TIME 120 // how many seconds needed to take over the zone

#define MIN_DEATHS_TO_START_WAR 3 // how many team members must be killed in a zone to start a war

SetTimer("ZoneTimer", 1000, true);

public ZoneTimer()

{

    for(new i=0; i < sizeof(ZoneInfo); i++) // loop all zones

    {

        if(ZoneAttacker != -1) // zone is being attacked

        {

            if(GetPlayersInZone(i, ZoneAttacker) >= 1) // there must be at least 1 attacker left

            {

                ZoneAttackTime++;

                if(ZoneAttackTime == TAKEOVER_TIME) // zone has been under attack for enough time and attackers take over the zone

                {

                    GangZoneStopFlashForAll(ZoneID);

                    ZoneInfo[zTeam] = ZoneAttacker;

                    GangZoneShowForAll(ZoneID, GetTeamZoneColor(ZoneInfo[zTeam])); // update the zone color for new team

                    ZoneAttacker = -1;

                }

            }

            else // attackers failed to take over the zone

            {

                GangZoneStopFlashForAll(ZoneID);

                ZoneAttacker = -1;

            }

        }

    }

}

if(IsPlayerConnected(killerid) && GetPlayerTeam(playerid) != GetPlayerTeam(killerid)) // not a suicide or team kill

{

    new zoneid = GetPlayerZone(playerid);

    if(zoneid != -1 && ZoneInfo[zoneid][zTeam] == GetPlayerTeam(playerid)) // zone member has been killed in the zone

    {

        ZoneDeaths[zoneid]++;

        if(ZoneDeaths[zoneid] == MIN_DEATHS_TO_START_WAR)

        {

            ZoneDeaths[zoneid] = 0;

            ZoneAttacker[zoneid] = GetPlayerTeam(killerid);

            ZoneAttackTime[zoneid] = 0;

            GangZoneFlashForAll(ZoneID[zoneid], GetTeamZoneColor(ZoneAttacker[zoneid]));

        }

    }

}

new ZoneDeaths[sizeof(ZoneInfo)];

stock GetPlayerZone(playerid)

{

    for(new i=0; i < sizeof(ZoneInfo); i++)

    {

        if(IsPlayerInZone(playerid, i))

        {

            return i;

        }

    }

    return -1;

}[/pawn]

Inspirat din: http://forum.sa-mp.com/showthread.php?t=276352

560x95_F01616_1625F2_030303_000000.png

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.