• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Powergamers script

Why don't you use 'players' table to save info about exp?
I'll try to make my own sript with update every 24 hours, save last 7 days exp change and show exp history (in my acc. maker).
 
How can I add
PHP:
<?php
include ('config.php');
include ('top.inc.php');
to the powergamers.php ? :p
Im newb on php
 
On header... or try on echo for example;
PHP:
echo 'include ('config.php');';
It didn't work but I think its me that are doing something wrong :p
I'm using Swelia btw (don't think that does any diffrent)
 
Why would you want to echo it? If it's a php file, and you paste that within php tags, it should work. You can't put it in html, for example.

PHP:
include ("config.php");
include ("top.inc.php");
 
You don't echo includes.
If your simply adding the includes to the powergamers script then just add it after <?php at the top of the script and at the very bottom right before this ?> you add the footer include.
 
You don't echo includes.
If your simply adding the includes to the powergamers script then just add it after <?php at the top of the script and at the very bottom right before this ?> you add the footer include.

Yeah, my bad - sorry.
 
Hehe yeah I'm Chris at Phobos (Old Xaar), why? :)
Anyways, I'm done with the script now and here it comes:


File: Config.php (Notice: It must have a capital C in the filename!)
PHP:
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
<?PHP


	/** Database Connection Data **/
	$config['DB'] = array
	(
	
		'localhost',			# Hostname
		'root',				 # Username
		'',				     # Password
		'scripts',			  # Database
		
		'chris_players',		# Players table
		'chris_powergamers'	 # PowerGamers table
	
	);
	
	
	/** General Configuration **/
	$config['GENERAL'] = array
	(
	
		7,					  # Lastlogin (X days before today).	(Default =  7)
		60,					 # [Forgot about this, so it's out of function] Refresh every X minutes.			(Default = 60)
		30,					 # Show X players at highscore.		(Default = 30)
	
	);
	

?>

File: stylesheet.css
Code:
.info
{
	font: 11px Tahoma;
	background: url(images/info.png) repeat #F2F2F2;
	border: 1px solid #D2D2D2;
	padding: 5px;	
	margin-bottom: 5px;
	text-align: center;
	min-width: 400px;
}

.info h1
{
	font: 16px Tahoma;
	margin: 3px;
	font-weight: bold;
}

.score
{
	border-top: 1px solid #D2D2D2;
	border-bottom: 1px solid #D2D2D2;
}

.score1
{
	font: 13px Tahoma;
	background-color: #F2F2F2;
	border-left: 1px solid #D2D2D2;
	border-right: 1px solid #D2D2D2;
	padding: 5px;
	min-width: 400px;
}

.score2
{
	font: 13px Tahoma;
	background-color: #F7F7F7;
	border-left: 1px solid #D2D2D2;
	border-right: 1px solid #D2D2D2;
	padding: 5px;
	min-width: 400px;
}

.score a:link, a:visited
{
	color: #000;	
	text-decoration: none;
}
.score a:active, a:hover
{
	color: #4c555b;	
	font-weight: bold;
	text-decoration: none;
}

.scoretitles
{
	font: 11px Tahoma;
	font-weight: bold;
	min-width: 400px;
	padding: 5px;
	padding-bottom: 0px;
}

File: DBConnect.php (Notice: It contains 3 capital letters in the filename!)
PHP:
<?PHP


	// Creating a class called Database.
	class Database
	{
		
		// Creating a function called dbConnection.
		function dbConnection ( )
		{
			
			
			// Including the configuration file.
			require ( './Config.php' );
			
			
			// Connect and select the database that was set in the configuration file.
			$db['CONNECT'] = mysql_connect ( $config['DB'][0] , $config['DB'][1] , $config['DB'][2] ) or die ( mysql_error() );
			$db['SELECT']  = mysql_select_db ( $config['DB'][3] , $db['CONNECT'] ) or die ( mysql_error() );
			
		}
	
	}
	
	
	// Print database connection.
	Database::dbConnection();

?>

File: powergamers.php
PHP:
<?PHP

	
	// Include the configuration & database connection files.
	require ( './Config.php' );
	require ( './DBConnect.php' );


	// Creating a class called powerGamers.
	class powerGamers
	{
		
		// Creating a function called onRefresh.
		function onRefresh ( )
		{
			 
		 	// Include the configuration file.
			require ( './Config.php' );
			
			
			// Variables required by the onRefresh function.
			$refreshTime	= $config['GENERAL'][1];
			$limitTop		= $config['GENERAL'][2];
			
			echo "<div class=\"info\"><h1>Top $limitTop PowerGamers</h1>The scoreboard will refresh each and every <strong>$refreshTime</strong> minutes.</div>";
			
		}
		
		
		
		// Creating a function called updateScores.
		function updateScores ( )
		{
		
			// Include the configuration file.
			require ( './Config.php' );
			
			
			// Variables required by the updateScores function.
			$onlineDays		= $config['GENERAL'][0];
			$DBPlayers		= $config['DB'][4];
			$DBPGs			= $config['DB'][5];
			
			$updated		= fread ( fopen ( 'update.txt' , 'r' ) , filesize ( 'update.txt' ) );
			$lastLogin		= date ( "d-m-Y" , mktime ( 0 , 0 , 0 , date ( "m" ) , date ( "d" ) - $onlineDays , date ( "Y" ) ) );
			
			$DBPlayersResult 	= mysql_query ( "SELECT * FROM `$DBPlayers`" );
			
			// Loop the players.
			while ( $row = mysql_fetch_array ( $DBPlayersResult ) )
			{
				
				// Required variables.
				$playerLastLogin	= date ( "d-m-Y" , $row[lastlogin] );
				$DBPGsResult		= mysql_query ( "SELECT * FROM `$DBPGs` WHERE `id` = $row[id]" );
				$checkPGs			= mysql_num_rows ( $DBPGsResult );
				$fetchPGs			= mysql_fetch_array ( $DBPGsResult );
				
				// Check which player has been online the past X days.
				if ( $playerLastLogin >= $lastLogin )
				{
					
					// Check if the players already exists in the PowerGamers table.
					if ( $checkPGs == 0 )
					{
						
						// Add new powergamers.
						mysql_query ( "
							INSERT INTO $DBPGs ( id , oldexperience , newexperience , difference )
							VALUES ( '$row[id]' , '$row[experience]' , '$row[experience]' , '0' )
						" );
						
					}
					elseif ( $checkPGs >= 1 && $updated != date ( "H" ) )
					{
						
						$experience[old] = $fetchPGs[newexperience];
						$experience[now] = $row[experience];
						$experience[dif] = $experience[now] - $experience[old];
						
						// Update the current powergamers.
						mysql_query ( "
							UPDATE $DBPGs
							SET oldexperience = '$experience[old]',
							newexperience = '$experience[now]',
							difference = '$experience[dif]'
							WHERE id = $row[id]
						" );
						
						// Change update.txt to contain 1 instead of 0.
						$fileHandle = fopen ( 'update.txt' , 'w' );
						fwrite ( $fileHandle, date ( "H" ) );
						fclose ( $fileHandle );
						
					}
					
				}
				
			}
			
		}
		
		
		
		// Creating a function called publicScoreboard.
		function publicScoreboard ( )
		{
			
			// Include the configuration file.
			require ( './Config.php' );
			
			
			// Including the onRefresh & updateScores function.
			$obj = new powerGamers;
			$obj -> onRefresh();
			$obj -> updateScores();
			
			
			// Variables required by the publicScoreboard function.
			$limitTop		= $config['GENERAL'][2];
			$DBPlayers		= $config['DB'][4];
			$DBPGs			= $config['DB'][5];
			
			$DBPGsResult 	= mysql_query ( "SELECT * FROM `$DBPGs` WHERE `difference` != '0' ORDER BY `difference` DESC LIMIT $limitTop" );
			$DBPGsCheck		= mysql_num_rows ( mysql_query ( "SELECT * FROM `$DBPGs` WHERE `difference` != '0'" ) );
			$i 				= 0;
			
			
			// Print scoretable titles.
			echo "<div class=\"scoretitles\">";
			echo "<div style=\"width: 5%; float: left;\">#</div>";
			echo "<div style=\"width: 35%; float: left;\">Character</div> ";
			echo "<div style=\"width: 35%; float: left;\">Old / New Experience</div> ";
			echo "<div style=\"width: 23%; float: left;\">Difference</div>";
			echo "&nbsp;</div>";
			echo "<div class=\"score\">";
			
			
			// Check if all the entries have difference 0.
			if ( $DBPGsCheck == 0 )
			{
			
				echo "<div class=\"score1\"><div>There are currently no players with an experience increasement.</div></div>";
				
			}
			
			
			// Loop the players.
			while ( $row = mysql_fetch_array ( $DBPGsResult ) )
			{
				
				
				// Required variables.
				$i++;
				$PGName			= mysql_fetch_array ( mysql_query ( "SELECT * FROM `$DBPlayers` WHERE `id` = $row[id]" ) );


				// Make every second background a different color.
				switch ( $i % 2 )
				{
					case 1:
						$bg = 1;
					break;
					
					default:
						$bg = 2;
					break;
				}
				
				
				// Print the result.
				echo "<div class=\"score$bg\">";
				echo "<div style=\"width: 5%; float: left;\">$i</div>";
				echo "<div style=\"width: 35%; float: left;\"><a href=\"characters.php?char=$PGName[name]\">$PGName[name]</a></div> ";
				echo "<div style=\"width: 35%; float: left;\"><strike style=\"color: #900808;\">$row[oldexperience]</strike> -> $row[newexperience]</div> ";
				echo "<div style=\"width: 23%; float: left;\"><strong style=\"color: #539c33;\">+$row[difference]</strong></div>";
				echo "&nbsp;</div>";
				
			}
			
			
			echo "</div>";
			
		}
		
	}
	
	
	// Print the publicScoreboard function.
	powerGamers::publicScoreboard();


?>

File: update.txt
Code:
0

MySQL: xxx_powergamers
Code:
`ID` INT, PRIMARY KEY
`oldexperience` VARCHAR(60)
`newexperience` VARCHAR(60)
`difference` VARCHAR(60)


EDIT: Forgot to mention, this is the file for images/info.png:
http://img98.imageshack.us/img98/3976/infozn9.png


I can't get mine too work, could you help me?
 
Top 30 PowerGamers
The scoreboard will refresh each and every 60 minutes.
#
Character
Old / New Experience
Difference

There are currently no players with an experience increasement.
_______________________________________________________________

How long should that take too show some exp increasment????
 
Last edited:
Back
Top