(04-07-2012, 21:45)surtek Wrote: [ -> ]I have found the problem.
Problem:
Code:
getNumSurvivors()
{
numSurvivors = 0;
foreach ( player in level.players )
{
if ( player.team == "allies" )
numSurvivors++;
}
return numSurvivors;
}
It counts every players that belongs to the "allies" (team). Each player will add 1 to "numSurvivors". The problem is, that this function doesn't add -1 if a player loses connection or leaves.
How to solve:
Make a check how many players are really left each 2 seconds or something. Than put this amount in "numSurvivors".
I hope this helped you.
No. This isn't true. It checks the number of survivors every time an infected kills a player. Then it does if(survivorCount == 0) -> last survivor died, infected won.
Meh did someone figure out what was the exact issue? Rendflex and I have been trying to get this to work in MW2 but it never counts down.
Code:
updateTeamScores()
{
game["teamScores"]["axis"] = getNumInfected();
setTeamScore( "axis", getNumInfected() );
game["teamScores"]["allies"] = getNumSurvivors();
setTeamScore( "allies", getNumSurvivors() );
}
getNumInfected()
{
numInfected = 0;
foreach ( player in level.players )
{
if ( player.team == "axis" )
numInfected++;
}
return numInfected;
} //why are you so stupid! You don't even count correctly! (when you leave the counter stays the same)
getNumSurvivors()
{
numSurvivors = 0;
foreach ( player in level.players )
{
if ( player.team == "allies" )
numSurvivors++;
}
return numSurvivors;
} //why are you so stupid! You don't even count correctly!(when you leave the counter stays the same)
Problem being updateTeamScores() most likely, it does an update on: onSpawnPlayer(), onPlayerKilled(XXXXXXXXXXXXXXXX), and onPlayerDisconnect() *using a for(;
*.
Code:
onPlayerDisconnect()
{
for(;;)
{
level waittill( "disconnected", player );
updateTeamScores();
Any help will be appreciated.
Note: If you suggest putting: level waittill( "disconnected"); on updateTeamScores() don't. It doesn't even work... as it starts the match but you don't get any weapons nor does the counter even initialize.