SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 23/03/2017, 10:26 AM   #1
Face9000
Banned
 
Join Date: Jan 2010
Location: Pigland
Posts: 3,351
Reputation: 190
Default Gangzones

I made a gangzone system thanks to Gammix's tutoril 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:

Code:
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]);
				}
Seems the code breaks after the message..

Last edited by Face9000; 23/03/2017 at 09:20 PM.
Face9000 is offline   Reply With Quote
Old 23/03/2017, 10:37 AM   #2
coool
Gangsta
 
coool's Avatar
 
Join Date: Feb 2013
Location: Republic of Pakistan
Posts: 629
Reputation: 54
Default Re: Gangzones

You mean it is stuck on "Capturing in 30..." if yes. Show us the OnZoneUpdate.
Is this gammix's tutorial, this happened with me too
__________________
coool is offline   Reply With Quote
Old 23/03/2017, 10:39 AM   #3
Face9000
Banned
 
Join Date: Jan 2010
Location: Pigland
Posts: 3,351
Reputation: 190
Default Re: Gangzones

No, the Capturing in 30 doesnt even show. I just got that message and nothing more. No progress bar, no capturing, no flash.

This is OnZoneUpdate:

Code:
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;
	}
}
This is the full OnPlayerEnterDynamicCp (which i get a warning when compiling because OnPlayerEnterDynamicCp should return a value..)

Code:
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;
		}
	}
}
Face9000 is offline   Reply With Quote
Old 23/03/2017, 04:07 PM   #4
Logic_
Banned
 
Join Date: Jun 2015
Posts: 1,506
Reputation: 305
Default Re: Gangzones

Quote:
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:
*Starts sarcastic coughing*
This whole code is from the Gammix' tutorial, which can be further optimized and rewritten.

The problem is in this line:
PHP Code:
GangZoneFlashForAll(gCaptureZone[i][zone_Id], SET_ALPHA(gTeamData[GetPlayerTeam(playerid)][team_Color], 100)) 
You need to modify this line, or also you may need to show us your gTeamData array.

However, you may freely contact me for further issues
Logic_ is offline   Reply With Quote
Old 23/03/2017, 09:20 PM   #5
Face9000
Banned
 
Join Date: Jan 2010
Location: Pigland
Posts: 3,351
Reputation: 190
Default Re: Gangzones

What's wrong with that line? How can that code block everything? However, this gTeamData array:

Code:
new const gTeamData[][e_TEAM_DATA] =
{
	{"Usa", TEAM_USA_COLOUR},
	{"Germany", TEAM_GERMANY_COLOUR},
	{"Russia", TEAM_RUSSIA_COLOUR}
};
And, i know it's from Gammix.
Face9000 is offline   Reply With Quote
Old 24/03/2017, 10:12 AM   #6
Logic_
Banned
 
Join Date: Jun 2015
Posts: 1,506
Reputation: 305
Default Re: Gangzones

Are you properly setting your team? Debug by adding a message that prints your team ID by using GetPlayerTeam native.

PHP Code:
new str[10];
format(strsizeof str"TEAM: %d"GetPlayerTeam(playerid));
SendClientMessage(playerid, -1str); 
Logic_ is offline   Reply With Quote
Old 24/03/2017, 11:25 AM   #7
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,773
Reputation: 858
Default Re: Gangzones

Are you using "gangzones.inc"?
If so try compiling without that include. You might have to change a few things.
__________________

Follow me on Github: Donate on Paypal:

Gammix is offline   Reply With Quote
Old 24/03/2017, 09:51 PM   #8
Face9000
Banned
 
Join Date: Jan 2010
Location: Pigland
Posts: 3,351
Reputation: 190
Default Re: Gangzones

@Logic_ where i should put that debug code?


@Gamminx, im using the compact version of gangzones (gangzonesc.inc).
I tried to remove it and i got this errors while compiling:

warning 202: number of arguments does not match definition

In this code:
pawn Code:
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);

warning 202: number of arguments does not match definition, here:

pawn Code:
for(new i, j = sizeof(gCaptureZone); i < j; i++)
    {
        GangZoneShowForPlayer(playerid, gCaptureZone[i][zone_Id]);
    }

And...

warning 209: function "OnPlayerEnterDynamicCP" should return a value

pawn Code:
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;
            }
        }
    }
}
Face9000 is offline   Reply With Quote
Old 24/03/2017, 11:21 PM   #9
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,773
Reputation: 858
Default Re: Gangzones

Update your include "gangzone.inc" and also checkout a little update i made in tutorial, basically fixes those warnings.
__________________

Follow me on Github: Donate on Paypal:

Gammix is offline   Reply With Quote
Old 25/03/2017, 12:15 AM   #10
Face9000
Banned
 
Join Date: Jan 2010
Location: Pigland
Posts: 3,351
Reputation: 190
Default Re: Gangzones

Do i need to use the compact version or the standard?
Face9000 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
[Ajuda] Gangzones xFrajola Português/Portuguese 3 06/07/2015 05:48 PM
[Ajuda] GangZones VeNuZ_ Português/Portuguese 5 01/08/2014 04:02 PM
need some help with gangzones... niels44 Scripting Help 5 21/12/2011 02:31 PM
Gangzones usekevin1988 Scripting Help 17 01/12/2011 11:17 AM
GangZones Baks Scripting Help 4 18/11/2011 08:19 PM


All times are GMT. The time now is 05:59 PM.


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