if (GetPlayerTeam(playerid) != gCaptureZone[i][zone_Owner]) { if (IsPlayerInAnyVehicle(playerid)) { return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You cannot capture the zone in a vehicle."); } buf[0] = EOS; strcat(buf, "The zone is controlled by team "); strcat(buf, gTeamData[gCaptureZone[i][zone_Owner]][team_Name]); strcat(buf, "."); SendClientMessage(playerid, 0x00FF00FF, buf); SendClientMessage(playerid, 0x00FF00FF, "Stay in the checkpoint for "#CAPTURE_TIME" seconds to capture the zone."); GangZoneFlashForAll(gCaptureZone[i][zone_Id], SET_ALPHA(gTeamData[GetPlayerTeam(playerid)][team_Color], 100)); gCaptureZone[i][zone_Attacker] = playerid; gCaptureZone[i][zone_Players] = 1; gCaptureZone[i][zone_Tick][0] = 0; gCaptureZone[i][zone_Tick][1]= CAPTURE_TIME; KillTimer(gCaptureZone[i][zone_Timer]); gCaptureZone[i][zone_Timer] = SetTimerEx("OnZoneUpdate", 1000, true, "i", i); buf[0] = EOS; strcat(buf, "ZONE: Team "); strcat(buf, gTeamData[GetPlayerTeam(playerid)][team_Name]); strcat(buf, " is trying to capture zone "); strcat(buf, gCaptureZone[i][zone_Name]); strcat(buf, " against team "); strcat(buf, gTeamData[gCaptureZone[i][zone_Owner]][team_Name]); strcat(buf, "."); SendClientMessageToAll(0xFFFFFFFF, buf); PlayerTextDrawSetString(playerid, ptxtCapture[playerid], "Capturing in 30..."); PlayerTextDrawShow(playerid, ptxtCapture[playerid]); SetPlayerProgressBarValue(playerid, pbarCapture[playerid], gCaptureZone[i][zone_Tick][0]); ShowPlayerProgressBar(playerid, pbarCapture[playerid]); }
public OnZoneUpdate(zoneid) { switch(gCaptureZone[zoneid][zone_Players]) { case 1: { gCaptureZone[zoneid][zone_Tick][0] += 1; gCaptureZone[zoneid][zone_Tick][1] -= 1; } case 2: { gCaptureZone[zoneid][zone_Tick][0] += 2; gCaptureZone[zoneid][zone_Tick][1] += 2; } default: { gCaptureZone[zoneid][zone_Tick][0] += 3; gCaptureZone[zoneid][zone_Tick][1] += 2; } } for (new i, j = GetPlayerPoolSize(); i <= j; i++) { if (IsPlayerInDynamicCP(i, gCaptureZone[zoneid][zone_CPId]) && ! IsPlayerInAnyVehicle(i) && GetPlayerTeam(i) == GetPlayerTeam(gCaptureZone[zoneid][zone_Attacker])) // if the player is in CP, outside any vehicle and of same team that of attacker { SetPlayerProgressBarValue(i, pbarCapture[i], gCaptureZone[zoneid][zone_Tick][0]); } } if (gCaptureZone[zoneid][zone_Tick][0] > CAPTURE_TIME) { SendClientMessage(gCaptureZone[zoneid][zone_Attacker], 0x00FF00FF, "You have successfully captured the zone, +3 score and +$3000."); SetPlayerScore(gCaptureZone[zoneid][zone_Attacker], GetPlayerScore(gCaptureZone[zoneid][zone_Attacker]) + 3); GivePlayerMoney(gCaptureZone[zoneid][zone_Attacker], 3000); for (new p, l = GetPlayerPoolSize(); p <= l; p++) { if (IsPlayerInDynamicCP(p, gCaptureZone[zoneid][zone_CPId])) { PlayerTextDrawHide(p, ptxtCapture[p]); HidePlayerProgressBar(p, pbarCapture[p]); if (p != gCaptureZone[zoneid][zone_Attacker] && GetPlayerTeam(p) == GetPlayerTeam(gCaptureZone[zoneid][zone_Attacker]) && ! IsPlayerInAnyVehicle(p)) { SendClientMessage(p, 0x00FF00FF, "You have assisted your teammate to capture the zone, +1 score and +$1500."); SetPlayerScore(p, GetPlayerScore(p) + 1); GivePlayerMoney(p, 1500); } } } GangZoneStopFlashForAll(gCaptureZone[zoneid][zone_Id]); GangZoneShowForAll(gCaptureZone[zoneid][zone_Id], SET_ALPHA(gTeamData[GetPlayerTeam(gCaptureZone[zoneid][zone_Attacker])][team_Color], 100)); KillTimer(gCaptureZone[zoneid][zone_Timer]); new text[150]; strcat(text, "ZONE: Team "); strcat(text, gTeamData[GetPlayerTeam(gCaptureZone[zoneid][zone_Attacker])][team_Name]); strcat(text, " has successfully captured the zone "); strcat(text, gCaptureZone[zoneid][zone_Name]); strcat(text, " against team "); strcat(text, gTeamData[gCaptureZone[zoneid][zone_Owner]][team_Name]); strcat(text, "."); SendClientMessageToAll(0xFFFFFFFF, text); gCaptureZone[zoneid][zone_Owner] = GetPlayerTeam(gCaptureZone[zoneid][zone_Attacker]); gCaptureZone[zoneid][zone_Attacker] = INVALID_PLAYER_ID; } }
public OnPlayerEnterDynamicCP(playerid, checkpointid) { for (new i, j = sizeof(gCaptureZone); i < j; i++) { if (gCaptureZone[i][zone_CPId] == checkpointid) { new buf[150]; if (gCaptureZone[i][zone_Attacker] != INVALID_PLAYER_ID) { if (GetPlayerTeam(playerid) == GetPlayerTeam(gCaptureZone[i][zone_Attacker])) { if (IsPlayerInAnyVehicle(playerid)) { return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You cannot capture the zone in a vehicle."); } format(buf, sizeof(buf), "Capturing in %i...", gCaptureZone[i][zone_Tick][1]); PlayerTextDrawSetString(playerid, ptxtCapture[playerid], buf); PlayerTextDrawShow(playerid, ptxtCapture[playerid]); SetPlayerProgressBarValue(playerid, pbarCapture[playerid], gCaptureZone[i][zone_Tick][0]); ShowPlayerProgressBar(playerid, pbarCapture[playerid]); gCaptureZone[i][zone_Players]++; SendClientMessage(playerid, 0x00FF00FF, "Stay in the checkpoint to assist your teammate in capturing the zone."); } } else { if (GetPlayerTeam(playerid) != gCaptureZone[i][zone_Owner]) { if (IsPlayerInAnyVehicle(playerid)) { return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You cannot capture the zone in a vehicle."); } buf[0] = EOS; strcat(buf, "The zone is controlled by team "); strcat(buf, gTeamData[gCaptureZone[i][zone_Owner]][team_Name]); strcat(buf, "."); SendClientMessage(playerid, 0x00FF00FF, buf); SendClientMessage(playerid, 0x00FF00FF, "Stay in the checkpoint for "#CAPTURE_TIME" seconds to capture the zone."); GangZoneFlashForAll(gCaptureZone[i][zone_Id], SET_ALPHA(gTeamData[GetPlayerTeam(playerid)][team_Color], 100)); gCaptureZone[i][zone_Attacker] = playerid; gCaptureZone[i][zone_Players] = 1; gCaptureZone[i][zone_Tick][0] = 0; gCaptureZone[i][zone_Tick][1]= CAPTURE_TIME; KillTimer(gCaptureZone[i][zone_Timer]); gCaptureZone[i][zone_Timer] = SetTimerEx("OnZoneUpdate", 1000, true, "i", i); buf[0] = EOS; strcat(buf, "ZONE: Team "); strcat(buf, gTeamData[GetPlayerTeam(playerid)][team_Name]); strcat(buf, " is trying to capture zone "); strcat(buf, gCaptureZone[i][zone_Name]); strcat(buf, " against team "); strcat(buf, gTeamData[gCaptureZone[i][zone_Owner]][team_Name]); strcat(buf, "."); SendClientMessageToAll(0xFFFFFFFF, buf); PlayerTextDrawSetString(playerid, ptxtCapture[playerid], "Capturing in 30..."); PlayerTextDrawShow(playerid, ptxtCapture[playerid]); SetPlayerProgressBarValue(playerid, pbarCapture[playerid], gCaptureZone[i][zone_Tick][0]); ShowPlayerProgressBar(playerid, pbarCapture[playerid]); } } break; } } }
I made a gangzone system and i'm testing it a bit. When i enter the gangzone cp to start taking over, i get just the message "The zone is controlled by ... stay in cp for 30 seconds" and nothing happens. As you see, after this message, the gangzone should start flash and timer have to start, but nothing: |
GangZoneFlashForAll(gCaptureZone[i][zone_Id], SET_ALPHA(gTeamData[GetPlayerTeam(playerid)][team_Color], 100))
new const gTeamData[][e_TEAM_DATA] = { {"Usa", TEAM_USA_COLOUR}, {"Germany", TEAM_GERMANY_COLOUR}, {"Russia", TEAM_RUSSIA_COLOUR} };
new str[10];
format(str, sizeof str, "TEAM: %d", GetPlayerTeam(playerid));
SendClientMessage(playerid, -1, str);
gCaptureZone[i][zone_Id] = GangZoneCreate(gCaptureZone[i][zone_Pos][0], gCaptureZone[i][zone_Pos][1], gCaptureZone[i][zone_Pos][2], gCaptureZone[i][zone_Pos][3], SET_ALPHA(gTeamData[gCaptureZone[i][zone_Owner]][team_Color], 100), 2.0);
for(new i, j = sizeof(gCaptureZone); i < j; i++)
{
GangZoneShowForPlayer(playerid, gCaptureZone[i][zone_Id]);
}
public OnPlayerLeaveDynamicCP(playerid, checkpointid)
{
for (new i, j = sizeof(gCaptureZone); i < j; i++)
{
if (gCaptureZone[i][zone_CPId] == checkpointid)
{
if (gCaptureZone[i][zone_Attacker] != INVALID_PLAYER_ID)
{
if (GetPlayerTeam(playerid) == GetPlayerTeam(gCaptureZone[i][zone_Attacker]))
{
gCaptureZone[i][zone_Players]--;
if (! gCaptureZone[i][zone_Players])
{
SendClientMessage(playerid, 0xFF0000FF, "You failed to capture the zone, there were no teammates left in your checkpoint.");
GangZoneStopFlashForAll(gCaptureZone[i][zone_Id]);
new buf[150];
strcat(buf, "ZONE: Team ");
strcat(buf, gTeamData[GetPlayerTeam(playerid)][team_Name]);
strcat(buf, " failed to capture zone ");
strcat(buf, gCaptureZone[i][zone_Name]);
strcat(buf, " against team ");
strcat(buf, gTeamData[gCaptureZone[i][zone_Owner]][team_Name]);
strcat(buf, ".");
SendClientMessageToAll(0xFFFFFFFF, buf);
gCaptureZone[i][zone_Attacker] = INVALID_PLAYER_ID;
KillTimer(gCaptureZone[i][zone_Timer]);
}
else if (gCaptureZone[i][zone_Attacker] == playerid)
{
for (new p, l = GetPlayerPoolSize(); p <= l; p++)
{
if (GetPlayerTeam(p) == GetPlayerTeam(playerid))
{
if (IsPlayerInDynamicCP(p, checkpointid))
{
gCaptureZone[i][zone_Attacker] = p;
break;
}
}
}
}
}
PlayerTextDrawHide(playerid, ptxtCapture[playerid]);
HidePlayerProgressBar(playerid, pbarCapture[playerid]);
break;
}
}
}
}