Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This is a comment
- // uncomment the line below if you want to write a filterscript
- //#define FILTERSCRIPT
- // --- * INCLUDES * ------------------------------------------------------------
- #include <a_samp>
- #include <s3Zone.pwn>
- #include <YSI\y_timers>
- //--------------------------
- #undef MAX_PLAYERS
- #define MAX_PLAYERS 72 // change this to maximum players on your server.
- //--------------------------
- // WARNING: Define your function to get player team ----------------------------
- stock GetTeam(playerid)
- {
- return playerid; // change playerid to variable with your team ID (example 'return pInfo[playerid][Team];')
- }
- // --- * DEFINES * -------------------------------------------------------------
- #define MIN_ENEMIES_TO_WAR 2 // Change to number which you want to start gang war
- #define MAX_TEAMS 6 // Change number of all your teams
- #define FOREACH(%0,%1) for(new %0=0;%0<%1;%0++) if (IsPlayerConnected(%0))
- // --- * VARIABLES * -----------------------------------------------------------
- new OLD_ZONE[ MAX_PLAYERS ],
- NEW_ZONE[ MAX_PLAYERS ]
- ;
- new PlayerIsEnemy[ MAX_PLAYERS ][ MAX_GANGZONES ],
- TotalEnemies[ MAX_TEAMS ][ MAX_GANGZONES ],
- EnemyTeam[ MAX_GANGZONES ]
- ;
- new PlayerIsProtector[ MAX_PLAYERS ][ MAX_GANGZONES ],
- TotalProtectors[ MAX_TEAMS ][ MAX_GANGZONES ],
- ProtectTeam[ MAX_GANGZONES ]
- ;
- new G_WarStarted = false, G_GangZoneInWar = -1, T_GangZone;
- // --- * BODY * ----------------------------------------------------------------
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Blank Filterscript by your name here");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- forward s_OnPlayerDisconnect(playerid);
- public s_OnPlayerDisconnect(playerid)
- {
- PlayerQuit(playerid);
- return 1;
- }
- forward s_OnPlayerDeath(playerid);
- public s_OnPlayerDeath(playerid)
- {
- PlayerQuit(playerid);
- return 1;
- }
- Timer:MainBody[1000]()
- {
- FOREACH (i, MAX_PLAYERS)
- {
- if (IsPlayerInAnyGangZone(i))
- {
- new zoneid = GetPlayerGangZone(i);
- if (zoneid != NEW_ZONE[ i ])
- {
- OLD_ZONE[ i ] = NEW_ZONE[ i ];
- NEW_ZONE[ i ] = zoneid;
- }
- if (NEW_ZONE[ i ] != OLD_ZONE[ i ])
- {
- OnPlayerChangeGangZone(i, NEW_ZONE[ i ], OLD_ZONE[ i ]);
- }
- }
- else
- {
- }
- }
- }
- // --- * FUNCTIONS * -----------------------------------------------------------
- forward OnPlayerChangeGangZone(playerid, newzoneid, oldzoneid);
- public OnPlayerChangeGangZone(playerid, newzoneid, oldzoneid)
- {
- new teamid = GetTeam(playerid);
- // War is not started
- if (!G_WarStarted)
- {
- // Player is not owner of this zone - Enemy
- //if (!IsPlayerZoneOwner(playerid, newzoneid))
- if (!PlayerIsEnemy[ playerid ][ newzoneid ] && !IsPlayerZoneOwner(playerid, newzoneid))
- {
- // attack can each member of the team.
- // This write value 1 to this zone.
- SetPlayerEnemy(playerid, teamid, newzoneid);
- // It allow players are more than other,
- if (TotalEnemies[ teamid ][ newzoneid ] >= MIN_ENEMIES_TO_WAR)
- {
- OnPlayerStartGangWar(playerid, newzoneid, teamid);
- GameTextForPlayer(playerid, "~r~YOU START GANG WAR!", 1000*3, 5);
- }
- }
- }
- else
- {
- if (PlayerIsEnemy[ playerid ][ oldzoneid ] || PlayerIsProtector[ playerid ][ oldzoneid ])
- {
- // ------ PLAYER HAS LEFT THE GANG WAR ZONE ---------------------
- // if oldzone is in gangwar
- if (NEW_ZONE[ playerid ] != G_GangZoneInWar)
- {
- // If player is owner ot means decrease Protectors
- //if (IsPlayerZoneOwner(playerid, oldzoneid))
- if (PlayerIsEnemy[ playerid ][ oldzoneid ] && !IsPlayerZoneOwner(playerid, oldzoneid))
- {
- // if enemy left the war zone
- //if (EnemyTeam[ oldzoneid ] == teamid)
- //{
- //
- PlayerIsEnemy[ playerid ][ oldzoneid ] = 0;
- TotalEnemies[ teamid ][ oldzoneid ]--;
- GameTextForPlayer(playerid, "~r~YOU LEFT FROM GANG WAR!", 1000*5, 5);
- if (TotalEnemies[ teamid ][ oldzoneid ] <= 0)
- {
- EndGangWar(oldzoneid);
- GangWarCallBack();
- SendClientMessage(playerid, -1, "Gangwar has ended!");
- }
- //}
- }
- //else
- if (PlayerIsProtector[ playerid ][ oldzoneid ] && IsPlayerZoneOwner(playerid, oldzoneid))
- {
- PlayerIsProtector[ playerid ][ oldzoneid ] = 0;
- TotalProtectors[ teamid ][ oldzoneid ]--;
- GameTextForPlayer(playerid, "~r~YOU LEFT FROM YOUR GANG ZONE!", 1000*5, 5);
- if (TotalProtectors[ teamid ][ oldzoneid ] <= 0)
- {
- EndGangWar(oldzoneid);
- GangWarCallBack();
- SendClientMessage(playerid, -1, "Gangwar has ended!");
- }
- }
- }
- }
- else
- {
- // War is started. In this time players can come to warzone
- if (ProtectTeam[ newzoneid ] == teamid && PlayerIsProtector[ playerid ][ newzoneid ])
- {
- // player is owner and he can be as Protector of this zone.
- SetPlayerProtect(playerid, teamid, newzoneid);
- GameTextForPlayer(playerid, "~r~PROTECT YOUR ZONE!!!", 1000*5, 5);
- }
- else
- {
- // it add only player from EnemyTeam
- if (EnemyTeam[ newzoneid ] == teamid && !PlayerIsEnemy[ playerid ][ newzoneid ])
- {
- // player is not owner and he can be as Enemy for this zone.
- SetPlayerEnemy(playerid, teamid, newzoneid);
- GameTextForPlayer(playerid, "~r~KILL ALL PROTECTORS OF THIS ZONE!!!", 1000*3, 5);
- }
- }
- }
- }
- return 1;
- }
- //------------------------------------------------------------------------------
- forward OnPlayerStartGangWar(playerid, zoneid, teamid);
- public OnPlayerStartGangWar(playerid, zoneid, teamid)
- {
- // Start flash gang zone
- SetGangZoneFlash(zoneid);
- G_WarStarted = true;
- //--------------------------------------------------------------------------
- // Main set of variable - You shouldn't to change it
- EnemyTeam[ zoneid ] = teamid;
- ProtectTeam[ zoneid ] = GetGangZoneOwner(zoneid);
- G_GangZoneInWar = zoneid;
- //--------------------------------------------------------------------------
- T_GangZone = SetTimer("GangWarCallBack", 1000*30, false);
- }
- //------------------------------------------------------------------------------
- forward GangWarCallBack();
- public GangWarCallBack()
- {
- new
- zoneid = G_GangZoneInWar,
- protectorid = ProtectTeam[ zoneid ],
- enemyid = EnemyTeam[ zoneid ]
- ;
- // All protectors were killed and enemies still
- if (TotalEnemies[ enemyid ][ zoneid ] > 0)
- {
- // Protectors still a live
- if (TotalProtectors[ protectorid ][ zoneid ] == 0)
- {
- SetGangZoneOwnerTeam(zoneid, enemyid);
- FOREACH(i, MAX_PLAYERS)
- {
- if (GetTeam(i) == enemyid)
- {
- GameTextForPlayer(i, "~g~THIS HOOD IS YOURS!", 1000*4, 5);
- }
- else if (GetTeam(i) == protectorid)
- {
- GameTextForPlayer(i, "~r~YOU LOST THIS HOOD!", 1000*4, 5);
- }
- }
- }
- }
- else
- {
- FOREACH(playerid, MAX_PLAYERS)
- {
- if (GetTeam(playerid) == protectorid)
- {
- GameTextForPlayer(playerid, "~r~YOU LOST THIS HOOD", 1000*4, 5);
- }
- }
- }
- EndGangWar(zoneid);
- }
- //------------------------------------------------------------------------------
- stock EndGangWar(zoneid)
- {
- // Main set of variable - You shouldn't to change it
- EnemyTeam[ zoneid ] = -1;
- ProtectTeam[ zoneid ] = -1;
- G_GangZoneInWar = -1;
- for (new i=0;i < MAX_TEAMS; i++)
- {
- TotalEnemies[ i ][ zoneid ] = 0;
- TotalProtectors[ i ][ zoneid ] = 0;
- }
- FOREACH(i, MAX_PLAYERS)
- {
- PlayerIsEnemy[ i ][ zoneid ] = 0;
- PlayerIsProtector[ i ][ zoneid ] = 0;
- GangZoneStopFlashForPlayer(i, zoneid);
- }
- //--------------------------------------------------------------------------
- G_WarStarted = false;
- KillTimer(T_GangZone);
- }
- forward PlayerQuit(playerid);
- public PlayerQuit(playerid)
- {
- if (G_WarStarted)
- {
- new teamid = GetTeam(playerid);
- if (PlayerIsEnemy[ playerid ][ G_GangZoneInWar ])
- {
- PlayerIsEnemy[ playerid ][ G_GangZoneInWar ] = 0;
- TotalEnemies[ teamid][ G_GangZoneInWar ]--;
- if (TotalEnemies[ teamid ][ G_GangZoneInWar ] <= 0)
- {
- EndGangWar(G_GangZoneInWar);
- GangWarCallBack();
- SendClientMessage(playerid, -1, "Gangwar has ended!");
- }
- }
- if (PlayerIsProtector[ playerid ][ G_GangZoneInWar ])
- {
- PlayerIsProtector[ playerid ][ G_GangZoneInWar ] = 0;
- TotalProtectors[ teamid][ G_GangZoneInWar ]--;
- if (TotalProtectors[ teamid ][ G_GangZoneInWar ] <= 0)
- {
- EndGangWar(G_GangZoneInWar);
- GangWarCallBack();
- SendClientMessage(playerid, -1, "Gangwar has ended!");
- }
- }
- }
- return 1;
- }
- stock IsPlayerZoneOwner(playerid, zoneid)
- {
- if (GetGangZoneOwner(zoneid) == GetTeam(playerid)) return 1;
- else return 0;
- }
- //------------------------------------------------------------------------------
- stock IsZoneInWar(zoneid)
- {
- if (zoneid == G_GangZoneInWar) return 1;
- else return 0;
- }
- stock SetPlayerEnemy(playerid, teamid, zoneid)
- {
- PlayerIsEnemy[ playerid ][ zoneid ] = 1;
- TotalEnemies[ teamid ][ zoneid ]++;
- }
- stock SetPlayerProtect(playerid, teamid, zoneid)
- {
- PlayerIsProtector[ playerid ][ zoneid ] = 1;
- TotalProtectors[ teamid ][ zoneid ]++;
- }
Advertisement
Add Comment
Please, Sign In to add comment