I found an old game!

Place to place any code snippets, completed games, or even uncompleted games for IR users to use.
Post Reply
User avatar
Chris
Posts: 1580
Joined: Wed Sep 30, 2009 7:22 pm

I found an old game!

Post by Chris »

I used to work on this at school in my "spare" time. Was just poking about on the computers and stumbled accross it. Might be of use to someone, I can't find the database for it. Haven''t had a chance to test it out. It's a really simple scripted system, nothing too complex.

Edit: Just found the database! The connect.php script points directly to it :D

Flag icons from http://famfamfam.com/
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
Chris
Posts: 1580
Joined: Wed Sep 30, 2009 7:22 pm

Re: I found an old game!

Post by Chris »

functions/global.lang.define.php fix:

Code: Select all

<?php

// Split commas from string into an array
function global_lang_define()
{

    if( empty($_SESSION['lang']) )
    {
        $_SESSION['lang'] = "en";
    }
    
    $lines = file_get_contents("settings/lang.{$_SESSION['lang']}.txt");

    foreach ( explode("\n", $lines) as $line_num => $line)
    {
        $lineArray = explode("::", $line);
        define($lineArray['0'], trim($lineArray['1']));
    }
    return true;
}

?>
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
Chris
Posts: 1580
Joined: Wed Sep 30, 2009 7:22 pm

Re: I found an old game!

Post by Chris »

functions/global.navigation.php fix:

Code: Select all

<?php

// check if user is logged in
function global_navigation($userId)
{
    $userQuery = mysql_query("SELECT * FROM `users` WHERE `id` = '$userId'");
    $userArray = mysql_fetch_assoc($userQuery);
    
    $array = array( ''.LANG_USER_STATS.'' => array(),
                    ''.LANG_NAVIGATION.'' => array(),
                    ''.LANG_USERS_ONLINE.'' => array());
    
    $array[''.LANG_USER_STATS.''][] = "{$userArray['username']}[{$userArray['id']}]";
    $array[''.LANG_USER_STATS.''][] = "$ {$userArray['money']}";
    $array[''.LANG_USER_STATS.''][] = "Lvl {$userArray['level']}";
    
    $hpLeft = ($userArray['hp']/$userArray['max_hp'])*100;
    $xpNeed = round(($userArray['level']*12054.4555)/33, 0);
    $xpLeft = ($userArray['xp']/$xpNeed)*100;
    
    $array[''.LANG_USER_STATS.''][] = "<div style=\"background: #A33; padding: 0px; margin: 0px; height: 14px; text-align: left;\">
                                <div style=\"background: #3A3; padding: 0px; margin: 0px; height: 14px; width: $hpLeft%;\"> </div>
                                <div style=\"text-align: center; font-weight: bold; padding: 0px; padding-top: 1px; padding-left: 1px; margin: 0px; color: #000; font-size: 10px; margin-top: -14px;\"> HP: {$userArray['hp']}/{$userArray['max_hp']} </div>
                                <div style=\"text-align: center; font-weight: bold; padding: 0px; margin: 0px; color: #FFF; font-size: 10px; margin-top: -13px;\"> HP: {$userArray['hp']}/{$userArray['max_hp']} </div>
                              </div>";
                              
    $array[''.LANG_USER_STATS.''][] = "<div style=\"background: #33A; padding: 0px; margin: 0px; height: 14px; text-align: left;\">
                                <div style=\"background: #3AA; padding: 0px; margin: 0px; height: 14px; width: $xpLeft%;\"> </div>
                                <div style=\"text-align: center; font-weight: bold; padding: 0px; padding-top: 1px; padding-left: 1px; margin: 0px; color: #000; font-size: 10px; margin-top: -14px;\"> XP: {$userArray['xp']}/$xpNeed </div>
                                <div style=\"text-align: center; font-weight: bold; padding: 0px; margin: 0px; color: #FFF; font-size: 10px; margin-top: -13px;\"> XP: {$userArray['xp']}/$xpNeed </div>
                              </div>";
    
    $array[''.LANG_NAVIGATION.''][] = "    <form action=\"{$_SERVER['PHP_SELF']}?4\" method=\"post\" style=\"padding: 0px; margin: 0px;\">
                                    <input type=\"submit\" value=\"".LANG_LOG_OUT."\" style=\"border: 0px solid; background: #051A2E; color: #99F; font-size: 12px; padding: 0px; margin: 0px;\" name=\"logout\" />
                                </form>";
    
    $inboxQuery = mysql_query("SELECT * FROM `mail` WHERE `to_id` = '{$userArray['id']}' AND `read` = '0' AND `deleted` != '1'");
    $array[''.LANG_NAVIGATION.''][] = "<a href=\"{$_SERVER['PHP_SELF']}?5\">".LANG_MAIL."</a> [". mysql_num_rows($inboxQuery)."]";
    $array[''.LANG_NAVIGATION.''][] = "<a href=\"{$_SERVER['PHP_SELF']}?10\">Forum</a>";
    
    $lastActiveTime = time()-300;
    $onlineQuery = mysql_query("SELECT * FROM `users` WHERE `last_active` >= '$lastActiveTime' AND `last_page` != '4'");
    $i = 0;
    $array[''.LANG_USERS_ONLINE.''][0] = '';
    while( $onlineArray = mysql_fetch_assoc($onlineQuery) )
    {
        if( $i > 0 )
        {
            $array[''.LANG_USERS_ONLINE.''][0] .= ", ";
        }
        $array[''.LANG_USERS_ONLINE.''][0] .= "<a href=\"index.php?3,{$onlineArray['id']}\" title=\"ID: {$onlineArray['id']}, Rank: ". global_rank($onlineArray['rank']) ."\">{$onlineArray['username']}</a> ";
        $i++;
    }
    
    return $array;

}
?>
Fighting for peace is declaring war on war. If you want peace be peaceful.
PKDemon
Posts: 91
Joined: Tue Nov 15, 2011 5:51 pm

Re: I found an old game!

Post by PKDemon »

it is always kewl to find old projects that you have started :) but i will download and look through it and see how kewl it is :)
Kevin1230
Posts: 62
Joined: Mon Jul 18, 2011 3:32 pm

Re: I found an old game!

Post by Kevin1230 »

( ! ) Fatal error: Cannot redeclare global_user_id_to_name_link() (previously declared in C:\wamp\www\spel\functions\global.user.id.to.name.lnik.php:4) in C:\wamp\www\spel\functions\global.user.id.to.name.php on line 16

why does it show this error?

Here is global.user.id.name.php

Code: Select all

<?php

// Get user stats into an array
function global_user_id_to_name_link($id)
{
	$userQuery = mysql_query("SELECT * FROM `users` WHERE `id` = '$id'");
	if( mysql_num_rows($userQuery) != 1 )
	{
	 	return false;
	}
	else
	{
		$userArray = mysql_fetch_assoc($userQuery);
	  	return $userArray['username'];
	}
 }
?>
User avatar
Chris
Posts: 1580
Joined: Wed Sep 30, 2009 7:22 pm

Re: I found an old game!

Post by Chris »

function global_user_id_to_name_link($id) is already defined in a different file. Should be, global_user_id_to_name($id);

Code: Select all

// Get user stats into an array
function global_user_id_to_name($id)
{
    $userQuery = mysql_query("SELECT `username` FROM `users` WHERE `id` = '$id'");
    if( mysql_num_rows($userQuery) != 1 )
    {
         return false;
    }
    else
    {
        $userArray = mysql_fetch_assoc($userQuery);
          return $userArray['username'];
    }
}
 
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
vitinho444
Posts: 2819
Joined: Mon Mar 21, 2011 4:54 pm

Re: I found an old game!

Post by vitinho444 »

@pkDemon you know whats not cool? Lose the source for 5 months projects, it happened to me twice :(
But moving on :D
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
Post Reply

Return to “Code Sharing”