Announcement

Collapse
No announcement yet.

Menu Code Bug (long snippet)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Menu Code Bug (long snippet)

    Be warned, a very large snippet is in this post...

    Anyway, I'm trying to develop a mutator called Buddies Stick Together. Basically, you can pick a Best Friend and you can pick some Buddies (probably will limit it to 3). Your Buddies will have a brighter tag, along with your Best Friend, which is a different color. If your Best Friend runs to far away (150 meters) you will be notified at the top of the screen. Also, if the Buddies and Best Friend goes off screen, a tag will appear on the right or left (which ever is closer) side of the screen notifying you where they are at. Now that you get the gist of it, I'm having a problem with the in-game menu, which allows you to choose your Buddies and Best Friend. I can add team players to my Buddy list and to my Best Friend list, but the problem is when I try to delete them, it doesn't always work. For instance, I added Jakob to my Buddies and he showed up as a buddy, but when I tried to take him off, it would work in the menu, but when I hit Accept, it's like it didn't do it. I checked back on the menu, and he was still there.

    So, can anyone find where the bug is in this? O.o I could really use some help - this mutator is really close to being finished.

    All of the menu coding follows (excluding the defaultproperties):
    Code:
    //Buddies Stay Together mutator - Menu
    //File:    BSTBuddyMenu.uc
    
    class BSTBuddyMenu extends PopupPageBase;
    
    var PlayerController LocalPlayer;
    var moCheckBox UseBestFriends2, UseBuddies2;
    var GUIListBox TeamList2, BestFriends2, BuddyList2;
    
    function InitComponent (GUIController MyGUIController, GUIComponent MyOwner)
    {
    	local BSTAction MyMut;
    	local int i;
    
    	Super.InitComponent(MyGUIController, MyOwner);
    
    	LocalPlayer = PlayerOwner();
    
    	TeamList2 = GUIListBox(Controls[5]);
    	BestFriends2 = GUIListBox(Controls[7]);
    	BuddyList2 = GUIListBox(Controls[8]);
    
    	UseBestFriends2 = moCheckBox(Controls[3]);
    	UseBuddies2 = moCheckBox(Controls[4]);
    
        BuddyList2.List.Clear();
        BestFriends2.List.Clear();
        TeamList2.List.Clear();
        BuddyList2.List.ClearPendingElements();
        BestFriends2.List.ClearPendingElements();
        TeamList2.List.ClearPendingElements();
    
    	foreach LocalPlayer.AllObjects(Class'BSTAction', MyMut)
    	{
    
    	    for( i = 0; i < MyMut.bTeamPlayers.length; i++ )
    	    {
                TeamList2.List.Add(MyMut.bTeamPlayers[i]);
    	    }
    
    	    for( i = 0; i < MyMut.bBestFriends.length; i++ )
    	    {
    	        if ( MyMut.bBestFriends[i] != "" )
    	        {
                    BestFriends2.List.Add(MyMut.bBestFriends[i]);
                }
    	    }
    
    	    for( i = 0; i < MyMut.bBuddies.length; i++ )
    	    {
    	        if ( MyMut.bBuddies[i] != "" )
    	        {
                    BuddyList2.List.Add(MyMut.bBuddies[i]);
                }
    	    }
    
    	    UseBestFriends2.Checked(MyMut.bBFriendsActivate);
    	    UseBuddies2.Checked(MyMut.bBListActivate);
    	}
    }
    
    function LoadLists()
    {
    	local BSTAction MyMut;
    	local int i;
    
        BuddyList2.List.Clear();
        BestFriends2.List.Clear();
        TeamList2.List.Clear();
        BuddyList2.List.ClearPendingElements();
        BestFriends2.List.ClearPendingElements();
        TeamList2.List.ClearPendingElements();
    
    	foreach LocalPlayer.AllObjects(Class'BSTAction', MyMut)
    	{
    	    for( i = 0; i < MyMut.bBestFriends.length; i++ )
    	    {
    	        if ( MyMut.bBestFriends[i] != "" )
    	        {
                    BestFriends2.List.Add(MyMut.bBestFriends[i]);
                }
    	    }
    
    	    for( i = 0; i < MyMut.bBuddies.length; i++ )
    	    {
    	        if ( MyMut.bBuddies[i] != "" )
    	        {
                    BuddyList2.List.Add(MyMut.bBuddies[i]);
                }
    	    }
    	}
    }
    
    function SaveLists()
    {
    	local BSTAction MyMut;
    	local int i,j;
    	local bool CheckName;
    
      	foreach LocalPlayer.AllObjects(Class'BSTAction', MyMut)
      	{
    		for( i = 0; i < BestFriends2.ItemCount(); i++ )
    		{
    		    for( j = 0; j < BestFriends2.ItemCount(); j++ )
    		    {
    		        if ( !CheckName && (i != j ) && ( BestFriends2.List.GetItemAtIndex(i) == BestFriends2.List.GetItemAtIndex(j) ) )
    		        {
                        CheckName = True;
    		        }
    		    }
    
    		    if ( !CheckName )
    		    {
    		        MyMut.bBestFriends[i] = BestFriends2.List.GetItemAtIndex(i);
                }
                else
                {
                    MyMut.bBestFriends[i] = "";
                }
          	}
    
    		for( i = 0; i < BuddyList2.ItemCount(); i++ )
    		{
    		    for( j = 0; j < BuddyList2.ItemCount(); j++ )
    		    {
    		        if ( !CheckName && (i != j ) && ( BuddyList2.List.GetItemAtIndex(i) == BuddyList2.List.GetItemAtIndex(j) ) )
    		        {
                        CheckName = True;
    		        }
    		    }
    
    		    if ( !CheckName )
    		    {
    		        MyMut.bBuddies[i] = BuddyList2.List.GetItemAtIndex(i);
                }
                else
                {
                    MyMut.bBuddies[i] = "";
                }
    		}
    
        	MyMut.doSilentSave();
    	}
    
        BuddyList2.List.Clear();
        BestFriends2.List.Clear();
        TeamList2.List.Clear();
        BuddyList2.List.ClearPendingElements();
        BestFriends2.List.ClearPendingElements();
        TeamList2.List.ClearPendingElements();
    }
    
    // Called when the OK button is clicked
    function bool InternalOnClick(GUIComponent Sender)
    {
    	local BSTAction MyMut;
    	local int i,j;
    	local bool CheckName;
    
    	CheckName = false;
    
        if ( Sender == Controls[1] )
        {
        	foreach LocalPlayer.AllObjects(Class'BSTAction', MyMut)
        	{
    			for( i = 0; i < BestFriends2.ItemCount(); i++ )
    			{
    
    			    for( j = 0; j < BestFriends2.ItemCount(); j++ )
    			    {
    			        if ( !CheckName && (i != j ) && ( BestFriends2.List.GetItemAtIndex(i) == BestFriends2.List.GetItemAtIndex(j) ) )
    			        {
                            CheckName = True;
    			        }
    			    }
    
    			    if ( !CheckName )
    			    {
    			        MyMut.bBestFriends[i] = BestFriends2.List.GetItemAtIndex(i);
                    }
                    else
                    {
                        MyMut.bBestFriends[i] = "";
                    }
    			}
    
    			for( i = 0; i < BuddyList2.ItemCount(); i++ )
    			{
    			    for( j = 0; j < BuddyList2.ItemCount(); j++ )
    			    {
    			        if ( !CheckName && (i != j ) && ( BuddyList2.List.GetItemAtIndex(i) == BuddyList2.List.GetItemAtIndex(j) ) )
    			        {
                            CheckName = True;
    			        }
    			    }
    
    			    if ( !CheckName )
    			    {
    			        MyMut.bBuddies[i] = BuddyList2.List.GetItemAtIndex(i);
                    }
                    else
                    {
                        MyMut.bBuddies[i] = "";
                    }
    			}
    
        		MyMut.bBFriendsActivate = UseBestFriends2.IsChecked();
        		MyMut.bBListActivate = UseBuddies2.IsChecked();
    		}
    
            LoadLists();
            SaveLists();
    
    		Controller.CloseMenu(false);
        }
        if ( Sender == Controls[11] )
        {
            if ( BestFriends2.ItemCount() == 0 )
            {
                 BestFriends2.List.Add(TeamList2.List.GetItemAtIndex(TeamList2.List.Index));
            }
            else
            {
                for( i = 0; i < BestFriends2.ItemCount(); i++ )
                {
                    if( !CheckName && ( BestFriends2.List.GetItemAtIndex(i) == TeamList2.List.GetItemAtIndex(TeamList2.List.Index) ) )
                    {
                        CheckName = true;
                    }
                }
    
                if ( !CheckName )
                {
                    BestFriends2.List.Add(TeamList2.List.GetItemAtIndex(TeamList2.List.Index));
                }
            }
        }
        if ( Sender == Controls[12] )
        {
            BestFriends2.List.Remove(BestFriends2.List.Index);
        }
        if ( Sender == Controls[13] )
        {
            if ( BuddyList2.ItemCount() == 0 )
            {
                BuddyList2.List.Add(TeamList2.List.GetItemAtIndex(TeamList2.List.Index));
            }
            else
            {
                for( i = 0; i < BuddyList2.ItemCount(); i++ )
                {
                    if( !CheckName && ( BuddyList2.List.GetItemAtIndex(i) == TeamList2.List.GetItemAtIndex(TeamList2.List.Index) ) )
                    {
                        CheckName = true;
                    }
                }
    
                if ( !CheckName )
                {
                    BuddyList2.List.Add(TeamList2.List.GetItemAtIndex(TeamList2.List.Index));
                }
            }
        }
        if ( Sender == Controls[14] )
        {
            BuddyList2.List.Remove(BuddyList2.List.Index);
        }
    
        return true;
    }
    And then the default properties follow, the only important properties are:
    Code:
        bAllowedAsLast=True
        bScaleToParent=true
        WinLeft=0.1
        WinTop=0.1
        WinWidth=0.8
        WinHeight=0.8
    Also, here are the controls for each object:
    Controls(0)=GUIImage'DialogBackground'
    Controls(1)=GUIButton'OkButton'
    Controls(2)=GUILabel'DialogText'
    Controls(3)=moCheckBox'UseBestFriends'
    Controls(4)=moCheckBox'UseBuddies'
    Controls(5)=GUIListBox'TeamList'
    Controls(6)=GUIImage'TeamListBG'
    Controls(7)=GUIListBox'BestFriends'
    Controls(8)=GUIListBox'BuddyList'
    Controls(9)=GUIImage'BestFriendsBG'
    Controls(10)=GUIImage'BuddyListBG'
    Controls(11)=GUIButton'ADDFriend'
    Controls(12)=GUIButton'DELFriend'
    Controls(13)=GUIButton'ADDBuddy'
    Controls(14)=GUIButton'DELBuddy'

    And now that you've read at least some of that, I know that there are redundant entries in the menu, but I don't want to take them out until I'm sure I don't need them. Also, I think the bug is somewhere between the LoadLists() and SaveLists() functions. Anyway, if you have the time, please look over it!

    Thanks a bunch!

    #2
    Okay, before I bestow on you a favor which I never do for anyone, I want to note that it is a one time only deal, and if you cant fix it from here (if anything even remains broken), then I cant help you any further, lol.

    You have some pretty major flaws in your code. The AllActors check is pretty bad (very slow, even if it is relatively infrequent), but I wont fix that for you. Its a pretty big design change, and I'm lazy. Anyway, you also have some questionable logic, as well as a lot of duplicated code and useless code. The bool CheckName is pretty needless, for example. I dont know why you dont just call LoadLists in InitComponent(), since you have the same code there. When you handle your ok button click, you have the SaveLists logic (which sends the contents of the list to the mutator), and then call LoadLists() (which loads the lists again from the mutator), and then call SaveLists() again (which resets the mutator lists), and I have no idea what that was all about, heh. Anyway, this *should* work. Its untested, obviously, and dont trust me with your code, so make sure you have yours backed up somewhere before you try mine.
    I cleaned yours up a bit, too, and used cleaner logic, it should accomplish the same effects, at least. The bug might still exist, I have no idea. There has to be a smaller list than AllActors to find the mutator, but I have no idea where (I know the mutator list exists on the server, not sure about the client).

    Code:
    //Buddies Stay Together mutator - Menu
    //File:    BSTBuddyMenu.uc
    
    class BSTBuddyMenu extends PopupPageBase;
    
    var PlayerController LocalPlayer;
    var moCheckBox UseBestFriends2, UseBuddies2;
    var GUIListBox TeamList2, BestFriends2, BuddyList2;
    
    function InitComponent (GUIController MyGUIController, GUIComponent MyOwner)
    {
    	local BSTAction MyMut;
    	local int i;
    
    	Super.InitComponent(MyGUIController, MyOwner);
    
    	LocalPlayer = PlayerOwner();
    
    	TeamList2 = GUIListBox(Controls[5]);
    	BestFriends2 = GUIListBox(Controls[7]);
    	BuddyList2 = GUIListBox(Controls[8]);
    
    	UseBestFriends2 = moCheckBox(Controls[3]);
    	UseBuddies2 = moCheckBox(Controls[4]);
    
    
    	foreach LocalPlayer.AllObjects(Class'BSTAction', MyMut)
    	{
    		LoadLists();
    
    		for( i = 0; i < MyMut.bTeamPlayers.length; i++ )
    	 		TeamList2.List.Add(MyMut.bTeamPlayers[i]);
    
    		UseBestFriends2.Checked(MyMut.bBFriendsActivate);
    		UseBuddies2.Checked(MyMut.bBListActivate);
        		break;
    	}
    }
    
    function LoadLists()
    {
    	local BSTAction MyMut;
    	local int i;
    
    	BuddyList2.List.Clear();
    	BestFriends2.List.Clear();
    	TeamList2.List.Clear();
    	BuddyList2.List.ClearPendingElements();
    	BestFriends2.List.ClearPendingElements();
    	TeamList2.List.ClearPendingElements();
    
    	foreach LocalPlayer.AllObjects(Class'BSTAction', MyMut)
    	{
    		for( i = 0; i < MyMut.bBestFriends.length; i++ )
    			if ( MyMut.bBestFriends[i] != "" )
       				BestFriends2.List.Add(MyMut.bBestFriends[i]);
    
    		for( i = 0; i < MyMut.bBuddies.length; i++ )
    			if ( MyMut.bBuddies[i] != "" )
    				BuddyList2.List.Add(MyMut.bBuddies[i]);
        		break;
    	}
    }
    
    function SaveLists()
    {
    	local BSTAction MyMut;
    	local int i,j;
    
      	foreach LocalPlayer.AllObjects(Class'BSTAction', MyMut)
      	{
    		for( i = 0; i < BestFriends2.ItemCount(); i++ )
    		    for( j = 0; j < BestFriends2.ItemCount(); j++ )
    		        if ( ( BestFriends2.List.GetItemAtIndex(i) == BestFriends2.List.GetItemAtIndex(j) ) && (i != j ) )
    		        	MyMut.bBestFriends[i] = BestFriends2.List.GetItemAtIndex(i);
               		else
                   			MyMut.bBestFriends[i] = "";
    
    		for( i = 0; i < BuddyList2.ItemCount(); i++ )
    		    for( j = 0; j < BuddyList2.ItemCount(); j++ )
    		        if ( ( BuddyList2.List.GetItemAtIndex(i) == BuddyList2.List.GetItemAtIndex(j) ) && (i != j ) )
    		        	MyMut.bBuddies[i] = BuddyList2.List.GetItemAtIndex(i);
    			else
                			MyMut.bBuddies[i] = "";
    
    		MyMut.doSilentSave();
        		break;
    	}
    
    	BuddyList2.List.Clear();
    	BestFriends2.List.Clear();
    	TeamList2.List.Clear();
    	BuddyList2.List.ClearPendingElements();
    	BestFriends2.List.ClearPendingElements();
    	TeamList2.List.ClearPendingElements();
    }
    
    // Called when the OK button is clicked
    function bool InternalOnClick(GUIComponent Sender)
    {
    	local BSTAction MyMut;
    	local int i,j;
    	local bool CheckName;
    
    	CheckName = false;
    
    	// ok
    	if ( Sender == Controls[1] )
    	{
    		foreach LocalPlayer.AllObjects(class'BSTAction', MyMut)
    		{
            		SaveLists();
        			MyMut.bBFriendsActivate = UseBestFriends2.IsChecked();
        			MyMut.bBListActivate = UseBuddies2.IsChecked();
        			break;
    		}
    		Controller.CloseMenu(false);
    	}
    	// add friend
    	else if ( Sender == Controls[11] )
    	{
    		if ( BestFriends2.ItemCount() == 0 )
    			BestFriends2.List.Add(TeamList2.List.GetItemAtIndex(TeamList2.List.Index));
    		else
    		{
    			for( i = 0; i < BestFriends2.ItemCount(); i++ )
    				if( !CheckName && ( BestFriends2.List.GetItemAtIndex(i) == TeamList2.List.GetItemAtIndex(TeamList2.List.Index) ) )
    					BestFriends2.List.Add(TeamList2.List.GetItemAtIndex(TeamList2.List.Index));
    		}
    	}
    	// delete friend
    	else if ( Sender == Controls[12] )
    		BestFriends2.List.Remove(BestFriends2.List.Index);
    	// add buddy
    	else if ( Sender == Controls[13] )
    	{
    		if ( BuddyList2.ItemCount() == 0 )
    			BuddyList2.List.Add(TeamList2.List.GetItemAtIndex(TeamList2.List.Index));
    		else
    			for( i = 0; i < BuddyList2.ItemCount(); i++ )
    				if( !CheckName && ( BuddyList2.List.GetItemAtIndex(i) == TeamList2.List.GetItemAtIndex(TeamList2.List.Index) ) )
    					BuddyList2.List.Add(TeamList2.List.GetItemAtIndex(TeamList2.List.Index));
    	}
    	// delete buddy
    	else if ( Sender == Controls[14] )
    		BuddyList2.List.Remove(BuddyList2.List.Index);
    	// any other control, return false to prevent noises and such from occouring
    	else
    		return false;
    	return true;
    }

    Comment


      #3
      And for the record, I believe the bug you are experiencing is because of your CheckName variable not being reset to false after the inner loop (which is why its best to do it my way, not to mention less code and easier to read).

      Comment


        #4
        ok

        Well first, thank you so much for revising my code. Second of all, I'm having a slight problem with it now

        Instead of just not being able to delete a buddy, now I can't add them either. It's probably my fault somewhere in the BSTAction, so I'll try and fix it myself.

        Though if I can't, I'm gonna come running

        Thx again Bones

        Comment


          #5
          Well, to be honest I didnt really think much about the code, lol. So it may very well not do what you want it to, but it definately does something...lol. Maybe I'll revise it.

          Comment


            #6


            I would really appreciate it if you did, because I didn't find anything wrong with my list interaction...

            Thx Bones

            Comment


              #7
              Okay, will revise this evening when I get off work. Just to clarify, the point of your double loops in the save/load functions are to ensure that the same name isnt added twice, correct?

              Comment


                #8
                Eh, I lied, lol.

                This should actually work, and be a lot faster (not that you would notice). I think I got all the unreferenced variables out and corrected all the names. Note that I'm accessing the GUIList directly, instead of the GUIListBox.List. I also used PlayerOwner() instead of LocalPlayer, since you dont need the player for anything else. There will be significant bugs if the mutator does not exist, so make sure that this menu is never used otherwise.

                The names are only supposed to exist in one list at a time, so when you add a player to a list, its supposed to be removed from the players list (so that you cant re-add it), and when you remove a person from a list, they are supposed to be added back into the player list. If this is not the case, debug the OnClick function.

                Code:
                //Buddies Stay Together mutator - Menu
                //File:    BSTBuddyMenu.uc
                
                class BSTBuddyMenu extends PopupPageBase;
                
                var moCheckBox UseBestFriends, UseBuddies;
                var GUIList TeamList, BestFriends, BuddyList;
                
                // store the mutator here globally
                var BSTAction MyMut;
                
                function InitComponent (GUIController MyGUIController, GUIComponent MyOwner)
                {
                	local int i;
                
                	Super.InitComponent(MyGUIController, MyOwner);
                
                	// reference the list itself, rather than the list box
                	TeamList = GUIListBox(Controls[5]).List;
                	BestFriends = GUIListBox(Controls[7]).List;
                	BuddyList = GUIListBox(Controls[8]).List;
                
                	UseBestFriends = moCheckBox(Controls[3]);
                	UseBuddies = moCheckBox(Controls[4]);
                
                	// perform the foreach once only
                	foreach PlayerOwner().AllObjects(Class'BSTAction', MyMut)
                	{
                		LoadLists();
                
                		// break after we find the mutator
                    		break;
                	}
                }
                
                function LoadLists()
                {
                	local int i;
                
                	BuddyList.Clear();
                	BestFriends.Clear();
                	TeamList.Clear();
                	BuddyList.ClearPendingElements();
                	BestFriends.ClearPendingElements();
                	TeamList.ClearPendingElements();
                
                	UseBestFriends.Checked(MyMut.bBFriendsActivate);
                	UseBuddies.Checked(MyMut.bBListActivate);
                
                	for( i = 0; i < MyMut.bBestFriends.length; ++i )
                		if ( MyMut.bBestFriends[i] != "" )
                   			BestFriends.Add(MyMut.bBestFriends[i]);
                
                	for( i = 0; i < MyMut.bBuddies.length; ++i )
                		if ( MyMut.bBuddies[i] != "" )
                			BuddyList.Add(MyMut.bBuddies[i]);
                
                	for( i = 0; i < MyMut.bTeamPlayers.length; ++i )
                		if ( MyMut.bTeamPlayers[i] != "" )
                	 		TeamList.Add(MyMut.bTeamPlayers[i]);
                }
                
                // we know here that none of the lists will contain duplicate names
                function SaveLists()
                {
                	local int i;
                
                  	for( i = 0; i < BestFriends.ItemCount(); ++i )
                		MyMut.bBestFriends[i] = BestFriends.GetItemAtIndex(i);
                
                	for( i = 0; i < BuddyList.ItemCount(); ++i )
                		MyMut.bBuddies[i] = BuddyList.GetItemAtIndex(i);
                
                	for( i = 0; i < TeamList.ItemCount(); ++i )
                		MyMut.bTeamPlayers[i] = TeamList.GetItemAtIndex(i);
                
                	
                    	MyMut.bBFriendsActivate = UseBestFriends.IsChecked();
                    	MyMut.bBListActivate = UseBuddies.IsChecked();
                	MyMut.doSilentSave();
                
                	BuddyList.Clear();
                	BestFriends.Clear();
                	TeamList.Clear();
                	BuddyList.ClearPendingElements();
                	BestFriends.ClearPendingElements();
                	TeamList.ClearPendingElements();
                }
                
                // Called when the OK button is clicked
                function bool InternalOnClick(GUIComponent Sender)
                {
                	// ok
                	if ( Sender == Controls[1] )
                	{
                		SaveLists();
                		Controller.CloseMenu(false);
                	}
                	// add friend
                	else if ( Sender == Controls[11] )
                	{
                		// add to buddy list, remove from players (to avoid adding a person twice)
                		BestFriends.Add(TeamList.GetItemAtIndex(TeamList.Index));
                		TeamList.Remove(TeamList.Index);
                	}
                	// delete friend
                	else if ( Sender == Controls[12] )
                	{
                		// add to player list, remove from friends
                		TeamList.Add(BestFriends.GetItemAtIndex(BestFriends.Index));
                		BestFriends.Remove(BestFriends.Index);
                	}
                
                	// add buddy
                	else if ( Sender == Controls[13] )
                	{
                		// add to buddy list, remove from players (to avoid adding a person twice)
                		BuddyList.Add(TeamList.GetItemAtIndex(TeamList.Index));
                		TeamList.Remove(TeamList.Index);
                	}
                	// delete buddy
                	else if ( Sender == Controls[14] )
                	{
                		// add to player list, remove from buddys
                		TeamList.Add(BuddyList.GetItemAtIndex(BuddyList.Index));
                		BuddyList.Remove(BuddyList.Index);
                	}
                	// any other control, return false to prevent noises and such from occouring
                	else
                		return false;
                	return true;
                }

                Comment


                  #9
                  ummm

                  Thanks a lot for revising my code It's much more optimized than mine. But now I'm stuck with the same problem, plus another bug has developed when trying to delete someone. For instance, one time, I kept trying to delete one person, I found out to do this, I have to delete the first person on this list, but when I do that, the second person doubles. So I have two same names on one list. Then when I try to delete those two, but removing them both, they don't go away, BUT one (or two, I don't think it matters much) of their names gets added to the team players list. So, when I did this, I had about 8 of the same names on the team list, and 2 of the same names in the Buddies list... I decided to have fun, so I added all of those 8 names to the Buddies list. It kinda worked, since the adding names thing isn't bugged up much. So then I had 10 Jakobs in the Buddies list. When I disabled the Buddies list, the 10 Jakobs stayed in the Buddy list GUIBox plus, they were also copied to the team player list. So yeah, I had 10 Jakobs in the team list. Then when I re-enabled the Buddies list, the 10 Jakobs were removed from the team list, and the Buddies list stayed the same, because it already had 10 Jakobs in the list. :bulb:

                  Anyway, you've done a lot already Bones, so only try to find the bug if you're bored

                  Comment


                    #10
                    btw

                    btw, remember that when you made this revision:
                    Code:
                    TeamList = GUIListBox(Controls[5]).List;
                    BestFriends = GUIListBox(Controls[7]).List;
                    BuddyList = GUIListBox(Controls[8]).List;
                    That means you can't use the ItemCount() function, instead you have to use the ItemCount variable I fixed that when I was compiling it, so I'm not sure if you wanted to use the function or if you just forgot about that. Anyway, just wanted to point that out.

                    Thx again for all your work!

                    Comment


                      #11
                      Actually I didnt see it, lol. Good eye, though.

                      Comment


                        #12
                        Re: ummm

                        Originally posted by Kiros72
                        Thanks a lot for revising my code It's much more optimized than mine. But now I'm stuck with the same problem, plus another bug has developed when trying to delete someone. For instance, one time, I kept trying to delete one person, I found out to do this, I have to delete the first person on this list, but when I do that, the second person doubles. So I have two same names on one list. Then when I try to delete those two, but removing them both, they don't go away, BUT one (or two, I don't think it matters much) of their names gets added to the team players list. So, when I did this, I had about 8 of the same names on the team list, and 2 of the same names in the Buddies list... I decided to have fun, so I added all of those 8 names to the Buddies list. It kinda worked, since the adding names thing isn't bugged up much. So then I had 10 Jakobs in the Buddies list. When I disabled the Buddies list, the 10 Jakobs stayed in the Buddy list GUIBox plus, they were also copied to the team player list. So yeah, I had 10 Jakobs in the team list. Then when I re-enabled the Buddies list, the 10 Jakobs were removed from the team list, and the Buddies list stayed the same, because it already had 10 Jakobs in the list. :bulb:

                        Anyway, you've done a lot already Bones, so only try to find the bug if you're bored
                        Still having that issue

                        Comment


                          #13
                          D'oh, sorry. I bet this is because I forgot about what happens in this case:

                          Assume this is your player list....

                          1
                          2
                          3
                          4
                          5
                          6
                          7

                          ...and you add player 4 to the buddy list. You get this...

                          1
                          2
                          3
                          5
                          6
                          7
                          7

                          ...and this is your buddy list...

                          4

                          Am I correct so far? What you said was a jumble of words, lol, so who knows. The point is, I expect this. Pretty simple fix though!

                          See, what is happening is we are rewriting the player list for 0-5, but forgetting about 6 (player 7). So 6 remains, lol. The same is true for the other lists.

                          All we have to do is, before we save the lists to the mutator (in SaveLists), just simply clear the arrays! I assume you are using dynamic arrays in your mutator, correct? If so, just change your SaveLists to this:

                          Code:
                          function SaveLists()
                          {
                          	local int i;
                          
                          	MyMut.bBestFriends.Remove(0,MyMut.bBestFriends.length);
                          	MyMut.bBuddies.Remove(0,MyMut.bBuddies.length);
                          	MyMut.bTeamPlayers.Remove(0,MyMut.bTeamPlayers.length);
                          
                            	for( i = 0; i < BestFriends.ItemCount(); ++i )
                          		MyMut.bBestFriends[i] = BestFriends.GetItemAtIndex(i);
                          
                          	for( i = 0; i < BuddyList.ItemCount(); ++i )
                          		MyMut.bBuddies[i] = BuddyList.GetItemAtIndex(i);
                          
                          	for( i = 0; i < TeamList.ItemCount(); ++i )
                          		MyMut.bTeamPlayers[i] = TeamList.GetItemAtIndex(i);
                          
                          	
                              	MyMut.bBFriendsActivate = UseBestFriends.IsChecked();
                              	MyMut.bBListActivate = UseBuddies.IsChecked();
                          	MyMut.doSilentSave();
                          
                          	BuddyList.Clear();
                          	BestFriends.Clear();
                          	TeamList.Clear();
                          	BuddyList.ClearPendingElements();
                          	BestFriends.ClearPendingElements();
                          	TeamList.ClearPendingElements();
                          }
                          ..And if you're not using dynamic arrays, you should, they rock.

                          Comment


                            #14


                            It works!

                            Thanks so much for fixing the bug and optimizing my code
                            And thanks a lot for helping me in the first place, since I know it's something you never do

                            Comment

                            Working...
                            X