Gangzones
#1

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:

Код:
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..
Reply
#2

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
Reply
#3

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:

Код:
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..)

Код:
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;
		}
	}
}
Reply
#4

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 код:
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
Reply
#5

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

Код:
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.
Reply
#6

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

PHP код:
new str[10];
format(strsizeof str"TEAM: %d"GetPlayerTeam(playerid));
SendClientMessage(playerid, -1str); 
Reply
#7

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

@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 Код:
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 Код:
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 Код:
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;
            }
        }
    }
}
Reply
#9

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

Do i need to use the compact version or the standard?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)