Quote:
Originally Posted by BenzoAMG
Why not get the amount of players in the certain area, then deduct that from the total time? Example: There is 1 player in the area, and the timer is deducting 1 point every second. Another player enters and the timer then begins to deduct 2 points every second, having the same effect as halving the timer, where when the points reach or go below 0, the timer stops and the zone is then captured.
Further Example of code:
pawn Код:
ZonePoints[RedZone] = 30; //We want to have 30 seconds for a single player, so we will use 30 points. SetTimer("CaptureRedZone", 1000, true); //Timer will repeat, every second.
forward CaptureRedZone(); public CaptureRedZone() { new count = 0; //Begin the count at 0 players. for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) //foreach is a better alternative { if(IsPlayerInRangeOfPoint(i, range, X, Y, Z)) //Check if they are in, or near the area, you can use your own custom functions/stocks instead of IsPlayerInRangeOfPoint if you want. { if(gTeam[i] != TEAM_RED) //Check if the zone does not belong to them { count++; continue; } } } } if(count == 0) return ZonePoints[RedZone] = 30; //Reset the points if the players leave the area. ZonePoints[RedZone] = ZonePoints[RedZone] - count; if(ZonePoints[RedZone] <= 0) { SendClientMessageToAll(0xFF0000FF, "The red zone has been captured."); KillTimer("ZoneCapture"); //This won't work, but you can change it accordingly so it no longer continues to countZonePoints[RedZone] = 0; //Capture area etc. } return 1; }
This is an example, probably not the best method available, but should work properly.
|
Yes i think i need this this works for dynamiccheckpoints aswell?