Step 1. Use this in your SQL to create a new column on chars.
Code:
ALTER TABLE [PS_GameData].[dbo].[Chars]
ADD LoginStatus TINYINT DEFAULT '0' NOT NULL
Step 2. Next, go to PS_GameData Stored Procedures >
In usp_Read_Chars_Detail2_R, change:
Code:
UPDATE Chars SET JoinDate=GETDATE(), LoginStatus = 1 WHERE CharID=@CharID
Step 2.5.
usp_Save_Char_LeaveDate_R, change:
Code:
UPDATE Chars SET LeaveDate=GETDATE(), LoginStatus = 0 WHERE CharID=@CharID
Now you just want to run one of the following, or both queries depending on what you want, the first will show how many are on and the second will show who.
Total Players:
Code:
SELECT COUNT(LoginStatus) AS PlayersOnline
FROM [PS_GameData].[dbo].[Chars]
WHERE LoginStatus = 1 -- Filters online people only.
See who's online (+ more in-depth info, all you need to do is add the columns)
Code:
SELECT
UserID,CharName,Level,Map,K1 AS Kills,K2 AS Deaths
FROM [PS_GameData].[dbo].[Chars]
WHERE LoginStatus='1' -- Filters online people only.
ORDER BY
Map -- Choose a column to sort by, i.e. Map.
DESC -- ASC (ascending) or DESC (descending)
Here's the PhP script for it.
Code:
<?php
$sql_server = "127.0.0.1";
$sql_user = "sa";
$sql_pass = "123456";
$sql_data = "PS_GameData";
$conn=mssql_connect($sql_server,$sql_user,$sql_pass);
$xadb = mssql_select_db($sql_data,$conn) or die("$uwebmsg_cerr");
$toplvlq = "SELECT * FROM CHARS WHERE (LoginStatus = 1) ORDER BY Level DESC";
$toplvlr = mssql_query($toplvlq);
$toplvl_num = 0;
echo "<p><b>TOP PLAYERS<b></p><p>";
echo "<Table width=100% border=1><TR><TD><B>RANK NUMBER</B></td><TD><B>PLAYER NAME</B></td><TD><B>PLAYER LEVEL</B></td></tr>";
while ($toplvlrow = mssql_fetch_array($toplvlr))
{
$toplvl_num++;
echo "<TR><TD>$toplvl_num</td><TD>".$toplvlrow[CharName]."</td><TD>".$toplvlrow[Level]."</td>";
if ($toplvl_num >= 100) break;
}
echo "</table></p>";
?>
I can't say if the PhP works as it's not mine, but the SQL does. Hope this helps
credits to Mazdik & ihatehaxor