Raised This Month: $51 Target: $400
 12% 

GunGame SQL


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kafidu
Member
Join Date: Aug 2005
Old 05-03-2007 , 17:21   GunGame SQL
Reply With Quote #1

hi all, anybody post a link with a full install and user guide for the gungame sql to have live gg stats? or anybody know a way to have gg live stats?
kafidu is offline
Krim // Relgam.com
Junior Member
Join Date: Jul 2005
Location: Las Cruces, NM
Old 05-06-2007 , 18:31   Re: GunGame SQL
Reply With Quote #2

I made a PHP script to grab the gungame.stats file because it looks like the SQL plugin isn't working for me.

PHP Code:
 <?php
echo "Updating GG Top 10 Statistics...<br>";


 
$amx_sql_host    "xxxxxxxxxxx";
 
$amx_sql_user    "xxxxxxxxxxx";
 
$amx_sql_pass    "xxxxxxxxxxx";
 
$amx_sql_db    "xxxxxxxxxxx";
 
      
$db mysql_connect($amx_sql_host,$amx_sql_user,$amx_sql_pass);
     
mysql_select_db($amx_sql_db,$db);
 

$ch curl_init();
$timeout 5// set to zero for no timeout
curl_setopt ($chCURLOPT_URL'http://xxxxx/xxx/gungame.stats');


curl_setopt ($chCURLOPT_RETURNTRANSFER1);
curl_setopt ($chCURLOPT_CONNECTTIMEOUT$timeout);
$file_contents curl_exec($ch);
curl_close($ch);
$lines = array();
$lines explode("\n"$file_contents);

// display file line by line
$details = array();

foreach(
$lines as $line_num => $line) {
    
    
$details explode"\t"$line );
    
// 0 - authid
    // 1 - wins
    // 2 - lastname
    // 3 - timestamp
    // 4 - points
        
     
$details[2] = htmlspecialchars($details[2]);
     
     
$query "SELECT * FROM gg_stats WHERE authid='$details[0]'";
     
$result mysql_query$query$db );
     
$rows mysql_num_rows($result);
     
$myrow mysql_fetch_array$result );
     
     if( 
$rows &&  strlen$details[0] ) > ){
     
// There is already a record for this user, we need to update this record
     
     // Find out what is different
     
if( strcmp($myrow["wins"], $details[1]) != ){
         
printf("Wins Differ, new wins: <b>%s</b> | old wins: %s<br>"$details[1], $myrow["wins"] );
        
$query "UPDATE gg_stats SET wins='$details[1]' WHERE authid='$details[0]'";
        
mysql_query$query );        
        
    }if( 
strcmp($myrow["lastname"], $details[2]) != ){
         
printf("Lastname Differs, new name: %s<br>"$details[2] );
        
$query "UPDATE gg_stats SET lastname='$details[2]' WHERE authid='$details[0]'";
        
mysql_query$query );
        
    }if( 
strcmp($myrow["timestamp"], $details[3]) != ){
         
printf("Timestamp Differs, new timestamp: %s<br>"$details[3] );
        
$query "UPDATE gg_stats SET timestamp='$details[3]' WHERE authid='$details[0]'";
        
mysql_query$query );
    }
     
     
     }elseif( 
strlen$details[0] ) > ){
         
// New user, we need to add them
         
$query "INSERT INTO gg_stats ( authid, wins, lastname, timestamp, points  )
                        VALUES ( '
$details[0]', '$details[1]', '$details[2]', '$details[3]', '$details[4]' )";
          
mysql_query$query );
          
          
printf("New user <b>%s</b><br>"$details[0] );
     }
     
     
    
}


echo 
"<br>Done.";

?>
__________________
--= Smooth Kriminal // Krim =-
RelentlessGaming
Relgam.com

Last edited by Krim // Relgam.com; 05-06-2007 at 18:47.
Krim // Relgam.com is offline
Vordrix
Member
Join Date: Jun 2006
Location: Ireland
Old 05-07-2007 , 14:12   Re: GunGame SQL
Reply With Quote #3

Now, how do we install it?
__________________
- l)l)` Vordrix (l)l)` Clan Leader).


http://www.ddcz.org
Vordrix is offline
Send a message via AIM to Vordrix
Krim // Relgam.com
Junior Member
Join Date: Jul 2005
Location: Las Cruces, NM
Old 05-07-2007 , 14:21   Re: GunGame SQL
Reply With Quote #4

Quote:
Originally Posted by Vordrix View Post
Now, how do we install it?
Good question. Basically, anywhere you have a web server that can run PHP/MySQL (doesn't need to be the same as your game server).

Requirements:
1. A CS1.6 game server + web server (on the same machine) - to be able to share (via http) your gungame.stats file
2. Either another webserver or the same as in (1) that can run PHP/MySQL

Workarounds:
If you don't have a game + webserver, you could setup a cron/scheduled task to copy your gungame.stats file to your webserver (via SCP/SFTP/FTP, etc) If you're interested in this, and you can give me your working environment (Linux/Unix, Windows), I can probably help you out.

You just need to fill out the details for your MySQL database
$amx_sql_host = "xxxxxxxxxxx";
$amx_sql_user = "xxxxxxxxxxx";
$amx_sql_pass = "xxxxxxxxxxx";
$amx_sql_db = "xxxxxxxxxxx";


In my case, I choose to use the same database as my AMXX admins (but a different table called gg_stats)
Code:
-- 
-- Table structure for table `gg_stats`
-- 

DROP TABLE IF EXISTS `gg_stats`;
CREATE TABLE IF NOT EXISTS `gg_stats` (
  `authid` varchar(24) NOT NULL,
  `wins` int(6) NOT NULL,
  `lastname` varchar(32) NOT NULL,
  `timestamp` int(12) NOT NULL,
  `points` int(8) NOT NULL,
  PRIMARY KEY  (`authid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

The only catch is that your game server needs to have some sort of connection to the web, I have a Windows 2003 game server with IIS6 so this was easy for me to do. After you setup your webserver on your game server you can fill out these details in the PHP script:
curl_setopt ($ch, CURLOPT_URL, 'http://xxxxx/xxx/gungame.stats');

__________________
--= Smooth Kriminal // Krim =-
RelentlessGaming
Relgam.com
Krim // Relgam.com is offline
Vordrix
Member
Join Date: Jun 2006
Location: Ireland
Old 05-07-2007 , 14:39   Re: GunGame SQL
Reply With Quote #5

Alright, wow, thats alot to take in, now with the $amx_sql_host = "xxxxxxxxxxx"; would I change that to my websites URL like this:

$amx_sql_host = "http://www.ddcz.bloodservers.com";

And also, would you be willing to do an installation for me?
__________________
- l)l)` Vordrix (l)l)` Clan Leader).


http://www.ddcz.org
Vordrix is offline
Send a message via AIM to Vordrix
Krim // Relgam.com
Junior Member
Join Date: Jul 2005
Location: Las Cruces, NM
Old 05-07-2007 , 14:54   Re: GunGame SQL
Reply With Quote #6

Quote:
Originally Posted by Vordrix View Post
Alright, wow, thats alot to take in, now with the $amx_sql_host = "xxxxxxxxxxx"; would I change that to my websites URL like this:

$amx_sql_host = "http://www.ddcz.bloodservers.com";

And also, would you be willing to do an installation for me?
My work hours are pretty crazy (6pm - 4am starting today). So if my directions don't work out...maybe we could do it on a weekend?

Alright, $amx_sql_host refers to your MySQL hostname (or IP address). Do you have a MySQL server to use?

If you only use BloodServers, look around to see if 1) you get webspace, 2) if you get PHP and MySQL on your webspace. If (1) and (2) are both "yes" then we're in business. Let me know.
__________________
--= Smooth Kriminal // Krim =-
RelentlessGaming
Relgam.com
Krim // Relgam.com is offline
Vordrix
Member
Join Date: Jun 2006
Location: Ireland
Old 05-09-2007 , 09:39   Re: GunGame SQL
Reply With Quote #7

Yes I do, and once you are ready to test it, just PM me and I will send you access to the Cpanel and FTP. I have 4 MySQL databases left, and 7 PostgreSQL Left. I also have about 80 MB of space left on my site, but I can make more room if needed out of the 500 MB total.
__________________
- l)l)` Vordrix (l)l)` Clan Leader).


http://www.ddcz.org
Vordrix is offline
Send a message via AIM to Vordrix
Cyb3rH4Xter
Senior Member
Join Date: May 2009
Location: Sweden
Old 05-06-2009 , 15:45   Re: GunGame SQL
Reply With Quote #8

How do i do if i have the game server/mysql and the webserver on different places?
I have the game server and mysql server at my computer and the webserver at x10hosting.
I get this error:

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'cyberstrike.no-ip.org' (4) in /home/cyb3r/public_html/index.php on line 12

What can i do to solve it?
Cyb3rH4Xter is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 05-06-2009 , 23:42   Re: GunGame SQL
Reply With Quote #9

I do not believe x10 allows external MySQL connections. You will have to submit a ticket with them and see. When I had their free packages, they didn't allow it, but I am on their paid accounts now and I am allowed to have external connections to MySQL
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Cyb3rH4Xter
Senior Member
Join Date: May 2009
Location: Sweden
Old 05-07-2009 , 01:25   Re: GunGame SQL
Reply With Quote #10

Quote:
Originally Posted by YamiKaitou View Post
I do not believe x10 allows external MySQL connections. You will have to submit a ticket with them and see. When I had their free packages, they didn't allow it, but I am on their paid accounts now and I am allowed to have external connections to MySQL
As you know, X10 uses cPanel 11, in the database field, there exists an option called "Remote Connections", and free users can use it. However i don't get it to work, i think it's my ip i should add there but im not shure.
Cyb3rH4Xter is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:03.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode