07.10.2012, 14:49
Need some help with this turf system ( i think its not working)
When ever my player goes on rival gang zone it should suppose to be flashing but it isn't :/
Code:
// This is a comment // uncomment the line below if you want to write a filterscript //#define FILTERSCRIPT #include <a_samp> #include <zcmd> #include <Dudb> #include <core> #include <float> #include <foreach> #include <sscanf2> #pragma unused ret_memcpy #if defined FILTERSCRIPT public OnFilterScriptInit() { print("\n--------------------------------------"); print(" GangWar"); print("--------------------------------------\n"); return 1; } public OnFilterScriptExit() { return 1; } #else //Colors #define COLOR_COPS 0x0080FFFF #define COLOR_BALLA 0xFF00FFFF #define COLOR_BALLAS 0xFF00FFFF #define COLOR_VEGOSS 0xFFFF00FF #define COLOR_GROVE 0x00FF00FF #define COLOR_GROVES 0x00FF00FF #define COLOR_VEGOS 0xFFFF00FF #define COLOR_AZTECS 0x00FFFFFF #define COLOR_RED 0xFF0000FF #define COLOR_GREEN 0x008000FF #define COLOR_VIOLET 0x800080FF #define COLOR_LIGHTBLUE0 0x00FFFFFF #define COLOR_YELLOW 0xFFFF00FF #define COLOR_BLUE 0x0000A0FF #pragma tabsize 0 #define TEAM_GROVE 1 #define TEAM_BALLAS 2 #define TEAM_VAGOS 3 #define TAKEOVER_TIME 120 #define MIN_MEMBERS_TO_START_WAR 1 forward ZoneTimer(); main() { print("\n----------------------------------"); print(" Gangwar"); print("----------------------------------\n"); } #endif new gTeam[MAX_PLAYERS]; enum eZone { Float:zMinX, Float:zMinY, Float:zMaxX, Float:zMaxY, zTeam } new ZoneInfo[][eZone] = { {2337.9004,-1808.8383,2590.2043,-1610.3673,TEAM_GROVE}, {2113.53, -1741.078, 2334.095, -1598.959,TEAM_GROVE}, {2212.404, -2021.368, 2493.814, -1752.921,TEAM_GROVE}, {2379.729, -1595.012, 2531.842, -1476.579,TEAM_GROVE}, {1843.529,-1259.454,2071.699,-1097.596,TEAM_BALLAS}, {2067.896, -1389.729, 2273.249, -1137.074,TEAM_BALLAS}, {1847.332, -1472.632, 2067.896, -1279.192,TEAM_BALLAS}, {1858.74, -1764.764, 2098.319, -1476.579,TEAM_BALLAS}, {2084.7,-1808.8383,2337.9004,-1610.3673,TEAM_BALLAS}, {2140.15, -1567.377, 2353.109, -1409.468,TEAM_BALLAS}, {2280.855, -1437.102, 2493.814, -1216.028,TEAM_BALLAS}, {2590.2043,-1808.8383,2842.3,-1610.3673,TEAM_VAGOS}, {2509.025, -1464.736, 2725.787, -1259.454,TEAM_VAGOS}, {2216.207, -1172.603, 2653.533, -1054.171,TEAM_VAGOS}, {2714.378, -1492.37, 2862.689, -1046.276,TEAM_VAGOS}, {2550.856, -2183.225, 2809.449, -1910.831,TEAM_VAGOS}, {2501.419, -2056.897, 2843.675, -1670.019,TEAM_VAGOS}, {2543.251, -1614.75, 2634.519, -1468.684,TEAM_VAGOS} }; new ZoneID[sizeof(ZoneInfo)]; new ZoneAttacker[sizeof(ZoneInfo)] = {-1, ...}; new ZoneAttackTime[sizeof(ZoneInfo)]; new Teams[] = { TEAM_GROVE, TEAM_BALLAS, TEAM_VAGOS }; new ZoneDeaths[sizeof(ZoneInfo)]; public OnGameModeInit() { //classe AddPlayerClass(0,2514.8130,-1674.3113,13.7020,66.7092,0,0,0,0,0,0); // grove AddPlayerClass(0,2514.8130,-1674.3113,13.7020,66.7092,0,0,0,0,0,0); // grove AddPlayerClass(0,2514.8130,-1674.3113,13.7020,66.7092,0,0,0,0,0,0); // grove AddPlayerClass(0,2014.1774,-1740.4828,13.5469,145.0912,0,0,0,0,0,0); // balla AddPlayerClass(0,2014.1774,-1740.4828,13.5469,145.0912,0,0,0,0,0,0); // balla AddPlayerClass(0,2014.1774,-1740.4828,13.5469,145.0912,0,0,0,0,0,0); // balla AddPlayerClass(0,2541.5249,-1033.1189,69.5793,177.4599,0,0,0,0,0,0); // vegos AddPlayerClass(0,2541.5249,-1033.1189,69.5793,177.4599,0,0,0,0,0,0); // vegos AddPlayerClass(0,2541.5249,-1033.1189,69.5793,177.4599,0,0,0,0,0,0); // vegos for(new i=0; i < sizeof(ZoneInfo); i++) { ZoneID[i] = GangZoneCreate(ZoneInfo[i][zMinX], ZoneInfo[i][zMinY], ZoneInfo[i][zMaxX], ZoneInfo[i][zMaxY]); } // Don't use these lines if it's a filterscript SetTimer("ZoneTimer", 1000, true); SetGameModeText("GangWar"); return 1; } public OnPlayerRequestClass(playerid, classid) { switch(classid) { case 0: { gTeam[playerid] = TEAM_GROVE; SetPlayerSkin(playerid,106); SetPlayerColor(playerid,COLOR_GROVES); GameTextForPlayer(playerid, "~g~Grove", 5000, 5); SetPlayerPos(playerid, 2514.8130,-1674.3113,13.7020); SetPlayerFacingAngle(playerid, 66.7092); SetPlayerCameraPos(playerid, 2510.4692,-1671.6757,13.4205); SetPlayerCameraLookAt(playerid, 2514.8130,-1674.3113,13.7020); } case 1: { gTeam[playerid] = TEAM_GROVE; SetPlayerSkin(playerid,105); GameTextForPlayer(playerid, "~g~Grove", 5000, 5); SetPlayerPos(playerid, 2514.8130,-1674.3113,13.7020); SetPlayerFacingAngle(playerid, 66.7092); SetPlayerCameraPos(playerid, 2510.4692,-1671.6757,13.4205); SetPlayerCameraLookAt(playerid, 2514.8130,-1674.3113,13.7020); } case 2: { gTeam[playerid] = TEAM_GROVE; SetPlayerSkin(playerid,107); SetPlayerColor(playerid,COLOR_GROVES); GameTextForPlayer(playerid, "~g~Grove", 5000, 5); SetPlayerPos(playerid, 2514.8130,-1674.3113,13.7020); SetPlayerFacingAngle(playerid, 66.7092); SetPlayerCameraPos(playerid, 2510.4692,-1671.6757,13.4205); SetPlayerCameraLookAt(playerid, 2514.8130,-1674.3113,13.7020); } case 3: { gTeam[playerid] = TEAM_BALLAS; SetPlayerSkin(playerid,104); SetPlayerColor(playerid,COLOR_BALLA); GameTextForPlayer(playerid, "~p~Balla", 5000, 5); SetPlayerPos(playerid, 2014.1774,-1740.4828,13.5469); SetPlayerFacingAngle(playerid,145.0912); SetPlayerCameraPos(playerid,2010.7732,-1744.9518,13.5469); SetPlayerCameraLookAt(playerid,2014.1774,-1740.4828,13.5469); } case 4: { gTeam[playerid] = TEAM_BALLAS; SetPlayerSkin(playerid,102); SetPlayerColor(playerid,COLOR_BALLA); GameTextForPlayer(playerid, "~p~Balla", 5000, 5); SetPlayerPos(playerid, 2014.1774,-1740.4828,13.5469); SetPlayerFacingAngle(playerid,145.0912); SetPlayerCameraPos(playerid,2010.7732,-1744.9518,13.5469); SetPlayerCameraLookAt(playerid,2014.1774,-1740.4828,13.5469); } case 5: { gTeam[playerid] = TEAM_BALLAS; SetPlayerSkin(playerid,103); SetPlayerColor(playerid,COLOR_BALLA); GameTextForPlayer(playerid, "~p~Balla", 5000, 5); SetPlayerPos(playerid, 2014.1774,-1740.4828,13.5469); SetPlayerFacingAngle(playerid,145.0912); SetPlayerCameraPos(playerid,2010.7732,-1744.9518,13.5469); SetPlayerCameraLookAt(playerid,2014.1774,-1740.4828,13.5469); } case 6: { gTeam[playerid] = TEAM_VAGOS; SetPlayerSkin(playerid,108); SetPlayerColor(playerid,COLOR_VEGOS); GameTextForPlayer(playerid, "~y~Vegos", 5000, 5); SetPlayerPos(playerid, 2541.5249,-1033.1189,69.5793); SetPlayerFacingAngle(playerid,177.4599); SetPlayerCameraPos(playerid,2541.0801,-1038.4296,69.5781); SetPlayerCameraLookAt(playerid,2541.5249,-1033.1189,69.5793); } case 7: { gTeam[playerid] = TEAM_VAGOS; SetPlayerSkin(playerid,109); SetPlayerColor(playerid,COLOR_VEGOS); GameTextForPlayer(playerid, "~y~Vegos", 5000, 5); SetPlayerPos(playerid, 2541.5249,-1033.1189,69.5793); SetPlayerFacingAngle(playerid,177.4599); SetPlayerCameraPos(playerid,2541.0801,-1038.4296,69.5781); SetPlayerCameraLookAt(playerid,2541.5249,-1033.1189,69.5793); } case 8: { gTeam[playerid] = TEAM_VAGOS; SetPlayerSkin(playerid,110); SetPlayerColor(playerid,COLOR_VEGOS); GameTextForPlayer(playerid, "~y~Vegos", 5000, 5); SetPlayerPos(playerid, 2541.5249,-1033.1189,69.5793); SetPlayerFacingAngle(playerid,177.4599); SetPlayerCameraPos(playerid,2541.0801,-1038.4296,69.5781); SetPlayerCameraLookAt(playerid,2541.5249,-1033.1189,69.5793); } } return 1; } public OnPlayerSpawn(playerid) { GivePlayerWeapon(playerid,24,1000); GivePlayerWeapon(playerid,27,1000); GivePlayerWeapon(playerid,31,1000); GivePlayerWeapon(playerid,34,1000); GivePlayerWeapon(playerid,32,1000); SetPlayerWorldBounds(playerid, 2931.147, 23.35575, -817.4513, -2662.556); 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])); } return 1; } stock GetTeamZoneColor(teamid) { switch(teamid) { case TEAM_GROVE: return 0x00FF0088; case TEAM_BALLAS: return 0xFF00FF88; case TEAM_VAGOS: return 0xFFFF0088; } return -1; } 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; } stock GetPlayerZone(playerid) { for(new i=0; i < sizeof(ZoneInfo); i++) { if(IsPlayerInZone(playerid, i)) { return i; } } return -1; } public OnPlayerDeath(playerid, killerid, reason) { 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])); } } } return 1; } 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])); } } } } }