11.07.2015, 17:49
Hello Forum SA-MP Members
I am facing a small problem in my capture zone that 2 player can capture 1 zone at once i want to do that 1 player can capture at once but the problem is that 2 player stand in zone and the timer start and it capture by twice please help me REP+ who help me to fix that problem
I am facing a small problem in my capture zone that 2 player can capture 1 zone at once i want to do that 1 player can capture at once but the problem is that 2 player stand in zone and the timer start and it capture by twice please help me REP+ who help me to fix that problem
Код:
#include <a_samp> #include <streamer> #define SNAKE 0 //Snakes farm public OnGameModeInit() { tCP[SNAKE] = TEAM_NONE; UnderAttack[SNAKE] = 0; CP[SNAKE] = CreateDynamicCP(-36.5458, 2347.6426, 24.1406,3, -1,-1,-1,100.0); Zone[SNAKE] = GangZoneCreate(-62.5000000000005,2318.359375,23.4375,2390.625); return 1; } public OnPlayerConnect(playerid) { IsPlayerCapturing[playerid][SNAKE] = 0; CountVar[playerid][SNAKE] = 25; if(tCP[SNAKE] == TEAM_NONE) GangZoneShowForPlayer(playerid,Zone[SNAKE], ZONE_WHITE); else if(tCP[SNAKE] == TEAM_EURASIA) GangZoneShowForPlayer(playerid,Zone[SNAKE], TEAM_ZONE_EURASIA_COLOR); else if(tCP[SNAKE] == TEAM_ARAB) GangZoneShowForPlayer(playerid,Zone[SNAKE], TEAM_ZONE_ARAB_COLOR); else if(tCP[SNAKE] == TEAM_USA) GangZoneShowForPlayer(playerid,Zone[SNAKE], TEAM_ZONE_USA_COLOR); else if(tCP[SNAKE] == TEAM_AUS) GangZoneShowForPlayer(playerid,Zone[SNAKE], TEAM_ZONE_AUS_COLOR); else if(tCP[SNAKE] == TEAM_SOVIET) GangZoneShowForPlayer(playerid,Zone[SNAKE], TEAM_ZONE_SOVIET_COLOR); return 1; } public OnPlayerDisconnect(playerid, reason) { if(Captured[playerid][SNAKE] == 0 && IsPlayerCapturing[playerid][SNAKE] == 1) { LeavingSnakeFarm(playerid); } return 1; } public OnPlayerSpawn(playerid) { if(Captured[playerid][SNAKE] == 0 && IsPlayerCapturing[playerid][SNAKE] == 1 && IsPlayerInDynamicCP(playerid, CP[SNAKE])) { LeavingSnakeFarm(playerid); } return 1; } //================================CAPTURE ZONES================================= stock CaptureZoneMessage(playerid, messageid) { switch(messageid) { case 1: { SendClientMessage(playerid, dred,"*You cannot capture while in vehicle!"); } case 2: { SendClientMessage(playerid, dred,"*This zone is already being taken over!"); } case 3: { SendClientMessage(playerid, dred,"*Admins on-duty Cannot capture areas."); } } return 1; } //===============SNAKE FARMS==================================================== stock ActiveSnakeFarm(playerid) { if(Spectating[playerid] == 0 && PlayerInfo[playerid][OnDuty] == 0 && gTeam[playerid] != TEAM_MERC) { if(UnderAttack[SNAKE] == 0) { if(!IsPlayerInAnyVehicle(playerid)) { UnderAttack[SNAKE] = 1; timer[playerid][SNAKE] = SetTimerEx("SnakeFarm", 25000, false,"i",playerid); Captured[playerid][SNAKE] = 0; SendClientMessage(playerid, 0xFFFFFFFF,"| - Stay in this checkpoint for 25 seconds to capture! - |"); if(gTeam[playerid] == TEAM_EURASIA) { GangZoneFlashForAll(Zone[SNAKE], TEAM_ZONE_EURASIA_COLOR); } else if(gTeam[playerid] == TEAM_ARAB) { GangZoneFlashForAll(Zone[SNAKE], TEAM_ZONE_ARAB_COLOR); } else if(gTeam[playerid] == TEAM_SOVIET) { GangZoneFlashForAll(Zone[SNAKE], TEAM_ZONE_SOVIET_COLOR); } else if(gTeam[playerid] == TEAM_USA) { GangZoneFlashForAll(Zone[SNAKE], TEAM_ZONE_USA_COLOR); } else if(gTeam[playerid] == TEAM_AUS) { GangZoneFlashForAll(Zone[SNAKE], TEAM_ZONE_AUS_COLOR); } //------Message----- if(tCP[SNAKE] == TEAM_EURASIA) { SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by team "COL_RED"<EURASIA>"); SendTeamMessage(TEAM_EURASIA, green,"*Snakes Farm is under attack!"); } else if(tCP[SNAKE] == TEAM_ARAB) { SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by team "COL_RED"<ARAB>"); SendTeamMessage(TEAM_ARAB, green,"*Snakes Farm is under attack!"); } else if(tCP[SNAKE] == TEAM_SOVIET) { SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by team "COL_RED"<SOVIET>"); SendTeamMessage(TEAM_SOVIET, green,"*Snakes Farm is under attack!"); } else if(tCP[SNAKE] == TEAM_USA) { SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by team "COL_RED"<USA>"); SendTeamMessage(TEAM_USA, green,"*Snakes Farm is under attack!"); } else if(tCP[SNAKE] == TEAM_AUS) { SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by team "COL_RED"<AUSTRALIA>"); SendTeamMessage(TEAM_AUS, green,"*Snakes Farm is under attack!"); } else if(tCP[SNAKE] == TEAM_NONE) { SendClientMessage(playerid, COLOR_WHITE,"This flag is not controlled by any team"); } //---------loop-------// for(new i = 0; i < MAX_PLAYERS; i ++) { IsPlayerCapturing[i][SNAKE] = 1; } } else return CaptureZoneMessage(playerid, 1); } else return CaptureZoneMessage(playerid, 2); } else return CaptureZoneMessage(playerid, 3); return 1; } stock SnakeFarmCaptured(playerid) { Captured[playerid][SNAKE] = 1; UnderAttack[SNAKE] = 0; KillTimer(timer[playerid][SNAKE]); CountVar[playerid][SNAKE] = 25; GivePlayerScore(playerid, 3); GivePlayerMoney(playerid, 2000); new str[128]; Savestatus(playerid); TextStats(playerid); SendClientMessage(playerid,yellow,"*You have earned +$2000 and +3 score from this zone."); //========================================================================== for(new i = 0; i < MAX_PLAYERS; i++) { IsPlayerCapturing[i][SNAKE] = 0; if(gTeam[i] == gTeam[playerid] && i != playerid && PlayerInfo[i][OnDuty] == 0) { SendClientMessage(i, 0xFFFFFFFF,"*Your team has captured "cred"Snakes farm"cwhite"! You received +1 score for it!"); GivePlayerScore(i, 1); } } //========================================================================== tCP[SNAKE] = gTeam[playerid]; GangZoneStopFlashForAll(Zone[SNAKE]); //========================================================================== if(gTeam[playerid] == TEAM_EURASIA) { GangZoneShowForAll(Zone[SNAKE], TEAM_ZONE_EURASIA_COLOR); } else if(gTeam[playerid] == TEAM_ARAB) { GangZoneShowForAll(Zone[SNAKE], TEAM_ZONE_ARAB_COLOR); } else if(gTeam[playerid] == TEAM_SOVIET) { GangZoneShowForAll(Zone[SNAKE], TEAM_ZONE_SOVIET_COLOR); } else if(gTeam[playerid] == TEAM_USA) { GangZoneShowForAll(Zone[SNAKE], TEAM_ZONE_USA_COLOR); } else if(gTeam[playerid] == TEAM_AUS) { GangZoneShowForAll(Zone[SNAKE], TEAM_ZONE_AUS_COLOR); } //========================================================================== format(str, sizeof(str),"~w~%s has captured ~b~~h~Snakes Farm ~w~for team %s", pName(playerid), GetTeamName(playerid)); SendBoxMessage(str); return 1; } stock LeavingSnakeFarm(playerid) { if(IsPlayerCapturing[playerid][SNAKE] == 1) { Captured[playerid][SNAKE] = 1; UnderAttack[SNAKE] = 0; KillTimer(timer[playerid][SNAKE]); CountVar[playerid][SNAKE] = 25; SendClientMessage(playerid, white,"*You have Failed to Capture this Zone."); GangZoneStopFlashForAll(Zone[SNAKE]); } else return 0; for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerCapturing[i][SNAKE] == 1) return 0; else IsPlayerCapturing[i][SNAKE] = 0; } return 1; } forward SnakeFarm(playerid); public SnakeFarm(playerid) { SnakeFarmCaptured(playerid); return 1; } public OnPlayerEnterDynamicCP(playerid, checkpointid) { if(checkpointid == CP[SNAKE]) { if(Spectating[playerid] == 0) { if(UnderAttack[SNAKE] == 0) { if(PlayerInfo[playerid][OnDuty] == 0) { if(tCP[SNAKE] != gTeam[playerid]) { if(gTeam[playerid] != TEAM_MERC) { CountVar[playerid][SNAKE] = 25; ActiveSnakeFarm(playerid); } else return SendClientMessage(playerid, red,"*Mercenary team cannot capture zones"); } else return SendClientMessage(playerid, -1,"*This zone is controlled by your team!"); } else return CaptureZoneMessage(playerid, 3); } else return CaptureZoneMessage(playerid, 2); } else return 0; } return 1; } public OnPlayerLeaveDynamicCP(playerid, checkpointid) { if(checkpointid == CP[SNAKE] && Captured[playerid][SNAKE] == 0 && IsPlayerCapturing[playerid][SNAKE] == 1 && !IsPlayerInDynamicCP(playerid, CP[SNAKE])) { LeavingSnakeFarm(playerid); } return 1; }