Username:    Password:        Click Here To Signup     Forgotten Password
Main Menu
Online
Members: 0

Guests: 39

144.76.x.x user
158.69.x.x news
216.244.x.x dilbertplus
46.229.x.x forum
46.229.x.x forum
46.229.x.x dilbertplus
46.229.x.x user
46.229.x.x forum
46.229.x.x forum
46.229.x.x forum
46.229.x.x forum
46.229.x.x forum
46.229.x.x forum
46.229.x.x dilbertplus
46.229.x.x forum
46.229.x.x forum
46.229.x.x forum
46.229.x.x forum
46.229.x.x forum
54.158.x.x forum
54.36.x.x forum
54.36.x.x dilbertplus
54.36.x.x forum
54.36.x.x forum
54.36.x.x dilbertplus
54.36.x.x dilbertplus
54.36.x.x forum
54.36.x.x dilbertplus
54.36.x.x forum
54.36.x.x forum
54.36.x.x lgsl
54.36.x.x dilbertplus
54.36.x.x dilbertplus
54.36.x.x dilbertplus
54.36.x.x forum
54.36.x.x forum
59.58.x.x news
66.249.x.x forum
95.181.x.x forum

Last Seen

Wussie Wed 01:56
suzain lian Fri 07:52
85filip58 Wed 12:37
mmotony Sat 04:27
Dodgeitorelse Fri 12:48

Newest Members

Forums
Richard Perry - GreyCube.com :: Forums :: Live Game Server List
Go to page       >>     
My Score Tracker / Top Players List using LGSL v1.03 - 2011/07/23
Fenix
Tue Jun 28 2011, 08:45AM
Posts: 14
Joined: Sun Jun 26 2011, 06:07PM
Registered Member #6793
Hello all!

I have made a score tracker which uses LGSL engine, and wanted to share it with all of you.
So far I have tested it only with America's Army 2 servers, but as it uses LGSL engine it should work for other supported games with little or no modification.
Only limitation is that for it to work, you have to have LGSL configured to use database, feed won't work.


Picture 1: Score tracker showing both online and top players for each server



Download

Version 1.03 (2011-07-23) NEW
- bold names for online players in lgsl_details_top50.php score list
- Kikoff's fix for SQL Insert/Update problems with some servers
- few other minor improvements/fixes
- added additional support for: Counter Strike and Counter Strike Source (used as Half-Life Steam in LGSL engine)
Download version 1.03 - 49kB
Download version 1.03 + documentation - 413kB

Version 1.02 (2011-06-30)
- added additional support for: ArmA Armed Assault, America's Army 3, Call Of Duty 4, Battlefield Bad Company 2, IL-2 Sturmovik, Quake 2, Quake 3, Quake 4, GTA San Andreas Multiplayer
Download version 1.02 - 49kB
Download version 1.02 + documentation - 411kB

Version 1.01 (2011-06-29)
- reports error if it's not properly installed relative to LGSL directory (or if you don't set PATH_TO_LGSL).
Download version 1.01 - 48kB
Download version 1.01 + documentation - 411kB

Version 1.0 (2011-06-28) - first public release
Download version 1.0 - 48kB
Download version 1.0 + documentation - 411kB



Step 1: Installation

Just copy all the files from archive to your server's lgsl directory (where you have your admin.php from LGSL installation).
You should then have this new files:

* f-common.php
* f-scoretracker.php
* tracker-engine.php
* server-refresh.bat - this file is needed only if you're going to refresh scores from command line - more on that later in Step 3
* ServerTracker.html - this and next file are optional, score tracker can work without them
* jquery-1.6.1.min.js - this is JavaScript jQuery library, and is required only for ServerTracker.html
* lgsl_details_top50.php is an example how to integrate top players list with your custom server details page - if you want to use it, you'll have to put it in lgsl_files folder.

If you want to install it to some other directory relative to your LGSL installation, then you'll have to edit this line on start of file f-common.php, and change the value of PATH_TO_LGSL so it points to your LGSL installation directory:
define( PATH_TO_LGSL, "lgsl_files" );




Step 2: Configuration

In your browser go to file tracker-engine.php (e.g. URL on my server is http://localhost/lgsl/tracker-engine.php, it depends where you copied files on installation). You will get interface similar to one in Picture 2, which will show all of your LGSL servers.
Note how it under 'Players in DB' column shows No table for each server - that is because you need to manually create all the database tables which hold scores for each server.
You can do that by entering your LGSL username and password and pressing 'Initialize all data'; or alternatively you can do it individualy for each server by pressing 'Initialize'.

NOTE: If you add new servers to LGSL, you'll need to manually initialize databases for them. In that case, always use individual 'Initialize' button for each server, as using global 'Initialize all data' would destroy all the scores from other servers too.


Picture 2: Tracking Engine main page



Step 3: Running score tracker

This is VERY IMPORTANT step for tracker to properly update scores - as it has to be called every 2 minutes to query all the servers and write new scores to database.
This can be accomplished in two ways: from your web browser, or with small program - server-refresh.bat.

  • From web browser

In your browser go to page tracker-engine.php, enter your LGSL username and password in input boxes, and press button 'Refresh scores'.
As long as you have that page open in your browser, it will automatically refresh scores every 2 minutes, you just have to make sure that it always stays open.
Advantage of this method that it can be done remotely from any computer which has access to server - you just have to know LGSL username and password.

Picture 3a: Refreshing scores from web browser


  • With server-refresh.bat (Windows only)

First you'll have to edit file server-refresh.bat and change the following line:
c:\pj\sdk\xampp\php\php.exe -c c:\pj\sdk\xampp\php\php.ini tracker-engine.php

You'll have to change paths to both your php.exe and to your php.ini files.
After you have done that and saved your changes, you can just start server-refresh.bat from Windows Explorer, as you would normally start any other program.
As long as you have that program running, it will automatically refresh the scores in database.
Advantage of this method is that you don't need to have web browser open, but disadvantage is that program can be run only directly on server.
TIP: If you want this program to start automatically with Windows, then you'll need to add shortcut to it to Windows Startup folder.

Picture 3b: Refreshing scores with server-refresh.bat



Step 4: Check if tracker is working

In your browser go to page ServerTracker.html (e.g. URL on my server is http://localhost/lgsl/ServerTracker.html), and you should get something as on Picture 1 with all of your servers.
You can now log in game and play on some server, when you log out it should have all your scores, and scores of all other people who played on those servers.
Note that top scores are refreshed only after round finishes, or if player disconnects/reconnects.



Sample HMTL/JavaScript tracker (ServerTracker.html)

This is my tracker page, which I made because I wanted to be able to customize looks and information which is displayed, and also because I wanted to be able to sort servers by number of players online.
It works by requesting information (via AJAX) about servers and players every 2 minutes, and then generating HTML page from that data. Advantage of this method that all changes to page (such as sorting, displaying additional player info, etc.) are done locally on user's computer, without asking the server again for the data - so it works very fast and it also saves on network traffic.
One nice trick is that is automatically sorts servers by number of online players, even though you can change that if you want.


Picture 4: ServerTracker.html in web browser

By clicking on 'Sort by players' or 'Sort by country' you can enable/disable sorting of servers.
When you click on 'Options' you get the following screen:

Picture 5: Options for ServerTracker.html

With it you can experiment with many different looks and feels. All the changes to looks and sort order are saved locally in a browser cookie, so they stay whenever you visit the page.


Picture 6a: Horizontal mode with additional player info


Picture 6b: Vertical mode with additional player info


Picture 6c: 'Compressed' look - only top 5 players, no additional player info, no map image, horizontal mode


Advanced customization of ServerTracker.html looks

Since most of the looks are defined in CSS on start of HTML file, you can change them and create your own version with different colors, texture backgrounds and so on.
You can also try modifying JavaScript code to change the looks even more.



Modifying lgsl_details.php to show top 50 players

This example should guide you how to integrate score tracker with your own server info page, if you wish so.
First you should make a backup copy of original lgsl_details.php to have it as reference.
Now, open lgsl_details.php in your favorite editor, and below line:
require "lgsl_class.php";

add these two lines:
include_once("f-common.php");
include_once("f-scoretracker.php");


Then after the block SHOW THE PLAYERS finishes (line 152 in original lgsl_details.php), add this code:
// SHOW TOP 50 PLAYERS LIST
$output .="
<div style='".lgsl_bg(TRUE)."; width:90%; margin:auto; text-align:center; height:6px; border:1px solid'><br /></div>
<div style='height:10px'><br /></div>

<div style='margin:auto; overflow:auto; text-align:center; padding:10px'>
TOP 50 PLAYERS<p>
<table cellpadding='4' cellspacing='2' style='margin:auto'>";

$scores = GetScores( $lgsl_server_id, 0, 50 ); // Get top players from 0-50
$c = 1;
foreach( $scores as $name => $player ) {
// Make online player names bold
$playerOnline = false;
foreach( $server['p'] as $onlinePlayer ) { // Is player online?
if( $onlinePlayer['name'] == $name ) { $playerOnline = true; break; }
}
if( $playerOnline ) $name = $name." <b>[Online]</b>";

$output .= "<trstyle='".lgsl_bg()."'><td align=left>".$c.". ".$name."</td><td>".$player['score']."</td><td>"
.$player['goal']."</td><td>".$player['leader']."</td><td>"
.$player['enemy']."</td><td>".$player['kia']."</td><td>".$player['roe']."</td></tr>\n";
$c++;
}
$output .= "</table>
</div>";

That's it! Now your server details page should look something like this (if you haven't changed any CSS styles from original LGSL installation):

Picture 7: Added top 50 players to server details page

If you have trouble, you can find already modified file as lgsl_details_top50.php in installation archive.

Most important part of code was call to function GetScores() which gets top players for specific server, and then foreach loop which displays them all.



Advanced: function reference

GetScores( $sid, $from=0, $count=50 );
Gets top players and their scores
- $sid - server ID in database (same as $lgsl_server_id in LGSL)
- $from - from which player to start, 0 is first player (player with biggest score)
- $count - how many players to return

RefreshScores();
Compares current results from online players to results it had from before, and from it concludes when the round has finished and if some player has disconnected/reconnected, and increases top scores in database accordingly.

GetDataFromLGSL( $type="spe" );
This function is basically just wrapper for call to lgsl_query_group() function, which returns data in custom format.

InitializeServer( $sid, $ip="", $name="", &$totalplayers=0 );
Initializes database table for tracking scores for single server
- $sid - Server ID in database (same as $lgsl_server_id in LGSL)
- $ip, $name, $totalplayers are just used for show and you don't need to fill them

InitializeAllTheScores();
Initializes database tables for all servers.
WARNING: using this function will destroy all old scores you had tracked on server. You should use it only for the first time you install this score tracker.



Thanks
to Dodgeitorelse for initial idea to create a tracker and for his support
to Richard Perry for LGSL engine
to jQuery JavaScript library
to Jeremy Saintot for his PHP http_request function.
Dodgeitorelse
Tue Jun 28 2011, 08:53AM
Posts: 246
Joined: Sun Dec 12 2010, 09:16AM
Registered Member #6457
A very nice job Fenix, well done Hooah!!


lack of effort on your part requires less effort on my part
Website
Fenix
Tue Jun 28 2011, 04:32PM
Posts: 14
Joined: Sun Jun 26 2011, 06:07PM
Registered Member #6793
Dodgeitorelse wrote ...

A very nice job Fenix, well done Hooah!!


Thanks Dodge
KIKOFF
Tue Jun 28 2011, 05:39PM

Posts: 132
Joined: Thu Nov 18 2010, 08:18AM
Registered Member #6411
Yes, yes... amazing. Thank you very much for sharing and good documentation, now try it with the Battlefield series. Thank again

Saludos, KIKOFF

EDIT: Hi Fenix, I downloaded the files 3 times and both appear to be damaged, you can check?

Lo cortez, no quita lo valiente... ahhh... yes e107 Rock
Dodgeitorelse
Tue Jun 28 2011, 07:14PM
Posts: 246
Joined: Sun Dec 12 2010, 09:16AM
Registered Member #6457
this line in original post

Only limitation is that for it to work, you have to have LGSL configured to use database, feed won't work.


should read

Only limitation is that for it to work, you have to have LGSL configured to use YOUR OWN database, feed won't work.

to view a working copy go to http://dodgeitorelse.dyndns.org/gsreaders/AA%20Server%20Tracker.html

lack of effort on your part requires less effort on my part
Website
Fenix
Tue Jun 28 2011, 09:10PM
Posts: 14
Joined: Sun Jun 26 2011, 06:07PM
Registered Member #6793
@Dodge: fixed the sentence about using your own database. Also, thanks for giving link to your server so people can check how it works

@KIKOFF: I re-uploaded files again, tried them both and they work... Really don't understand what happened with older links, they worked when I wrote original message. Hope it will work for you now.
Xsfd (M.D.A)
Wed Jun 29 2011, 07:20AM

Posts: 90
Joined: Wed Aug 18 2010, 10:42AM
Registered Member #6225
Notice: Undefined variable: lgsl_config in T:\home\localhost\forum\lgsl_files\tracker-engine.php on line 19
Wrong username/password

Why error? username and password is true!

Website
Dodgeitorelse
Wed Jun 29 2011, 07:37AM
Posts: 246
Joined: Sun Dec 12 2010, 09:16AM
Registered Member #6457
I believe it must be the same username and password you use in lgsl_config.php and you must have your own database.

Please correct me if I am wrong Fenix.

lack of effort on your part requires less effort on my part
Website
KIKOFF
Wed Jun 29 2011, 07:45AM

Posts: 132
Joined: Thu Nov 18 2010, 08:18AM
Registered Member #6411
Hello Fenix​​, now if the links work. Thank.

The SA version works perfect!, but the e107 CMS I have problems with the path to lgsl_class.php and the username and password as Xsfd.
I suppose you've designed for the SA, but it would be incredible to work for different CMS.

Anyway great work and big contribution, thanks again.

Saludos, KIKOFF

Lo cortez, no quita lo valiente... ahhh... yes e107 Rock
Fenix
Wed Jun 29 2011, 08:29AM
Posts: 14
Joined: Sun Jun 26 2011, 06:07PM
Registered Member #6793
Xsfd (M.D.A) wrote ...

Notice: Undefined variable: lgsl_config in T:\home\localhost\forum\lgsl_files\tracker-engine.php on line 19
Wrong username/password

Why error? username and password is true!


I think that problem with username/password is because my script can't locate lgsl_config.php because it's not in proper directory

Try either moving all my tracker files to T:\home\localhost\forum (one directory up from where is now); or you can try editing this line on start of f-common.php:
define( PATH_TO_LGSL, "lgsl_files" );

and change it to:
define( PATH_TO_LGSL, "." );



@KIKOFF: Is it possible that you also have it in wrong directory? Script gets username and password for database from lgsl_config.php, if it can't find it then of course it will report that user/pass are wrong... As I use database directly with mysql functions, it shouldn't be difference whatever CMS you are using, as long as mysql is configured inside PHP.
KIKOFF
Wed Jun 29 2011, 08:57AM

Posts: 132
Joined: Thu Nov 18 2010, 08:18AM
Registered Member #6411
wrote ...

@KIKOFF: Is it possible that you also have it in wrong directory? Script gets username and password for database from lgsl_config.php, if it can't find it then of course it will report that user/pass are wrong... As I use database directly with mysql functions, it shouldn't be difference whatever CMS you are using, as long as mysql is configured inside PHP.

Ok this is good news. Thanks for a prompt response.

Need a slash at the beginning. I refer in this case to e107:

define( "PATH_TO_LGSL", "/lgsl_files" );


Although I still have problems with the username and password, I keep trying, will report later.

Saludos, KIKOFF

EDIT: OKIS ALL DONE! will need the username and password in lgsl_config, although not required LGSL as it takes the data from the database of the CMS.

Thanks again

Lo cortez, no quita lo valiente... ahhh... yes e107 Rock
Xsfd (M.D.A)
Wed Jun 29 2011, 10:12AM

Posts: 90
Joined: Wed Aug 18 2010, 10:42AM
Registered Member #6225
don't work.

LGSL and tracker in directory T:\home\localhost\forum\lgsl_files\

with:

define( PATH_TO_LGSL, "http://localhost/forum/lgsl_files/" );

>>>>>ERROR>>>>> "Wrong username/password"


with:

define( PATH_TO_LGSL, "lgsl_files" );

>>>>>ERROR>>>>>

"Warning: include_once(lgsl_fileslgsl_config.php) [function.include-once]: failed to open stream: No such file or directory in T:\home\localhost\forum\lgsl_files\tracker-engine.php on line 18

Warning: include_once() [function.include]: Failed opening 'lgsl_fileslgsl_config.php' for inclusion (include_path='.;/usr/local/PHP/PEAR;/usr/local/PHP/PEAR/smarty') in T:\home\localhost\forum\lgsl_files\tracker-engine.php on line 18

Notice: Undefined variable: lgsl_config in T:\home\localhost\forum\lgsl_files\tracker-engine.php on line 19
Wrong username/password"

Website
Fenix
Wed Jun 29 2011, 11:14AM
Posts: 14
Joined: Sun Jun 26 2011, 06:07PM
Registered Member #6793
Have you tried just:

define( PATH_TO_LGSL, "." );

with a dot for path, as I wrote in my last message?

Otherwise, by default installation it is assumed that folder lgsl_files is subdirectory of my tracker's installation directory; and by T:\home\localhost\forum\lgsl_files\tracker-engine.php from your report I can see that you have instead copied it directly to lgsl_files folder. That's why i think just "." (a single dot) will work for your PATH_TO_LGSL.

BTW. PATH_TO_LGSL is never an URL, it is either windows or linux path to file - that means that path can't start with http:// or anything similar.



Xsfd (M.D.A) wrote ...

don't work.

LGSL and tracker in directory T:\home\localhost\forum\lgsl_files\

with:

define( PATH_TO_LGSL, "http://localhost/forum/lgsl_files/" );

>>>>>ERROR>>>>> "Wrong username/password"


with:

define( PATH_TO_LGSL, "lgsl_files" );

>>>>>ERROR>>>>>

"Warning: include_once(lgsl_fileslgsl_config.php) [function.include-once]: failed to open stream: No such file or directory in T:\home\localhost\forum\lgsl_files\tracker-engine.php on line 18

Warning: include_once() [function.include]: Failed opening 'lgsl_fileslgsl_config.php' for inclusion (include_path='.;/usr/local/PHP/PEAR;/usr/local/PHP/PEAR/smarty') in T:\home\localhost\forum\lgsl_files\tracker-engine.php on line 18

Notice: Undefined variable: lgsl_config in T:\home\localhost\forum\lgsl_files\tracker-engine.php on line 19
Wrong username/password"

Fenix
Wed Jun 29 2011, 12:09PM
Posts: 14
Joined: Sun Jun 26 2011, 06:07PM
Registered Member #6793
Posted a new version (v1.01) which reports error if files are not installed in proper directory relative to LGSL, or if you didn't set up PATH_TO_LGSL.
Xsfd (M.D.A)
Wed Jun 29 2011, 01:02PM

Posts: 90
Joined: Wed Aug 18 2010, 10:42AM
Registered Member #6225
Fatal error: Call to undefined function lgsl_query_group() in T:\home\localhost\forum\lgsl_files\f-common.php on line 127

Website
Fenix
Wed Jun 29 2011, 01:11PM
Posts: 14
Joined: Sun Jun 26 2011, 06:07PM
Registered Member #6793
Xsfd (M.D.A) wrote ...

Fatal error: Call to undefined function lgsl_query_group() in T:\home\localhost\forum\lgsl_files\f-common.php on line 127


You still probably don't have the tracker in proper directory and/or haven't set up PATH_TO_LGSL, have you tried version 1.01? With it you don't get strange errors as such if it's just problem with directory.
Xsfd (M.D.A)
Wed Jun 29 2011, 01:19PM

Posts: 90
Joined: Wed Aug 18 2010, 10:42AM
Registered Member #6225
It is version 1.01 and define( PATH_TO_LGSL, "." );

Website
Fenix
Wed Jun 29 2011, 01:42PM
Posts: 14
Joined: Sun Jun 26 2011, 06:07PM
Registered Member #6793
Xsfd (M.D.A) wrote ...

It is version 1.01 and define( PATH_TO_LGSL, "." );


Hm then this is quite strange error you get (Call to undefined function lgsl_query_group()) - it means it can't find standard lgsl function.
Could you check and confirm that f-common.php and lgsl_class.php are in the same directory? Do you get any other warnings/errors?
And just of curiosity, do you use Linux or Windows?
Dodgeitorelse
Wed Jun 29 2011, 02:24PM
Posts: 246
Joined: Sun Dec 12 2010, 09:16AM
Registered Member #6457
oh how I love the stand alone version of lgsl hahaha

lack of effort on your part requires less effort on my part
Website
Xsfd (M.D.A)
Wed Jun 29 2011, 03:33PM

Posts: 90
Joined: Wed Aug 18 2010, 10:42AM
Registered Member #6225
Fenix. Windows 7. On the server on the Internet is Linux and the problem is the same

Look at the video: http://www.youtube.com/watch?v=_l7yWniK_9M

Website
Go to page       >>   

Jump:     Back to top


You are not logged in - Click Here To Signup

Username:    Password:   

Mini Buttons

.... © GreyCube.com - Richard Perry - Powered by e107.org