ItsMods

Full Version: Treyarch Bad Coding?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
CountPlayers()
{
    
    players = level.players;
    allies = 0;
    axis = 0;
    for(i = 0; i < players.size; i++)
    {
        if ( players[i] == self )
            continue;
            
        if((isdefined(players[i].pers["team"])) && (players[i].pers["team"] == "allies"))
            allies++;
        else if((isdefined(players[i].pers["team"])) && (players[i].pers["team"] == "axis"))
            axis++;            
    }
    players["allies"] = allies;
    players["axis"] = axis;
    return players;
}

When using this and printing what it does to the screen

(playing with bots on 6v6)

Teams are always 5-6 or 6-5 (they switched all the time but never 6-6)

any one knows how to fix that?
Code:
CountPlayers()
{
    
     players = level.players;
     allies = 0;
     axis = 0;
     for(i = 0; i <= players.size; i++)
     {
         if ( players[i] == self )
             continue;
            
         if((isdefined(players[i].pers["team"])) && (players[i].pers["team"] == "allies"))
             allies++;
         else if((isdefined(players[i].pers["team"])) && (players[i].pers["team"] == "axis"))
             axis++;            
     }
     players["allies"] = allies;
     players["axis"] = axis;
     return players;
}
Hu... you only copied what I wrote and pasted it again...
(07-22-2011, 15:05)Scripts18 Wrote: [ -> ]Hu... you only copied what I wrote and pasted it again...

He changed
PHP Code:
for(0players.sizei++) 

to

PHP Code:
for(0<= players.sizei++) 
if ( players[i] == self )
continue;


it doesnt count you, that is why... remove that section and it will count all players correctly.
(07-22-2011, 15:43)koil Wrote: [ -> ]if ( players[i] == self )
continue;


it doesnt count you, that is why... remove that section and it will count all players correctly.

thx and pyro I tried and his code doesnt work..

works Smile