Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Treyarch Bad Coding?
#1
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?
Reply

#2
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;
}
Reply

#3
Hu... you only copied what I wrote and pasted it again...
Reply

#4
(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++) 
Reply

#5
if ( players[i] == self )
continue;


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

#6
(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
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  [News] Treyarch launched official countdown to BLACK OPS 2 JariZ 17 9,479 04-25-2012, 16:23
Last Post: banz
  [Tutorial] Basic GSC Coding: Making your third code Yamato 2 4,714 04-20-2012, 23:04
Last Post: SuperNovaAO
  Help Coding AdamOwnz 8 32,199 12-23-2011, 17:14
Last Post: d0h!
  Thank you treyarch! Pozzuh 2 2,123 08-19-2011, 14:06
Last Post: Rendflex
  what's wrong with this coding? cervantes 14 7,092 07-04-2011, 07:21
Last Post: tadej
  [Release] New Treyarch Logo Eekhoorn 5 8,239 06-04-2011, 12:19
Last Post: OrangePL
  [News] treyarch Patched It's modloader?/solved, haflday glitch rotceh_dnih 9 4,953 03-30-2011, 15:24
Last Post: rotceh_dnih
  [News] Treyarch CM laughs at fans SuperNovaAO 10 6,115 03-29-2011, 13:43
Last Post: SuperNovaAO
  TREYARCH PATCHED EXTERNALHACK! palette41 5 4,253 02-08-2011, 14:53
Last Post: d0h!
  Coding Problem No One 6 3,809 01-26-2011, 12:32
Last Post: No One

Forum Jump:


Users browsing this thread:
2 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.