Page 1 of 1

problem

Posted: Thu Jun 23, 2005 10:35 pm
by ViPER
ok , why is it that this does not work???

Code: Select all

peepscounter:
   iprintln ("CT")
   level.allies = 0 
   level.axis = 0 
   level.spectator = 0 
   for(local.dude=1;local.dude <= $player.size;local.dude++) 
   { 
   if ($player[local.dude].dmteam == "axis") 
   level.axis++ 
   if ($player[local.dude].dmteam == "allies") 
   level.allies++ 
   if ($player[local.dude].dmteam == "spectator") 
   level.spectator++ 
   } 
   if (level.allies + level.axis + level.spectator <= 1) 
   { 
   local.totalpeeps = 1 
   } 
   if (level.allies + level.axis + level.spectator = 2) 
   { 
   local.totalpeeps = 2 
   } 
   if (level.allies + level.axis + level.spectator >= 3) 
   { 
   local.totalpeeps = 3 
   }
   wait 1 

   setcvar totalpeeps local.totalpeeps 

end
It crashes the script

when this does work -

Code: Select all

countpeeps:
   iprintln ("counting")
   level.allies = 0 
   level.axis = 0 
   level.spectator = 0 
   for(local.dude=1;local.dude <= $player.size;local.dude++) 
   { 
   if ($player[local.dude].dmteam == "axis") 
   level.axis++ 
   if ($player[local.dude].dmteam == "allies") 
   level.allies++ 
   if ($player[local.dude].dmteam == "spectator") 
   level.spectator++ 
   } 
   if (level.allies + level.axis + level.spectator <= 6) 
   { 
   local.totalpeeps = 1 
   } 
   if ((level.allies + level.axis + level.spectator > 6) && (level.allies + level.axis + level.spectator < 15)) 
   { 
   local.totalpeeps = 2 
   } 
   if (level.allies + level.axis + level.spectator >= 15) 
   { 
   local.totalpeeps = 3 
   } 
   wait 1 

   setcvar totalpeeps local.totalpeeps 

end

Posted: Thu Jun 23, 2005 11:45 pm
by ViPER
Does multiple if require the && statement in the middle?

I can get the logic to work if i use the && in the middle if statements,

Posted: Fri Jun 24, 2005 12:49 am
by Ric-hard
if (level.allies + level.axis + level.spectator = 2)

should be

if (level.allies + level.axis + level.spectator == 2)

Richard

Posted: Fri Jun 24, 2005 1:34 am
by ViPER
ok thanks