problem

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

problem

Post 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
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post 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,
Ric-hard
Sergeant Major
Posts: 102
Joined: Sun Feb 29, 2004 6:44 am
Location: sweden
Contact:

Post by Ric-hard »

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

should be

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

Richard
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post by ViPER »

ok thanks
Post Reply