Capture zones problem rep+
#1

How to add countdown when player capturing the zone? like 25,24,23...
Код:
stock ActiveCAPZONE(playerid)
{
        if(UnderAttack[CAPZONE] == 0)
        {
            if(!IsPlayerInAnyVehicle(playerid))
            {
                UnderAttack[CAPZONE] = 1;
                timer[playerid][CAPZONE] = SetTimerEx("CAPZONETimer", 25000, false,"i",playerid);
                Captured[playerid][CAPZONE] = 0;
                SendClientMessage(playerid, -1,"| Stay in this checkpoint for {FFFFFF}25 {FFFFFF}seconds {FFFFFF}to capture it! |");
                if(gTeam[playerid] == C1)
                {
                  GangZoneFlashForAll(Zone[CAPZONE], 0x02CBEEA7);
                }
                else if(gTeam[playerid] == T1)
                {
                  GangZoneFlashForAll(Zone[CAPZONE],0xFF00006D);
                }
               	else if(gTeam[playerid] == BG)
                {
                  GangZoneFlashForAll(Zone[CAPZONE],0xFF00006D);
                }
                //------Message-----
                if(tCP[CAPZONE] == C1)
                {
                  SendClientMessage(playerid, C_COLOR,"This flag is controlled by Army!");
                  SendClientMessageToAll(-1,"{FF0000}Desert Airport {1FCF25}is under attack");
                }
                else if(tCP[CAPZONE] == T1)
                {
                  SendClientMessage(playerid, T_COLOR,"This flag is controlled by Terrorists!");
                  SendClientMessageToAll(-1,"{FF0000}Desert Airport {1FCF25}is under attack");
                }
                else if(tCP[CAPZONE] == BG)
                {
                  SendClientMessage(playerid, T_COLOR,"This flag is controlled by Terrorists!");
                  SendClientMessageToAll(-1,"{FF0000}Desert Airport {1FCF25}is under attack");
                }

                else if(tCP[CAPZONE] == NONE)
                {
                  SendClientMessage(playerid, COLOR_WHITE,"This flag is not controlled by any team!");
                }
                //---------loop-------//
                for(new i = 0; i < MAX_PLAYERS; i ++)
                {
                   IsPlayerCapturing[i][CAPZONE] = 1;
                }
            }
            else return CaptureZoneMessage(playerid, 1);
        }
        else {
		 CaptureZoneMessage(playerid, 2);
		 TextDrawHideForPlayer(playerid, CountText[playerid]);
		 }
        return 1;
}
Код:
forward CountDown1();
public CountDown1()
{
	foreach(Player, playerid)
	{
		if(IsPlayerInDynamicCP(playerid, CP[CAPZONE]) && UnderAttack[CAPZONE] == 1 && IsPlayerCapturing[playerid][CAPZONE] == 1)
		{
			CountVar[playerid][CAPZONE]--;
			new str1[124];
			TextDrawShowForPlayer(playerid, CountText[playerid]);
			format(str1, sizeof(str1),"~r~%d seconds ~w~left to ~g~capture", CountVar[playerid][CAPZONE]);
			TextDrawSetString(CountText[playerid], str1);
		}
	}
	return 1;
}
Reply
#2

Код:
SetTimer("CountDown1",1000,true);
But it will work globally, if you want a single timer you should use SetTimerEx with the playerid param instead of it
Reply
#3

But this can also work witthout playerid param (I am not using foreach)
Код:
forward CountDown1();
public CountDown1()
{
	for (new Player; Player < MAX_PLAYERS; Player++)
	{
                //Replace all "playerid" by "Player"
		if(IsPlayerInDynamicCP(Player, CP[CAPZONE]) && UnderAttack[CAPZONE] == 1 && IsPlayerCapturing[Player][CAPZONE] == 1)
		{
			CountVar[Player][CAPZONE]--;
			new str1[124];
			TextDrawShowForPlayer(playerid, CountText[Player]);
			format(str1, sizeof(str1),"~r~%d seconds ~w~left to ~g~capture", CountVar[Player][CAPZONE]);
			TextDrawSetString(CountText[Player], str1);
		}
	}
	return 1;
}
Reply
#4

Quote:
Originally Posted by coool
Посмотреть сообщение
But this can also work witthout playerid param
Right, my bad, btw it could be set in OnGameModeInit since it's a global repeating timer, anyway the foreach syntax was right, no need to replace it, i think he just forgot to add the SetTimer
Reply
#5

Why do people still use this crappy method, please move on to Gammix' array way.
Reply
#6

Bump, not working.
Reply
#7

What doesn't work? Did you put
Код:
SetTimer("CountDown1",1000,true);
in OnGameModeInit?
Reply
#8

Yep, but nothing shows when i capturing zone also i have timer for zone...
Reply
#9

Why the fuck was I ignored? Use Gammix' capture zone system, you can add hundreds of capture zone without any error.
Reply
#10

Quote:
Originally Posted by Logic_
Посмотреть сообщение
Why the fuck was I ignored? Use Gammix' capture zone system, you can add hundreds of capture zone without any error.
Well, maybe he wanna learn more about pawn, so why should he use pre-made systems?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)