30.01.2015, 11:52
WHY when i was capturing zone this zone is not captured , captured is other
help pls +REP
Код:
forward OnPlayerEnterDynamicCP(playerid, checkpointid);
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
if(checkpointid == CP[CAPZONE])
{
if(UnderAttack[CAPZONE] == 0)
{
if(tCP[CAPZONE] != gTeam[playerid])
{
CountVar[playerid][CAPZONE] = 25;
ActiveCAPZONE(playerid);
} else return SendClientMessage(playerid, COLOR_RED,"*This zone is already captured by your team!");
} else return CaptureZoneMessage(playerid, 2);
}
if(checkpointid == CP[SNAKE])
{
if(UnderAttack[SNAKE] == 0)
{
if(tCP[SNAKE] != gTeam[playerid])
{
CountVar[playerid][CAPZONE] = 25;
ActiveSNAKE(playerid);
} else return SendClientMessage(playerid, COLOR_RED,"*This zone is already captured by your team!");
} else return CaptureZoneMessage(playerid, 2);
}
if(checkpointid == CP[OLD])
{
if(UnderAttack[OLD] == 0)
{
if(tCP[OLD] != gTeam[playerid])
{
CountVar[playerid][OLD] = 25;
ActiveOLD(playerid);
} else return SendClientMessage(playerid, COLOR_RED,"*This zone is already captured by your team!");
} else return CaptureZoneMessage(playerid, 2);
}
if(checkpointid == CP[Factory])
{
if(UnderAttack[Factory] == 0)
{
if(tCP[Factory] != gTeam[playerid])
{
CountVar[playerid][Factory] = 25;
ActiveFactory(playerid);
} else return SendClientMessage(playerid, COLOR_RED,"*This zone is already captured by your team!");
} else return CaptureZoneMessage(playerid, 2);
}
if(checkpointid == CP[Town])
{
if(UnderAttack[Town] == 0)
{
if(tCP[Town] != gTeam[playerid])
{
CountVar[playerid][Town] = 25;
ActiveTown(playerid);
} else return SendClientMessage(playerid, COLOR_RED,"*This zone is already captured by your team!");
} else return CaptureZoneMessage(playerid, 2);
}
return 1;
}
forward OnPlayerLeaveDynamicCP(playerid, checkpointid);
public OnPlayerLeaveDynamicCP(playerid, checkpointid)
{
if(checkpointid == CP[CAPZONE] && Captured[playerid][CAPZONE] == 0 && IsPlayerCapturing[playerid][CAPZONE] == 1 && !IsPlayerInDynamicCP(playerid, CP[CAPZONE]))
{
LeavingCAPZONE(playerid);
}
if(checkpointid == CP[SNAKE] && Captured[playerid][SNAKE] == 0 && IsPlayerCapturing[playerid][SNAKE] == 1 && !IsPlayerInDynamicCP(playerid, CP[SNAKE]))
{
LeavingSNAKE(playerid);
}
if(checkpointid == CP[OLD] && Captured[playerid][OLD] == 0 && IsPlayerCapturing[playerid][OLD] == 1 && !IsPlayerInDynamicCP(playerid, CP[OLD]))
{
LeavingOLD(playerid);
}
if(checkpointid == CP[Factory] && Captured[playerid][Factory] == 0 && IsPlayerCapturing[playerid][Factory] == 1 && !IsPlayerInDynamicCP(playerid, CP[Factory]))
{
LeavingFactory(playerid);
}
if(checkpointid == CP[Town] && Captured[playerid][Town] == 0 && IsPlayerCapturing[playerid][Town] == 1 && !IsPlayerInDynamicCP(playerid, CP[Town]))
{
LeavingTown(playerid);
}
}
stock CaptureZoneMessage(playerid, messageid)
{
switch(messageid)
{
case 1:
{
SendClientMessage(playerid, COLOR_RED,"You cannot capture while in a vehicle!");
}
case 2:
{
SendClientMessage(playerid, COLOR_RED,"This zone is already being taken over!");
}
}
return 1;
}
stock ActiveCAPZONE(playerid)
{
if(UnderAttack[CAPZONE] == 0)
{
if(!IsPlayerInAnyVehicle(playerid))
{
UnderAttack[CAPZONE] = 1;
timer[playerid][CAPZONE] = SetTimerEx("CAPZONETimer", 25000, false,"i",playerid);
Captured[playerid][CAPZONE] = 0;
SendClientMessage(playerid, 0xFFFFFFFF,"| Stay in this checkpoint for 25 seconds to capture it! |");
if(gTeam[playerid] == C1)
{
GangZoneFlashForAll(Zone[CAPZONE], C_GZ_COLOR);
}
else if(gTeam[playerid] == T1)
{
GangZoneFlashForAll(Zone[CAPZONE], T_GZ_COLOR);
}
//------Message-----
if(tCP[CAPZONE] == C1)
{
SendClientMessage(playerid, C_COLOR,"This flag is controlled by Cops!");
SendClientMessageToAll(STEALTH_BLUE,"*Desert Airport is under attack!");
}
else if(tCP[CAPZONE] == T1)
{
SendClientMessage(playerid, T_COLOR,"This flag is controlled by Terrorists!");
SendClientMessageToAll(STEALTH_BLUE,"*Desert Airport is under attack!");
}
else if(tCP[CAPZONE] == NONE)
{
SendClientMessage(playerid, COLOR_WHITE,"This flag is not controlled by any team!");
}
//---------loop-------//
for(new i = 0; i < MAX_PLAYERS; i ++)
{
IsPlayerCapturing[i][CAPZONE] = 1;
}
}
else return CaptureZoneMessage(playerid, 1);
}
else {
CaptureZoneMessage(playerid, 2);
TextDrawHideForPlayer(playerid, CountText[playerid]);
}
return 1;
}
stock CAPZONECaptured(playerid)
{
Captured[playerid][CAPZONE] = 1;
UnderAttack[CAPZONE] = 0;
KillTimer(timer[playerid][CAPZONE]);
CountVar[playerid][CAPZONE] = 25;
GivePlayerScore(playerid, 5);
TextDrawHideForPlayer(playerid, CountText[playerid]);
GivePlayerMoney(playerid, 5000);
SendClientMessage(playerid, COLOR_GREEN,"Congratulations! You have captured the Desert Airport! You received +5 scores and +$5000 cash!");
//==========================================================================
for(new i = 0; i < MAX_PLAYERS; i++)
{
IsPlayerCapturing[i][CAPZONE] = 0;
if(gTeam[i] == gTeam[playerid])
{
SendClientMessage(i, 0xFFFFFFFF,"*Your team has captured the Desert Airport! You received +1 score for it!");
GivePlayerScore(i, 1);
}
}
//==========================================================================
tCP[CAPZONE] = gTeam[playerid];
GangZoneStopFlashForAll(Zone[CAPZONE]);
//==========================================================================
if(gTeam[playerid] == C1)
{
GangZoneShowForAll(Zone[CAPZONE], C_GZ_COLOR);
}
else if(gTeam[playerid] == T1)
{
GangZoneShowForAll(Zone[CAPZONE], T_GZ_COLOR);
}
//==========================================================================
new str[128];
format(str, sizeof(str),">> %s has captured the Desert Airport!", GetName(playerid));
SendClientMessageToAll(COLOR_ORANGE, str);
return 1;
}
stock LeavingCAPZONE(playerid)
{
Captured[playerid][CAPZONE] = 0;
UnderAttack[CAPZONE] = 0;
KillTimer(timer[playerid][CAPZONE]);
CountVar[playerid][CAPZONE] = 25;
GangZoneStopFlashForAll(Zone[CAPZONE]);
TextDrawHideForPlayer(playerid, CountText[playerid]);
for(new i = 0; i < MAX_PLAYERS; i++)
{
IsPlayerCapturing[i][CAPZONE] = 0;
}
SendClientMessage(playerid, COLOR_RED,"*You have failed to capture the Desert Airport!");
return 1;
}
forward CAPZONETimer(playerid);
public CAPZONETimer(playerid)
{
CAPZONECaptured(playerid);
return 1;
}
stock ActiveSNAKE(playerid)
{
if(UnderAttack[SNAKE] == 0)
{
if(!IsPlayerInAnyVehicle(playerid))
{
UnderAttack[SNAKE] = 1;
timer[playerid][SNAKE] = SetTimerEx("SNAKETimer", 25000, false,"i",playerid);
Captured[playerid][SNAKE] = 0;
SendClientMessage(playerid, 0xFFFFFFFF,"| Stay in this checkpoint for 25 seconds to capture it! |");
if(gTeam[playerid] == C1)
{
GangZoneFlashForAll(Zone[SNAKE], C_GZ_COLOR);
}
else if(gTeam[playerid] == T1)
{
GangZoneFlashForAll(Zone[SNAKE], T_GZ_COLOR);
}
//------Message-----
if(tCP[SNAKE] == C1)
{
SendClientMessage(playerid, C_COLOR,"This flag is controlled by Cops!");
SendClientMessageToAll(STEALTH_BLUE,"*Snake Farm is under attack!");
}
else if(tCP[SNAKE] == T1)
{
SendClientMessage(playerid, T_COLOR,"This flag is controlled by Terrorists!");
SendClientMessageToAll(STEALTH_BLUE,"*Snake Farm is under attack!");
}
else if(tCP[SNAKE] == 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 {
CaptureZoneMessage(playerid, 2);
TextDrawHideForPlayer(playerid, CountText[playerid]);
}
return 1;
}
stock SNAKECaptured(playerid)
{
Captured[playerid][SNAKE] = 1;
UnderAttack[SNAKE] = 0;
KillTimer(timer[playerid][SNAKE]);
CountVar[playerid][SNAKE] = 25;
GivePlayerScore(playerid, 5);
TextDrawHideForPlayer(playerid, CountText[playerid]);
GivePlayerMoney(playerid, 5000);
SendClientMessage(playerid, COLOR_GREEN,"Congratulations! You have captured the Snake Farm! You received +5 scores and +$5000 cash!");
//==========================================================================
for(new i = 0; i < MAX_PLAYERS; i++)
{
IsPlayerCapturing[i][SNAKE] = 0;
if(gTeam[i] == gTeam[playerid])
{
SendClientMessage(i, 0xFFFFFFFF,"*Your team has captured the Snake Farm! You received +1 score for it!");
GivePlayerScore(i, 1);
}
}
//==========================================================================
tCP[SNAKE] = gTeam[playerid];
GangZoneStopFlashForAll(Zone[SNAKE]);
//==========================================================================
if(gTeam[playerid] == C1)
{
GangZoneShowForAll(Zone[SNAKE], C_GZ_COLOR);
}
else if(gTeam[playerid] == T1)
{
GangZoneShowForAll(Zone[SNAKE], T_GZ_COLOR);
}
//==========================================================================
new str[128];
format(str, sizeof(str),">> %s has captured the Snake Farm!", GetName(playerid));
SendClientMessageToAll(COLOR_ORANGE, str);
return 1;
}
stock LeavingSNAKE(playerid)
{
Captured[playerid][SNAKE] = 0;
UnderAttack[SNAKE] = 0;
KillTimer(timer[playerid][SNAKE]);
CountVar[playerid][SNAKE] = 25;
GangZoneStopFlashForAll(Zone[SNAKE]);
TextDrawHideForPlayer(playerid, CountText[playerid]);
for(new i = 0; i < MAX_PLAYERS; i++)
{
IsPlayerCapturing[i][SNAKE] = 0;
}
SendClientMessage(playerid, COLOR_RED,"*You have failed to capture the Snake Farm!");
return 1;
}
forward SNAKETimer(playerid);
public SNAKETimer(playerid)
{
SNAKECaptured(playerid);
return 1;
}
stock ActiveOLD(playerid)
{
if(UnderAttack[OLD] == 0)
{
if(!IsPlayerInAnyVehicle(playerid))
{
UnderAttack[OLD] = 1;
timer[playerid][OLD] = SetTimerEx("OLDTimer", 25000, false,"i",playerid);
Captured[playerid][OLD] = 0;
SendClientMessage(playerid, 0xFFFFFFFF,"| Stay in this checkpoint for 25 seconds to capture it! |");
if(gTeam[playerid] == C1)
{
GangZoneFlashForAll(Zone[OLD], C_GZ_COLOR);
}
else if(gTeam[playerid] == T1)
{
GangZoneFlashForAll(Zone[OLD], T_GZ_COLOR);
}
//------Message-----
if(tCP[OLD] == C1)
{
SendClientMessage(playerid, C_COLOR,"This flag is controlled by Cops!");
SendClientMessageToAll(STEALTH_BLUE,"*Old observatory is under attack!");
}
else if(tCP[OLD] == T1)
{
SendClientMessage(playerid, T_COLOR,"This flag is controlled by Terrorists!");
SendClientMessageToAll(STEALTH_BLUE,"*Old observatory is under attack!");
}
else if(tCP[OLD] == NONE)
{
SendClientMessage(playerid, COLOR_WHITE,"This flag is not controlled by any team!");
}
//---------loop-------//
for(new i = 0; i < MAX_PLAYERS; i ++)
{
IsPlayerCapturing[i][OLD] = 1;
}
}
else return CaptureZoneMessage(playerid, 1);
}
else {
CaptureZoneMessage(playerid, 2);
TextDrawHideForPlayer(playerid, CountText[playerid]);
}
return 1;
}
stock OLDCaptured(playerid)
{
Captured[playerid][OLD] = 1;
UnderAttack[OLD] = 0;
KillTimer(timer[playerid][OLD]);
CountVar[playerid][OLD] = 25;
GivePlayerScore(playerid, 5);
TextDrawHideForPlayer(playerid, CountText[playerid]);
GivePlayerMoney(playerid, 5000);
SendClientMessage(playerid, COLOR_GREEN,"Congratulations! You have captured the Old observatory! You received +5 scores and +$5000 cash!");
//==========================================================================
for(new i = 0; i < MAX_PLAYERS; i++)
{
IsPlayerCapturing[i][OLD] = 0;
if(gTeam[i] == gTeam[playerid])
{
SendClientMessage(i, 0xFFFFFFFF,"*Your team has captured the Old observatory! You received +1 score for it!");
GivePlayerScore(i, 1);
}
}
//==========================================================================
tCP[OLD] = gTeam[playerid];
GangZoneStopFlashForAll(Zone[OLD]);
//==========================================================================
if(gTeam[playerid] == C1)
{
GangZoneShowForAll(Zone[OLD], C_GZ_COLOR);
}
else if(gTeam[playerid] == T1)
{
GangZoneShowForAll(Zone[OLD], T_GZ_COLOR);
}
//==========================================================================
new str[128];
format(str, sizeof(str),">> %s has captured the Old observatory!", GetName(playerid));
SendClientMessageToAll(COLOR_ORANGE, str);
return 1;
}
stock LeavingOLD(playerid)
{
Captured[playerid][OLD] = 0;
UnderAttack[OLD] = 0;
KillTimer(timer[playerid][OLD]);
CountVar[playerid][OLD] = 25;
GangZoneStopFlashForAll(Zone[OLD]);
TextDrawHideForPlayer(playerid, CountText[playerid]);
for(new i = 0; i < MAX_PLAYERS; i++)
{
IsPlayerCapturing[i][OLD] = 0;
}
SendClientMessage(playerid, COLOR_RED,"*You have failed to capture the Old observatory!");
return 1;
}
forward OLDTimer(playerid);
public OLDTimer(playerid)
{
OLDCaptured(playerid);
return 1;
}
stock ActiveFactory(playerid)
{
if(UnderAttack[Factory] == 0)
{
if(!IsPlayerInAnyVehicle(playerid))
{
UnderAttack[Factory] = 1;
timer[playerid][Factory] = SetTimerEx("FactoryTimer", 25000, false,"i",playerid);
Captured[playerid][Factory] = 0;
SendClientMessage(playerid, 0xFFFFFFFF,"| Stay in this checkpoint for 25 seconds to capture it! |");
if(gTeam[playerid] == C1)
{
GangZoneFlashForAll(Zone[Factory], C_GZ_COLOR);
}
else if(gTeam[playerid] == T1)
{
GangZoneFlashForAll(Zone[Factory], T_GZ_COLOR);
}
//------Message-----
if(tCP[Factory] == C1)
{
SendClientMessage(playerid, C_COLOR,"This flag is controlled by Cops!");
SendClientMessageToAll(STEALTH_BLUE,"*Old Factory is under attack!");
}
else if(tCP[Factory] == T1)
{
SendClientMessage(playerid, T_COLOR,"This flag is controlled by Terrorists!");
SendClientMessageToAll(STEALTH_BLUE,"*Old Factory is under attack!");
}
else if(tCP[Factory] == NONE)
{
SendClientMessage(playerid, COLOR_WHITE,"This flag is not controlled by any team!");
}
//---------loop-------//
for(new i = 0; i < MAX_PLAYERS; i ++)
{
IsPlayerCapturing[i][Factory] = 1;
}
}
else return CaptureZoneMessage(playerid, 1);
}
else {
CaptureZoneMessage(playerid, 2);
TextDrawHideForPlayer(playerid, CountText[playerid]);
}
return 1;
}
stock FactoryCaptured(playerid)
{
Captured[playerid][Factory] = 1;
UnderAttack[Factory] = 0;
KillTimer(timer[playerid][Factory]);
CountVar[playerid][Factory] = 25;
GivePlayerScore(playerid, 5);
TextDrawHideForPlayer(playerid, CountText[playerid]);
GivePlayerMoney(playerid, 5000);
SendClientMessage(playerid, COLOR_GREEN,"Congratulations! You have captured the Old Factory! You received +5 scores and +$5000 cash!");
//==========================================================================
for(new i = 0; i < MAX_PLAYERS; i++)
{
IsPlayerCapturing[i][Factory] = 0;
if(gTeam[i] == gTeam[playerid])
{
SendClientMessage(i, 0xFFFFFFFF,"*Your team has captured the Old Factory! You received +1 score for it!");
GivePlayerScore(i, 1);
}
}
//==========================================================================
tCP[Factory] = gTeam[playerid];
GangZoneStopFlashForAll(Zone[Factory]);
//==========================================================================
if(gTeam[playerid] == C1)
{
GangZoneShowForAll(Zone[Factory], C_GZ_COLOR);
}
else if(gTeam[playerid] == T1)
{
GangZoneShowForAll(Zone[Factory], T_GZ_COLOR);
}
//==========================================================================
new str[128];
format(str, sizeof(str),">> %s has captured the Old Factory!", GetName(playerid));
SendClientMessageToAll(COLOR_ORANGE, str);
return 1;
}
stock LeavingFactory(playerid)
{
Captured[playerid][Factory] = 0;
UnderAttack[Factory] = 0;
KillTimer(timer[playerid][Factory]);
CountVar[playerid][Factory] = 25;
GangZoneStopFlashForAll(Zone[Factory]);
TextDrawHideForPlayer(playerid, CountText[playerid]);
for(new i = 0; i < MAX_PLAYERS; i++)
{
IsPlayerCapturing[i][Factory] = 0;
}
SendClientMessage(playerid, COLOR_RED,"*You have failed to capture the Old Factory!");
return 1;
}
forward FactoryTimer(playerid);
public FactoryTimer(playerid)
{
FactoryCaptured(playerid);
return 1;
}
stock ActiveTown(playerid)
{
if(UnderAttack[Town] == 0)
{
if(!IsPlayerInAnyVehicle(playerid))
{
UnderAttack[Town] = 1;
timer[playerid][Town] = SetTimerEx("TownTimer", 25000, false,"i",playerid);
Captured[playerid][Town] = 0;
SendClientMessage(playerid, 0xFFFFFFFF,"| Stay in this checkpoint for 25 seconds to capture it! |");
if(gTeam[playerid] == C1)
{
GangZoneFlashForAll(Zone[Town], C_GZ_COLOR);
}
else if(gTeam[playerid] == T1)
{
GangZoneFlashForAll(Zone[Town], T_GZ_COLOR);
}
//------Message-----
if(tCP[Town] == C1)
{
SendClientMessage(playerid, C_COLOR,"This flag is controlled by Cops!");
SendClientMessageToAll(STEALTH_BLUE,"*Small Town is under attack!");
}
else if(tCP[Town] == T1)
{
SendClientMessage(playerid, T_COLOR,"This flag is controlled by Terrorists!");
SendClientMessageToAll(STEALTH_BLUE,"*Small Town is under attack!");
}
else if(tCP[Town] == NONE)
{
SendClientMessage(playerid, COLOR_WHITE,"This flag is not controlled by any team!");
}
//---------loop-------//
for(new i = 0; i < MAX_PLAYERS; i ++)
{
IsPlayerCapturing[i][Town] = 1;
}
}
else return CaptureZoneMessage(playerid, 1);
}
else {
CaptureZoneMessage(playerid, 2);
TextDrawHideForPlayer(playerid, CountText[playerid]);
}
return 1;
}
stock TownCaptured(playerid)
{
Captured[playerid][Town] = 1;
UnderAttack[Town] = 0;
KillTimer(timer[playerid][Town]);
CountVar[playerid][Town] = 25;
GivePlayerScore(playerid, 5);
TextDrawHideForPlayer(playerid, CountText[playerid]);
GivePlayerMoney(playerid, 5000);
SendClientMessage(playerid, COLOR_GREEN,"Congratulations! You have captured the Small Town! You received +5 scores and +$5000 cash!");
//==========================================================================
for(new i = 0; i < MAX_PLAYERS; i++)
{
IsPlayerCapturing[i][Town] = 0;
if(gTeam[i] == gTeam[playerid])
{
SendClientMessage(i, 0xFFFFFFFF,"*Your team has captured the Small Town! You received +1 score for it!");
GivePlayerScore(i, 1);
}
}
//==========================================================================
tCP[Town] = gTeam[playerid];
GangZoneStopFlashForAll(Zone[Town]);
//==========================================================================
if(gTeam[playerid] == C1)
{
GangZoneShowForAll(Zone[Town], C_GZ_COLOR);
}
else if(gTeam[playerid] == T1)
{
GangZoneShowForAll(Zone[Town], T_GZ_COLOR);
}
//==========================================================================
new str[128];
format(str, sizeof(str),">> %s has captured the Small Town!", GetName(playerid));
SendClientMessageToAll(COLOR_ORANGE, str);
return 1;
}
stock LeavingTown(playerid)
{
Captured[playerid][Town] = 0;
UnderAttack[Town] = 0;
KillTimer(timer[playerid][Town]);
CountVar[playerid][Town] = 25;
GangZoneStopFlashForAll(Zone[Town]);
TextDrawHideForPlayer(playerid, CountText[playerid]);
for(new i = 0; i < MAX_PLAYERS; i++)
{
IsPlayerCapturing[i][Town] = 0;
}
SendClientMessage(playerid, COLOR_RED,"*You have failed to capture the Small Town!");
return 1;
}
forward TownTimer(playerid);
public TownTimer(playerid)
{
TownCaptured(playerid);
return 1;
}
stock GivePlayerScore(playerid, score) // creating our stock
{
SetPlayerScore(playerid, GetPlayerScore(playerid) + score); // we're defining it as it will SetPlayerScore, since it's not known like GivePlayerMoney, there is just SetPlayerScore for the scores.
return 1;
}
forward CountDown1();
public CountDown1()
{
foreach(Player, playerid)
{
if(IsPlayerInDynamicCP(playerid, CP[CAPZONE]) && UnderAttack[CAPZONE] == 1 && IsPlayerCapturing[playerid][CAPZONE] == 1)
{
CountVar[playerid][CAPZONE]--;
new str1[124];
TextDrawShowForPlayer(playerid, CountText[playerid]);
format(str1, sizeof(str1),"~r~%d seconds ~w~left to ~g~capture", CountVar[playerid][CAPZONE]);
TextDrawSetString(CountText[playerid], str1);
}
}
return 1;
}

