View Single Post
  #1  
Old 02-09-2009, 05:40 AM
thatdwarf thatdwarf is offline
Former UN Dev Admin
Join Date: Nov 2005
Posts: 42
thatdwarf is on a distinguished road
Nested for() functions duplicating output

Alright, the problem I am having is with a GUI control, I want to add a filtered list of the player's weapons.

The below code doesnt filter the desired content (and yes, there is an array defined already called this.bannedNPCs)

flip the for() loops around, and it filters nothing, but duplicates the output a couple times

for example: -wep, -wep, -wep, -wep, -anotherwep, and so on
PHP Code:
function LAucItem.onSelect(idtxtind) {
  
L_List.clearrows();
  if(
txt == "NPC") {
    for(
temp.weps this.bannedNPCs) {
      for(
temp.0temp.player.weapons.size(); temp.i++) {
        if(!
player.weapons[temp.i].name.starts(temp.weps))
          
L_List.addrow(temp.iplayer.weapons[temp.i].name);
      }
    }
  }

Any ideas on how to fix this?

Thanks!
Reply With Quote