Capture Zones Basic needs more.
#1

Heey guys,
I just made a basic for capture zones with no timer and you can capture it everytime:
Code:
public OnPlayerPickUpPickup(playerid, pickupid)
{
	if(pickupid==areap)
	{
		if(gTeam[playerid]==TEAM_EUROPE)
		{
		GangZoneShowForAll(area,GZ_YELLOW);
		}
		if(gTeam[playerid]==TEAM_USA)
		{
		GangZoneShowForAll(area,GZ_BLUE);
		}
	}
	if(pickupid==oldairportp)
	{
		if(gTeam[playerid]==TEAM_EUROPE)
		{
		GangZoneShowForAll(oldairport,GZ_YELLOW);
		}
		if(gTeam[playerid]==TEAM_USA)
		{
		GangZoneShowForAll(oldairport,GZ_BLUE);
		}
	}
	return 1;
}
}
Now i need add a 20 seconds timer to it. And if team has the capture that you cant capture it anymore.
Can someone help me with this pls.
I give rep+ for it.
Reply
#2

I would advise you use a checkpoint streamer, it'd be much better.

Wrote a example, will not work but yeah, its using some sort of checkpoint streamer. It shows the base of it.

pawn Code:
new ZONE_1;
ZONE_1 = CreateStreamedCheckpoint(...);

public OnPlayerEnterStreamedCheckpoint(playerid, cp)
{
    if(IsPlayerInCheckpoint(playerid, ZONE_1))
    {
        g_PlayerInCheckpoint_1[playerid] = 1; // Can use a boolean & array
        g_PlayerCapturePointTimer[playerid] = SetTimer("CaptureArea", 10000, false);
    }
    return 1;
}

public OnPlayerLeaveStreamedCheckpoint(playerid)
{
    if(g_PlayerInCheckpoint_1[playerid] == 1)
    {
        g_PlayerInCheckpoint_1[playerid] = 0; // Can use a boolean & array
        KillTimer(g_PlayerCapturePointTimer[playerid]);
    }
    return 1;
}

public CaptureArea()
{
    print("Success");
}
Reply
#3

Now i made with pickups and if(!IsPlayerInRange so they when they leave pickup the timer stops. Its easy to make a counter and timer but problem is the player can take the gangzone everytime when the capture already is taken by his team.
Reply
#4

How can i make that the player from a team cant take the zone bacause its already token.
I know its with variable but i dunno how because if i make that i can only take one gangzone and not more because its says i already token it:P
Reply
#5

i want to mention that you can use the pickups (inclusive any desired amount of time) to use for capturing zones. iam in a hurry, so there will be some bugs:
Code:
OPPU()
{
	If(GetPVarInt(playerid,"StayingInPickupAlreadySinceMS")==0 || GetTickCount()-GetPVarInt(playerid,"StayingInPickupAlreadySinceMS")>20000)//if not set (or deleted from last capture) then set the pvar to the actual servertime
	{
		SetPVarInt(playerid,"StayingInPickupAlreadySinceMS",GetTickCount());
		return 1;
	}
	else//its >0, so the player already touched the pickup. time to calculate the difference:
	{
		SetPVarInt(playerid,"StayingInPickupAlreadyHowLongMS",GetTickCount()-GetPVarInt(playerid,"StayingInPickupAlreadySinceMS"));
		if(GetPVarInt(playerid,"StayingInPickupAlreadyHowLongMS")>20000)
		{
			//zone captured. DONT forget to erase the pvars aswell
			DeletePVar(playerid,"StayingInPickupAlreadySinceMS");
			DeletePVar(playerid,"StayingInPickupAlreadyHowLongMS");
		}
		else
		{
			//capture failed, coz the player is not touching the pickups anymore
			DeletePVar(playerid,"StayingInPickupAlreadySinceMS");
			DeletePVar(playerid,"StayingInPickupAlreadyHowLongMS");
		}
	}
}
the precision is not that precise like a timer, but who gives a fuck for max. 1 second tolerance? i dont
the idea with =="leaving pickup" can be reversed to !="still touching pickup". plus: w/o any need for yet 1 more timer... sry if theres a concept bug, give it a try
if you leave the pickup, you wont get any message unless you capture the zone. thats the downside, and you need to add a check if the "old" stored time is >20000 ms away (left pickups earlier), so you need to initialize it again >-<
Reply
#6

Try this. I don't know if it works but as Lorenc_ also said, this is an example

If you got a function like "GetTeamArea" then you need to replace "if(gTeam[i] ==)"
Add this at the area capture

NOTE: You don't have to add the loops everywhere. At the top of the public function start with "for(new i; i < MAX_PLAYERS; i++)".
Open with a bracket and then end with a bracket.

pawn Code:
for(new i; i < MAX_PLAYERS; i++)
{
    if(gTeam[i] == gTeam[playerid])
    {
        SetPVarInt(i, "areaTaken/*add the area here for example Area69*/", 1);
    }
}
Add this when he enters the area

pawn Code:
for(new i; i < MAX_PLAYERS; i++)
{
    if(gTeam[i] == /* add team here*/ && (GetPVarInt(i, "areaTaken/*add the area here for example Area69*/") == 1))
    {
        SendClientMessage(playerid, "Your team has already taken over this area");
        SetPVarInt(playerid, "team/*team name*/_area/*area name*/", 1);
    }
}
Add this when the area is taken over from an other team

pawn Code:
for(new i; i < MAX_PLAYERS; i++)
{
    if(GetPVarInt(i, teamEurope_areaArea69) == 1)   // THIS IS AN EXAMPLE
    {
        SetPVarInt(i, teamEurope_areaArea69, 0);
    }
   
    if(gTeam[i] == /* add team here*/ && (GetPVarInt(i, "areaTaken/*add the area here for example Area69*/") == 1))
    {
        SetPVarInt(playerid, "team/*team name*/_area/*area name*/", 1);
    }
}
Reply
#7

Quote:
Originally Posted by Pinguinn
View Post
Try this. I don't know if it works but as Lorenc_ also said, this is an example

If you got a function like "GetTeamArea" then you need to replace "if(gTeam[i] ==)"
Add this at the area capture

NOTE: You don't have to add the loops everywhere. At the top of the public function start with "for(new i; i < MAX_PLAYERS; i++)".
Open with a bracket and then end with a bracket.

pawn Code:
for(new i; i < MAX_PLAYERS; i++)
{
    if(gTeam[i] == gTeam[playerid])
    {
        SetPVarInt(i, "areaTaken/*add the area here for example Area69*/", 1);
    }
}
Add this when he enters the area

pawn Code:
for(new i; i < MAX_PLAYERS; i++)
{
    if(gTeam[i] == /* add team here*/ && (GetPVarInt(i, "areaTaken/*add the area here for example Area69*/") == 1))
    {
        SendClientMessage(playerid, "Your team has already taken over this area");
        SetPVarInt(playerid, "team/*team name*/_area/*area name*/", 1);
    }
}
Add this when the area is taken over from an other team

pawn Code:
for(new i; i < MAX_PLAYERS; i++)
{
    if(GetPVarInt(i, teamEurope_areaArea69) == 1)   // THIS IS AN EXAMPLE
    {
        SetPVarInt(i, teamEurope_areaArea69, 0);
    }
   
    if(gTeam[i] == /* add team here*/ && (GetPVarInt(i, "areaTaken/*add the area here for example Area69*/") == 1))
    {
        SetPVarInt(playerid, "team/*team name*/_area/*area name*/", 1);
    }
}
How can i make this in a timer so the player needs to be 20 seconds in pickup to capture?
Reply
#8

ill suggest to Use OnPlayerEnterDynamicCheckpoint Thats Better and Easier to make Capture Able Zones..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)