09.08.2016, 16:33
How to add countdown when player capturing the zone?
here?
here?
Код:
stock ActiveTown(playerid) { if(UnderAttack[Town] == 0) { if(!IsPlayerInAnyVehicle(playerid)) { UnderAttack[Town] = 1; timer[playerid][Town] = SetTimerEx("TownTimer", 25000, false,"i",playerid); Captured[playerid][Town] = 0; SendClientMessage(playerid, -1,"| Stay in this checkpoint for {FFFFFF}25 {FFFFFF}seconds {FFFFFF}to capture it! |"); if(gTeam[playerid] == C1) { GangZoneFlashForAll(Zone[Town], COLOR_BLUE); } else if(gTeam[playerid] == T1) { GangZoneFlashForAll(Zone[Town], RED); } else if(gTeam[playerid] == BG) { GangZoneFlashForAll(Zone[Town], RED); } //------Message----- if(tCP[Town] == C1) { SendClientMessage(playerid, C_COLOR,"This flag is controlled by Cops!"); SendClientMessageToAll(-1,"{FFFFFF}>{FFFFFF}Old observatory is under attack!"); } else if(tCP[Town] == T1) { SendClientMessage(playerid, T_COLOR,"This flag is controlled by Terrorists!"); SendClientMessageToAll(-1,"{FFFFFF}>{FFFFFF}Old observatory is under attack!"); } else if(tCP[Town] == BG) { SendClientMessage(playerid, T_COLOR,"This flag is controlled by Terrorists!"); SendClientMessageToAll(-1,"{FFFFFF}>{FFFFFF}Old observatory is under attack!"); } else if(tCP[Town] == NONE) { SendClientMessage(playerid, COLOR_WHITE,"This flag is not controlled by any team!"); } //---------loop-------// for(new i = 0; i < MAX_PLAYERS; i ++) { IsPlayerCapturing[i][Town] = 1; } } else return CaptureZoneMessage(playerid, 1); } else { CaptureZoneMessage(playerid, 2); TextDrawHideForPlayer(playerid, CountText[playerid]); } return 1; } stock TownCaptured(playerid) { Captured[playerid][Town] = 1; UnderAttack[Town] = 0; KillTimer(timer[playerid][Town]); CountVar[playerid][Town] = 25; GivePlayerScore(playerid, 5); F_GivePlayerMoney(playerid, 5000); SendClientMessage(playerid, COLOR_GREEN,"{FFFFFF}Congratulations! You have captured the Old observatory! You received +5 scores and +$5000 cash!"); //========================================================================== for(new i = 0; i < MAX_PLAYERS; i++) { IsPlayerCapturing[i][Town] = 0; if(gTeam[i] == gTeam[playerid]) { SendClientMessage(i, -1,"{FFFFFF}Your team has captured the Old observatory! You received +1 score for it!"); GivePlayerScore(i, 1); } } //========================================================================== tCP[Town] = gTeam[playerid]; GangZoneStopFlashForAll(Zone[Town]); //========================================================================== if(gTeam[playerid] == C1) { GangZoneShowForAll(Zone[Town], COLOR_BLUE); } else if(gTeam[playerid] == T1) { GangZoneShowForAll(Zone[Town], RED); } else if(gTeam[playerid] == BG) { GangZoneShowForAll(Zone[Town], RED); } //========================================================================== new str[128]; format(str, sizeof(str),"{39AB2E}%s has captured the Old observatory!", GetName(playerid)); SendClientMessageToAll(-1, str); return 1; } stock LeavingTown(playerid) { Captured[playerid][Town] = 0; UnderAttack[Town] = 0; KillTimer(timer[playerid][Town]); CountVar[playerid][Town] = 25; GangZoneStopFlashForAll(Zone[Town]); for(new i = 0; i < MAX_PLAYERS; i++) { IsPlayerCapturing[i][Town] = 0; } SendClientMessage(playerid, COLOR_RED,"*You have failed to capture the Old observatory!"); return 1; } forward TownTimer(playerid); public TownTimer(playerid) { TownCaptured(playerid); return 1; } stock GivePlayerScore(playerid, score) // creating our stock { SetPlayerScore(playerid, GetPlayerScore(playerid) + score); // we're defining it as it will SetPlayerScore, since it's not known like F_GivePlayerMoney, there is just SetPlayerScore for the scores. 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; }