![]() |
|
Treyarch Bad Coding? - Printable Version +- ItsMods (https://www.itsmods.com) +-- Forum: Archive (https://www.itsmods.com/Forum-Archive.html) +--- Forum: Archive (https://www.itsmods.com/Forum-Archive--64.html) +--- Thread: Treyarch Bad Coding? (/Thread-Treyarch-Bad-Coding.html) |
Treyarch Bad Coding? - Scripts18 - 07-22-2011 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? RE: Treyarch Bad Coding? - masterbob - 07-22-2011 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;
}RE: Treyarch Bad Coding? - Scripts18 - 07-22-2011 Hu... you only copied what I wrote and pasted it again... RE: Treyarch Bad Coding? - Pyroh - 07-22-2011 (07-22-2011, 15:05)Scripts18 Wrote: Hu... you only copied what I wrote and pasted it again... He changed PHP Code: for(i = 0; i < players.size; i++)
to PHP Code: for(i = 0; i <= players.size; i++)
RE: Treyarch Bad Coding? - koil - 07-22-2011 if ( players[i] == self ) continue; it doesnt count you, that is why... remove that section and it will count all players correctly. RE: Treyarch Bad Coding? - Scripts18 - 07-22-2011 (07-22-2011, 15:43)koil Wrote: if ( players[i] == self ) thx and pyro I tried and his code doesnt work.. works
|