Moin.
Ich will bei mir ein Rundensystem einfuegen. In meinem Gamemode gibt es 3 Teams, und wenn in mindestens 2 Teams mindestens 1 Spieler ist, soll ein Countdown starten.
Wenn zwischendurch Spieler rausgehen soll dieser wieder resettet werden.
Wenn der Countdown von 60 auf 0 runtergezaehlt hat sollen die Spieler gespawnt werden, und die Runde soll gestartet werden.
Ist das hier logisch umgesetzt? Und wann rufe ich am besten die Funktion StartGame() auf? Oder periodisch mit Timer?
Code
stock StartGame()
{
if(GetActiveTeamCount() > 1)
{
CountDownVar--;
new str[128];
if(CountDownVar == 0)
{
KillTimer(CountDownTimer2);
CountDownVar = 59;
GameHasStarted =1;
GameTextForAll("Start!",1000,1);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(gPlayerHasTeamSelected(i))
{
TeleportPlayerToBase(i);
TogglePlayerControllable(i,1);
ResetPlayerData(i);
}
}
}
else
{
format(str, sizeof(str), "Count Down: %d", CountDownTimer2);
GameTextForAll(str, 1000, 1);
}
return 1;
}
else
{
CountDownVar = 59;
}
}
Alles anzeigen
Hier die Funktion welche erkennt wenn eine Runde beendet ist.
Der rekursive Aufruf hier sinvoll?
Code
stock TeamsAlive(bool:value)
{
new i=0,count=0;
while(i<TEAMSIZE)
{
if(GetTeamPlayerCount(i) > 0)
{
count++;
}
i++;
}
if(bool:value == false)
switch(count)
{
case 1:
{
switch(TeamsAlive(true))
{
case FIRST_TEAM:
{
for(new d;d<MAX_PLAYERS;d++)
{
SendClientMessageEx(d,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FIRST_TEAM_COLOR_TAG);
}
}
case SECOND_TEAM:
{
for(new d;d<MAX_PLAYERS;d++)
{
SendClientMessageEx(d,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",SECOND_TEAM_COLOR_TAG);
}
}
#if defined TEAMSIZE
#if TEAMSIZE >= 3
case THIRD_TEAM:
{
for(new d;d<MAX_PLAYERS;d++)
{
SendClientMessageEx(d,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",THIRD_TEAM_COLOR_TAG);
}
}
#endif
#endif
#if defined TEAMSIZE
#if TEAMSIZE >= 4
case FOURTH_TEAM:
{
for(new d;d<MAX_PLAYERS;d++)
{
SendClientMessageEx(d,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FOURTH_TEAM_COLOR_TAG);
}
}
#endif
#endif
#if defined TEAMSIZE
#if TEAMSIZE >= 5
case FIFTH_TEAM:
{
for(new d;d<MAX_PLAYERS;d++)
{
SendClientMessageEx(d,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FIFTH_TEAM_COLOR_TAG);
}
}
#endif
#endif
#if defined TEAMSIZE
#if TEAMSIZE == 6
case SIXTH_TEAM:
{
for(new d;d<MAX_PLAYERS;d++)
{
SendClientMessageEx(d,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",SIXTH_TEAM_COLOR_TAG);
}
}
#endif
#endif
}
for(new o;o<MAX_PLAYERS;o++)
{
ResetPlayerData(o);
}
FinishedGame();
}
}
if(bool:value == true && count == 1)//Returns the ID of the remaining team
return i;
return 1;
}
Alles anzeigen