• Log in or sign up for an account here: https://www.sythe.org/login

User's Online Script?

Covey

Creator of EliteSwitch

Retired Sectional Moderator
Visual Basic Programmers
Joined
Sep 9, 2005
Sythe Gold
9
Messages
4,510
Age
17
Location
Fuckin' BAM!
Ok for my program EliteSwitch im trying to make it have a user's online part, how would i do this?

When i start the program i need it to add 1 to the user's online, then when i close the program it will have to take 1 away from the user's online.

How can i do that?
 
I would think PHP and a Database would be the easiest. I don't think that it would be too hard to do it. I made a members login/members area script for a friend in PHP, from first looking at the language to completion of it, it took me around three hours. But I had some help from a friend...

So.. For someone who can actually program, it might only take you 20 minutes to find out what you need to know... Or you could just google.. I'm sure you could find a script that would be similar to what you need.
 
What language is the program? I might be able to help you if you're using python for the program, or php.

The language you're making your program in should have a kill function or a conditional statement on what to do if the program is exited, where you can have it invisibly load the webpage with php and do that. Same goes with opening it. And you could add a while loop to constantly refresh the frame or whatever that holds the data of the people online.

Assuming you know php, just make a php file that when the get request is ?get=add you add one to the file and read it. If it's ?get=minus then you take one out and read that.

Assuming that your language can actually do that.
 
i've got this code from smither at cruels.net
Code:
<?php
If ($_GET['act'] == 'join') {
  // Add one to a file
} else if ( $_GET['act'] == 'leave') {
  // Remove one
} else {
  // echo file
}

?>

but i don't know how to use it.

lets pretend my .php page is called 'online.php'

when i load my program do it go to www.blah.com/online.php?join

and when i exit to i go to www.blah.com/online.php?leave

and to display the number of players online to i go to www.blah.com/online.php

is that correct?

also how to i exactly add one to a file and remove one from a file and echo the file (i know echo is a msgbox, well i think)
 
Code:
<?php
$fp = fopen('peepz.txt', 'w+');
$ro = fopen('peepz.txt', 'r');
$read = fread($ro, filesize("peepz.txt"));
if(isset($_GET['join'])) {
$read = $read + 1;
fwrite($fp, $read);
}
else {
if(isset($_GET['leave'])) {
$read = $read - 1;
fwrite($fp, $read);
}
}

echo("".$read."");
?>

When a user joins, load online.php?join . When the user leaves, load online.php?leave .

If you want to read (I don't know vb) read the url http://www.whatever.poo/online.php (without ?leave or ?join)

If you get any errors (there shouldn't be any) tell me, or try fixing it yourself.

Have fun.
 
i got an error :(

Warning: fread(): Length parameter must be greater than 0. in /home/tesstott/public_html/sscovey/eliteswitch/users.php on line 4

i have the users.php file and an online.txt, they are both CHMOD to 777.

heres the users.php code:
Code:
<?php
$fp = fopen('online.txt', 'w+');
$ro = fopen('online.txt', 'r');
$read = fread($ro, filesize("online.txt"));
if(isset($_GET['join'])) {
$read = $read + 1;
fwrite($fp, $read);
}
else {
if(isset($_GET['leave'])) {
$read = $read - 1;
fwrite($fp, $read);
}
}

echo("".$read."");
?>

i tried putting 0 and 1 in the online.txt but it made no difference :(

pelase help
 
try this

<?php
$fp = fopen('online.txt', 'w+');
$ro = fopen('online.txt', 'r');
$read = fread($ro, filesize("online.txt"));
if(isset($_GET['join'])) {
$read = $read + 1;
fwrite($fp, $read);
}
else {
if(isset($_GET['leave'])) {
fwrite($fp, $read);
}
}

echo("".$read."");
?>
 
Runescape Gamblingrunescape gambling
Back
Top