TotalLogged.txt

10/08/2010 21:17 tomtucker#1
hey, my friend helped me so that when someone logs out, it will erase 1 number from totallogged.txt. so how can i make it that when i exit the console, it will make the number in totallogged.txt 0?

Here is the void but I don't know what to write in it to make it 0:
Code:
public void Disconnect()
        {
            try
            {
                if (!Robot)
                {
                    if (Soc.Connected)
                    {
                        Soc.Shutdown(SocketShutdown.Both);
                        LogOff(true);
                        Soc.Close();
                    }
                }
                else
                    LogOff(true);
            }
            catch (Exception Exc) { Program.WriteLine(Exc); }
        }
10/08/2010 21:36 pro4never#2
So Disconnect() is what you call when a client disconnects?

Simply have a variable in your server to hold how many are logged.

Whenever you receive a new connection do something like.

Program.TotalOnline++; Then write the text file (using number online, overwrite whatever is in there is easiest)

Then when calling Disconnect() do Program.TotalOnline--; and update file again.

Why use a .txt though? Personally I'd do a sql database so you can read it easier on a website.
10/08/2010 21:46 tomtucker#3
I am just trying to make the the text say "0" instead of like 10 or 12 etc when I type /exit in the console. Because right now, it's set to -1 when someone logs off, but when I type /exit, they won't have the chance to log off, so that will mess up my server status, you get what I'm saying?
10/09/2010 00:03 _tao4229_#4
Code:
[color=mediumturquoise]File[/color][color=black].WriteAllText([/color][color=darkred]"TotalLogged.txt"[/color][color=black], [/color][color=darkred]"0"[/color][color=black]);[/color]
10/09/2010 00:39 tomtucker#5
fixed it thanks
10/09/2010 00:46 .Kob#6
Quote:
Originally Posted by tomtucker View Post
It ain't working. This is what I put:

Code:
public void Disconnect()
        {
            try
            {
                File.WriteAllText("C:\\AppServ\\www\\TotalLogged.txt", "0");
                if (!Robot)
                {
                    if (Soc.Connected)
                    {
                        Soc.Shutdown(SocketShutdown.Both);
                        LogOff(true);
                        Soc.Close();
                    }
                }
                else
                    LogOff(true);
            }
            catch (Exception Exc) { Program.WriteLine(Exc); }
        }
That's not the /exit command.
10/09/2010 01:11 Arcо#7
Decker, when are you going to learn to read code, and actually LEARN what the hell you're doing? You come to us with EVERY problem you have, and frankly a lot of us are tired of it. You're spoonfed beyond belief, you're like a 5 year old that's still on breastmilk, you don't learn to adapt. Read some tutorials, learn exactly what the hell you're doing, so you won't have to come to us all the time.
10/09/2010 01:13 tomtucker#8
Quote:
Originally Posted by Аrco View Post
Decker, when are you going to learn to read code, and actually LEARN what the hell you're doing? You come to us with EVERY problem you have, and frankly a lot of us are tired of it. You're spoonfed beyond belief, you're like a 5 year old that's still on breastmilk, you don't learn to adapt. Read some tutorials, learn exactly what the hell you're doing, so you won't have to come to us all the time.
You don't know who is tired of it, so stop putting words in other peoples mouths.
10/09/2010 06:52 pro4never#9
#tiredofit

You could have learned to be at LEAST a decent coder by now if you actually put a tiny bit of effort into it.
10/09/2010 06:55 Arcо#10
Quote:
Originally Posted by pro4never View Post
#tiredofit

You could have learned to be at LEAST a decent coder by now if you actually put a tiny bit of effort into it.
This was said many times. He just refuses to listen, and leeches off everyone else. Which I think is why his server is down atm :rolleyes:
10/09/2010 14:43 Basser#11
Quote:
Originally Posted by pro4never View Post
#tiredofit

You could have learned to be at LEAST a decent coder by now if you actually put a tiny bit of effort into it.
If thats the case, why are there so few decent coders on this forum?
There's some people who get along with the .NET framework, but thats about it for most of the 'coders' on this forum.
10/09/2010 14:49 _DreadNought_#12
Quote:
Originally Posted by Аrco View Post
This was said many times. He just refuses to listen, and leeches off everyone else. Which I think is why his server is down atm :rolleyes:
hehe.