SA-MP Forums Archive
How can i make capture zones with timer? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How can i make capture zones with timer? (/showthread.php?tid=277990)



How can i make capture zones with timer? - Admigo - 20.08.2011

Heey guys,
I want to make capture zones with pickup not with checkpoint.
You need to stay 20 seconds in pickup or in range to capure the zone but i dont know how.
I made the teams with gTeam[playerid].
Pls help me.


Re: How can i make capture zones with timer? - Admigo - 20.08.2011

I made this:
Code:
public OnPlayerPickUpPickup(playerid, pickupid)
{
	if(pickupid==areap&& gTeam[playerid]==TEAM_EUROPE && europecapture ==0)
	{
		areatimer=SetTimer("count1",1000,1);
		europetaken=1;
		ShowProgressBarForPlayer(playerid,capture);
	}
	if(pickupid==areap && gTeam[playerid]==TEAM_EUROPE && europecapture ==1)
	{
		SendClientMessage(playerid,red,"Your team already has Area51!");
		HideProgressBarForPlayer(playerid,capture);
	}
	if(pickupid==oldairportp && gTeam[playerid]==TEAM_EUROPE && europecapture ==0)
	{
		oldairporttimer=SetTimer("count2",1000,1);
		europetaken=1;
		ShowProgressBarForPlayer(playerid,capture);
	}
	if(pickupid==oldairportp && gTeam[playerid]==TEAM_EUROPE && europecapture ==1)
	{
		SendClientMessage(playerid,red,"Your team already has Old Airport!");
		HideProgressBarForPlayer(playerid,capture);
	}

	return 1;
}
And the Timers:
Code:
forward count1(playerid);
public count1(playerid)
{
//new string[56];
counter++;
SetProgressBarValue(capture, counter);
SetProgressBarMaxValue(capture, 20);
UpdateProgressBar(capture, playerid);
//format(string, sizeof(string),"~r~Wait %d seconds to capture Area51!!",counter);
//GameTextForAll(string,1000,5);
if(counter==20)
{
	if(europetaken==1)
	{
			GangZoneShowForAll( area, GZ_YELLOW);
   			SetPlayerScore(playerid,GetPlayerScore(playerid)+4);
   			GiveTeamScore(gTeam[playerid]=TEAM_EUROPE, 1);
			SendClientMessage(playerid,COLOR_WHITE,"You received 5 score and 6000 Dollar for capturing Area59!");
			if(playerid)
			{
			SendTeamMessage(COLOR_WHITE, "",TEAM_EUROPE);
			}
			SendTeamMessage(COLOR_WHITE, "You received 1 Score For a Capture!",TEAM_EUROPE);
			GivePlayerMoney(playerid,6000);
			europecapture=1;
   			usacapture=0;
   			//japancapture=0;
   			//russiacapture=0;
   			//afghancapture=0;
			capturedzones[playerid]++;
			HideProgressBarForPlayer(playerid,capture);
			KillTimer(areatimer);
	}
	if(usataken==1)
	{
			GangZoneShowForAll( area, GZ_LIGHTBLUE);
   			SetPlayerScore(playerid,GetPlayerScore(playerid)+4);
            GiveTeamScore(gTeam[playerid]=TEAM_EUROPE, 1);
			europecapture=0;
   			usacapture=1;
   			//japancapture=0;
   			//russiacapture=0;
   			//afghancapture=0;
			capturedzones[playerid]++;
			KillTimer(areatimer);
	}
	if(japantaken==1)
	{
			GangZoneShowForAll( area, GZ_DARKRED);
   			SetPlayerScore(playerid,GetPlayerScore(playerid)+4);
            GiveTeamScore(gTeam[playerid]=TEAM_JAPAN, 1);
			europecapture=0;
   			usacapture=0;
   			//japancapture=1;
   			//russiacapture=0;
   			//afghancapture=0;
			capturedzones[playerid]++;
			KillTimer(areatimer);
	}
	if(russiataken==1)
	{
			GangZoneShowForAll( area, GZ_PINK);
   			SetPlayerScore(playerid,GetPlayerScore(playerid)+4);
            GiveTeamScore(gTeam[playerid]=TEAM_RUSSIA, 1);
			europecapture=0;
   			usacapture=0;
   			//japancapture=0;
   			//russiacapture=1;
   			//afghancapture=0;
			capturedzones[playerid]++;
			KillTimer(areatimer);
	}
	if(afghantaken==1)
	{
			GangZoneShowForAll( area, GZ_WHITE);
   			SetPlayerScore(playerid,GetPlayerScore(playerid)+4);
            GiveTeamScore(gTeam[playerid]=TEAM_AFGHAN, 1);
   			//afghancapture=1;
			europecapture=0;
   			usacapture=0;
   			//japancapture=0;
   			//russiacapture=0;
			capturedzones[playerid]++;
			KillTimer(areatimer);
	}
	counter=20;
	HideProgressBarForPlayer(playerid, capture);
	if(counter>0 && counter<20)
	{
		if(europetaken==1&& !IsPlayerInRangeOfPoint(playerid,2.0,214.7506,1822.6283,6.4141))
		{
		    KillTimer(areatimer);
		    HideProgressBarForPlayer(playerid,capture);
		}
	}
}
The other timer is the same but only the range and the gangzones are dfferent.
Now if i capture one i cant take the other.
Pls can anyone help me making capture zones?