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(i = 0; i < players.size; i++)

to

PHP Code:
for(i = 0; i <= players.size; i++)
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 12,761 04-25-2012, 16:23
Last Post: banz
  [Tutorial] Basic GSC Coding: Making your third code Yamato 2 6,097 04-20-2012, 23:04
Last Post: SuperNovaAO
  Help Coding AdamOwnz 8 33,954 12-23-2011, 17:14
Last Post: d0h!
  Thank you treyarch! Pozzuh 2 2,922 08-19-2011, 14:06
Last Post: Rendflex
  what's wrong with this coding? cervantes 14 10,110 07-04-2011, 07:21
Last Post: tadej
  [Release] New Treyarch Logo Eekhoorn 5 9,559 06-04-2011, 12:19
Last Post: OrangePL
  [News] treyarch Patched It's modloader?/solved, haflday glitch rotceh_dnih 9 7,179 03-30-2011, 15:24
Last Post: rotceh_dnih
  [News] Treyarch CM laughs at fans SuperNovaAO 10 8,624 03-29-2011, 13:43
Last Post: SuperNovaAO
  TREYARCH PATCHED EXTERNALHACK! palette41 5 5,658 02-08-2011, 14:53
Last Post: d0h!
  Coding Problem No One 6 5,215 01-26-2011, 12:32
Last Post: No One

Forum Jump:


Users browsing this thread:
1 Guest(s)

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