SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 20/08/2011, 02:35 PM   #1
Admigo
High-roller
 
Admigo's Avatar
 
Join Date: Oct 2010
Location: The Netherlands
Posts: 1,840
Reputation: 297
Default Capture Zones Basic needs more.

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.
__________________
Follow me on Instagram @brandonvanommen
Admigo is offline   Reply With Quote
Old 20/08/2011, 02:58 PM   #2
Lorenc_
High-roller
 
Lorenc_'s Avatar
 
Join Date: Jan 2010
Location: Australia
Posts: 3,793
Reputation: 1179
Default Re: Capture Zones Basic needs more.

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");
}
__________________
Join the best Cops And Robbers in SA-MP, today. svr.sfcnr.com:7777

Lorenc_ is offline   Reply With Quote
Old 20/08/2011, 03:11 PM   #3
Admigo
High-roller
 
Admigo's Avatar
 
Join Date: Oct 2010
Location: The Netherlands
Posts: 1,840
Reputation: 297
Default Re: Capture Zones Basic needs more.

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.
__________________
Follow me on Instagram @brandonvanommen
Admigo is offline   Reply With Quote
Old 20/08/2011, 03:42 PM   #4
Admigo
High-roller
 
Admigo's Avatar
 
Join Date: Oct 2010
Location: The Netherlands
Posts: 1,840
Reputation: 297
Default Re: Capture Zones Basic needs more.

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
__________________
Follow me on Instagram @brandonvanommen
Admigo is offline   Reply With Quote
Old 20/08/2011, 04:17 PM   #5
Babul
High-roller
 
Babul's Avatar
 
Join Date: Sep 2009
Location: in a cement block
Posts: 1,781
Reputation: 266
Default Re: Capture Zones Basic needs more.

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 >-<
__________________
FireWorks

new sscanf2 custom specifiers available for Download, read the Release Topic
Babul is offline   Reply With Quote
Old 20/08/2011, 04:52 PM   #6
Pinguinn
Huge Clucker
 
Join Date: Aug 2011
Location: The Netherlands
Posts: 313
Reputation: 34
Default Re: Capture Zones Basic needs more.

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);
    }
}
Pinguinn is offline   Reply With Quote
Old 20/08/2011, 08:27 PM   #7
Admigo
High-roller
 
Admigo's Avatar
 
Join Date: Oct 2010
Location: The Netherlands
Posts: 1,840
Reputation: 297
Default Re: Capture Zones Basic needs more.

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?
__________________
Follow me on Instagram @brandonvanommen
Admigo is offline   Reply With Quote
Old 29/06/2012, 05:09 AM   #8
FearLe$$
Little Clucker
 
FearLe$$'s Avatar
 
Join Date: May 2012
Posts: 31
Reputation: 5
Default Re: Capture Zones Basic needs more.

ill suggest to Use OnPlayerEnterDynamicCheckpoint Thats Better and Easier to make Capture Able Zones..
__________________
Expert Mapping and Scripting Starting From 1$ - 120$ Cheapest And Coolest Script Pm ME!
Free Scripting For Hosted Tab Servers (Will Take Rewards)

If You Like Any of These Please +REP Me
FearLe$$ is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can i make capture zones with timer? Admigo Help Archive 1 20/08/2011 01:12 PM
Capture the Plane f3llah1n Filterscripts 13 02/02/2010 09:50 PM
Capture The Car? DeltaAirlines12 Help Archive 3 10/09/2009 11:50 PM
A little problem with gang zones (only create gang zones) CTCCoco Help Archive 4 20/02/2009 10:59 AM


All times are GMT. The time now is 07:50 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.