Little help with progress bar and capture
#1

Well the capture bar works good but the problem is after its captured then when other teams capture it then the capture will not start filling,it will show already filled Bar,i tried setting its value to 0 but not working,any help pls

Код:
forward CountBar(playerid);
public CountBar(playerid)
{
	BarCount++;
	SetPlayerProgressBarValue(playerid, Bar, BarCount);
	return 1;
}

forward OnPlayerEnterDynamicCP(playerid, checkpointid);
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
	if(checkpointid == CP[CAPZONE])
	{
		if(UnderAttack[CAPZONE] == 0)
		{
			if(TCP[CAPZONE] != GetPlayerTeam(playerid))
			{
				CountVar[playerid][CAPZONE] = 30;
				ActiveCAPZONE(playerid);
				SetPlayerProgressBarValue(playerid, Bar, 0.0);
			} 	else return SendClientMessage(playerid, COLOR_RED,"*This zone is already captured by your team!");
		} else return CaptureZoneMessage(playerid, 2);
	}
	return 1;
}

stock ActiveCAPZONE(playerid)
{
		if(UnderAttack[CAPZONE] == 0)
		{
			if(!IsPlayerInAnyVehicle(playerid))
		 	{
			 	UnderAttack[CAPZONE] = 1;
			 	Timer[playerid][CAPZONE] = SetTimerEx("CAPZONETimer", 30000, false,"i",playerid);
			 	CountBarTimer = SetTimerEx("CountBar", 1000, true, "i", playerid);
			 	Bar = CreatePlayerProgressBar(playerid, 517.000000, 128.000000, 82.000000, 10.000000, 1189758719, 30.000000, BAR_DIRECTION_RIGHT);
   				ShowPlayerProgressBar(playerid,Bar);
			 	GangZoneCaptured[playerid][CAPZONE] = 0;
			 	SendClientMessage(playerid, COLOR_PINK,"| Stay in this checkpoint for 30 seconds to capture it! |");
			 	SendClientMessage(playerid, COLOR_PINK,"You are capturing this zone.");
             	if(GetPlayerTeam(playerid) == USA)
			    {
				  GangZoneFlashForAll(GangZone[CAPZONE], USA_COLOR);
				}
				else if(GetPlayerTeam(playerid) == TALIBAN)
				{
			      GangZoneFlashForAll(GangZone[CAPZONE], TALIBAN_COLOR);
			    }

				//------Message-----
			    if(TCP[CAPZONE] == USA)
			    {
			      SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by USA!");
			    }
			    else if(TCP[CAPZONE] == TALIBAN)
			    {
			      SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by Taliban!");
			    }

				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 return CaptureZoneMessage(playerid, 2);
		return 1;
}

stock CAPZONECaptured(playerid)
{

	GangZoneCaptured[playerid][CAPZONE] = 1;
	UnderAttack[CAPZONE] = 0;
	KillTimer(Timer[playerid][CAPZONE]);
	KillTimer(CountBarTimer);
    CountVar[playerid][CAPZONE] = 30;
    GivePlayerScore(playerid, 5);
    GivePlayerMoney(playerid, 5000);
	SendClientMessage(playerid, COLOR_GREEN,"Congratulations! You have captured the area! You received +5 scores and +$5000 cash!");
 	DestroyPlayerProgressBar(playerid, PlayerBar: Bar);
	//==========================================================================
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
	   IsPlayerCapturing[i][CAPZONE] = 0;
	   if(GetPlayerTeam(i) == GetPlayerTeam(playerid))
	   {
		   SendClientMessage(i,COLOR_PURPLE,"*Your team has captured the area! You received +1 score for it!");
		   GivePlayerScore(i, 1);
	   }
	}
	//==========================================================================
	TCP[CAPZONE] = GetPlayerTeam(playerid);
	GangZoneStopFlashForAll(GangZone[CAPZONE]);
	//==========================================================================
	if(GetPlayerTeam(playerid) == USA)
    {
	   GangZoneShowForAll(GangZone[CAPZONE], USA_COLOR);
	}
	else if(GetPlayerTeam(playerid) == TALIBAN)
	{
	GangZoneShowForAll(GangZone[CAPZONE], TALIBAN_COLOR);
	}
    //==========================================================================
    new str[128];
    format(str, sizeof(str),"~n~~g~%s ~w~has captured the capture zone!", GetName(playerid));
    TextDrawSetString(Message,str);
	return 1;
}

stock LeavingCAPZONE(playerid)
{
	GangZoneCaptured[playerid][CAPZONE] = 0;
	UnderAttack[CAPZONE] = 0;
	KillTimer(Timer[playerid][CAPZONE]);
	KillTimer(CountBarTimer);
    CountVar[playerid][CAPZONE] = 30;
    GangZoneStopFlashForAll(GangZone[CAPZONE]);
    SetPlayerProgressBarValue(playerid, Bar, 0.0);
    DestroyPlayerProgressBar(playerid, PlayerBar: Bar);
    for(new i = 0; i < MAX_PLAYERS; i++)
	{
	   IsPlayerCapturing[i][CAPZONE] = 0;
	}
	SendClientMessage(playerid, COLOR_RED,"*You have failed to capture this zone!");
	return 1;
}
Reply
#2

bumpy
Reply
#3

did you reset BarCount to 0 too ?
btw i think your code will got problem when 2 player capture 2 zone in same time
Reply
#4

FIXED
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)