- Home /
Trouble resetting for loop
Hello everyone,
I am attempting to display all my servers in the string array 'servers' with this for loop.
string[] servers = serverlist.Split(',');
if(connecting)//Connect Window
{
for(int i = 0; i < servers.Length-1; i++)
{
GUI.Box (new Rect(10, i * 30, 130, 50), servers[i], skin.GetStyle("size17 Text"))
if(GUI.Button (new Rect(460, i * 30, 130, 50), "Add", skin.GetStyle("Button 2.0")))
{
print (i);
}
}
}
My problem is if I have 2 servers running, When I open the connect window (connecting) I have the 2 servers as desired. 'Server 1 - Server 2'
However if I close and reopen the connect window It duplicates those servers so I end up with. 'Server 1 - Server 2 - Server 1 - Server 2'
As a newbie to c# I was hoping someone could give me some assistance, I'm thinking I just need to break the loop somewhere but cant think where...
Any assistance would be very appreciated! Thank you very much!
we can't really help without knowing: 1) what is the value of serverList? 2) what is servers.Length?
Chances are once you figure out the answers to those question you will know what the problem is.
Thank you for the reply, serverList is a single string that is filled by a php script containing every server in the database, servers.length-1 is the amount of strings in the string array.
Thank you again for your assistance hopefully we both can figure out a solution....
Answer by Stand Alone OS · Dec 31, 2014 at 11:17 PM
I managed to find a fix by clearing serverList everytime I close connecting window... Took alot long then it should have...
Thanks everyone
Your answer
