MyBB Community Forums

Full Version: Game Section
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
gimmezell Wrote:
Ken7 Wrote:I'm using the add game function, not the simple one...Because the simple one does not work.

Yeah, the "simple" option doesn't work for me either.

What are you using for Name of the files:? I used "AWormsLife_Ste"

Yes thats the filename I used.

I have several games with gamedata files and all the games play fine, but I can't get the scores to submit and get recorded.


Question:
In gamedata, do you upload the folder or just the contents of the folder, like you do with the images?

thanks
In my "gamedata/" I have the "AWormsLife_Ste" folder and in that folder I have six files.
when i run the upgrade.php i get:
/home/kellys/public_html/thenightlords/forum/inc/languages//games.lang.php does not exist

I think i followed the instructions allright. including in globabl.php

After
// Load language
$lang->set_language($mybb->settings['bblanguage']);
$lang->load("global");
$lang->load("messages");
I did add $lang->load("games");

EDIT:
note that I forgot to deactivate 1.0.6 before replacing the files and editing.

Is it possible for someone to provide the modded files for download? (upgrade ones, ofcourse). Then I can just replace the files and get it done with. Toungue
the new game1.1 system, seems to not keep the "winners".
every time someone plays, it puts then in that place, and only after i "repair champions" in the adminCP does it fix it.
is it possible to make it auto refresh it so i wouldn' thave to 'fix" it after each time the game is played?

Thanks!
i fixed it by putting the "repair chamions" code segment from the admin games.php in two places in submit.php. Before each of the two redirects.
it seemed to fix the problem for now, but if anyone has a more efficient way to do it. i'd love to hear it.
Thanks!
MadamZuZu Wrote:i fixed it by putting the "repair chamions" code segment from the admin games.php in two places in submit.php. Before each of the two redirects.
it seemed to fix the problem for now, but if anyone has a more efficient way to do it. i'd love to hear it.
Thanks!

Will there be a fix for this that we can upload?
I am getting this error when I try to add games via admin cp
MyBB Error
Access Denied

      You do not have permission to access this part of the administration control panel.
Ken7 Wrote:Will there be a fix for this that we can upload?


i dont know. i didn't write the mod. just tried to modify it myself (my first php attempt,and i think it worked)

anyway. this is what my submit.php looks like right now....
<?php
/**
 * Game Section for MyBB
 * Copyright © 2006-2007 Online - Urbanus
 * 
 * Website: http://www.Online-Urbanus.be
 * 
 * Support in each language with a translation: http://www.Online-Urbanus.be/Forum
 * English support: http://community.mybboard.net/showthread.php?tid=12413
 * 
 * License: GNU/GPL v2
 * 
 * Last modifed: 25/03/2007
 */

//Is this an old PHP version
if(!isset($_SERVER))
{
	$_SERVER = $HTTP_SERVER_VARS;
}

//Is this a direct use
$test_file = strpos($_SERVER['PHP_SELF'], "/games/submit.php");
if($test_file !== false)
{
	die("You don't have acces to this page.");
}

//Define MyBB
define("IN_MYBB", 1);

require_once "./global.php";

$plugins->run_hooks("games_submit_start");

//Variabels
$gid = intval($_COOKIE['mybb_games_gid']);
$name = addslashes($mybb->input['gname']);
$uid = intval($mybb->user['uid']);
$score = intval($mybb->input['gscore']);

//Is this correctly?
if(!intval($_COOKIE['mybb_games_gid']) || !intval($mybb->input['gscore']) || !isset($mybb->input['gname']))
{
	if(intval($_COOKIE['mybb_games_gid']) || intval($mybb->input['gscore']) || isset($mybb->input['gname']))
	{
		if($mybb->input['gscore'] === 0)
		{
			redirect("games.php?action=scores&gid=".$gid, $lang->scoreis0);
		}
		else
		{
			error($lang->noinput, $lang->error);
		}
	}
	else
	{
		error($lang->noinput, $lang->error);
	}
}
else
{
	//Information of the game
	$query = $db->query("SELECT * FROM ".TABLE_PREFIX."games WHERE name='".$mybb->input['gname']."'");
	$games_test = $db->num_rows($query);
	
	//How many games with that file
	if($games_test == 0)
	{
		error($lang->gamedoesntexist, $lang->error);
	}
	elseif($games_test == 1)
	{
		$game = $db->fetch_array($query);
	}
	else
	{
		$query = $db->query("SELECT * FROM ".TABLE_PREFIX."games WHERE name='".$mybb->input['gname']."' AND gid='".$_COOKIE['mybb_games_gid']."'");
		$game = $db->fetch_array($query);
		$game_test = $db->num_rows($query);
		
		if($game_test == 0)
		{
			error($lang->gamedoesntexist, $lang->error);
		}
	}
	
	$gid = $game['gid'];
	
	$plugins->run_hooks("games_submit_pre");
	
	//Strip ASC and DESC
	if($game['score_type'] == DESC)
	{
		$score_type = "<";
	}
	
	if($game['score_type'] == ASC)
	{
		$score_type = ">";
	}
	
	//Is there all a score?
	$query = $db->query("SELECT * FROM ".TABLE_PREFIX."games_scores WHERE uid='".$uid."' AND gid='".$gid."' ORDER BY score ".$game['score_type']." LIMIT 0,1");
	$score_test = $db->num_rows($query);
	
	if($score_test == 1)
	{
		//Yes, Is the score higher then the old one?
		$query2 = $db->query("SELECT * FROM ".TABLE_PREFIX."games_scores WHERE uid='".$uid."' AND gid='".$gid."' AND score".$score_type."'".$score."' ORDER BY score ".$game['score_type']." LIMIT 0,1");
		$score_update_test = $db->num_rows($query2);
		
		if($score_update_test == 1)
		{
			$update_score = array(
				'gid'			=> intval($gid),
				'uid'			=> intval($mybb->user['uid']),
				'username'		=> addslashes($mybb->user['username']),
				'score'			=> intval($score),
				'dateline'		=> time(),
				'ip'			=> get_ip()
			);
			
			$db->update_query(TABLE_PREFIX."games_scores", $update_score, "gid='".$gid."' AND uid='".$uid."'");
			
			$plugins->run_hooks("games_submit_update_score");
			
			//Are you a champion?
			$query3 = $db->query("SELECT * FROM ".TABLE_PREFIX."games_champions WHERE gid='".$gid."'");
			$champ_test = $db->num_rows($query3);
			
			if($champ_test == 1)
			{
				$query4 = $db->query("SELECT * FROM ".TABLE_PREFIX."games_champions WHERE gid='".$gid."' AND score".$score_type."'".$score."'");
				$champ_update_test = $db->num_rows($query4);
				
				if($champ_update_test == 1)
				{
					$update_champ = array(
						'uid'			=> intval($mybb->user['uid']),
						'username'		=> addslashes($mybb->user['username']),
						'score'			=> intval($score),
						'dateline'		=> time()
					);
					
					$db->update_query(TABLE_PREFIX."games_champions", $update_champ, "gid='".$gid."'");
					
					$plugins->run_hooks("games_submit_update_champ");
				}
			}
			else
			{
				$insert_champ = array(
					'gid'			=> intval($gid),
					'title'			=> addslashes($game['title']),
					'uid'			=> intval($mybb->user['uid']),
					'username'		=> addslashes($mybb->user['username']),
					'score'			=> intval($score),
					'dateline'		=> time()
				);
				
				$db->insert_query(TABLE_PREFIX."games_champions", $insert_champ);
				
				$plugins->run_hooks("games_submit_insert_champ");
			}
			
		//repair champions///////////////////////////////////////////////
		//Load the games
		$query = $db->query("SELECT * FROM ".TABLE_PREFIX."games");
		while($champs_games = $db->fetch_array($query))
		{
			//Load best score
			$query2 = $db->query("SELECT * FROM ".TABLE_PREFIX."games_scores WHERE gid='".$champs_games['gid']."' ORDER BY score ".$champs_games['score_type']." LIMIT 0,1");
			$champs_scores = $db->fetch_array($query2);
			$champs_scores_test = $db->num_rows($query2);
			
			//Set champ
			if($champs_scores_test == 1)
			{
				$champs_array = array(
					'uid'			=> intval($champs_scores['uid']),
					'username'		=> addslashes($champs_scores['username']),
					'score'			=> addslashes($champs_scores['score']),
					'dateline'		=> addslashes($champs_scores['dateline']),
				);
			
				$db->update_query(TABLE_PREFIX."games_champions", $champs_array, "gid='".$champs_scores['gid']."'");
			}
		}
		
		//cpredirect("games.php?".SID, $lang->repaired_champs);
		//////////////////////////////////
			
			redirect("games.php?action=newscore&gid=$gid", $lang->scoreadded);
		}
		else
		{
			redirect("games.php?action=scores&gid=$gid", $lang->scoredontadded);
		}
	}
	else
	{
		//No, insert the score then.
		$insert_score = array(
			'sid'			=> NULL,
			'gid'			=> intval($gid),
			'uid'			=> intval($mybb->user['uid']),
			'username'		=> addslashes($mybb->user['username']),
			'score'			=> intval($score),
			'dateline'		=> time(),
			'ip'			=> get_ip()
		);
		
		$db->insert_query(TABLE_PREFIX."games_scores", $insert_score);
		
		$plugins->run_hooks("games_submit_insert_score");
		
		//Are you a champion?
		$query3 = $db->query("SELECT * FROM ".TABLE_PREFIX."games_champions WHERE gid='".$gid."'");
		$champ_test = $db->num_rows($query3);
		
		if($champ_test == 1)
		{
			$query4 = $db->query("SELECT * FROM ".TABLE_PREFIX."games_champions WHERE gid='".$gid."' AND score".$score_type."'".$score."'");
			$champ_update_test = $db->num_rows($query4);
			
			if($champ_update_test == 1)
			{
				$update_champ = array(
					'uid'			=> intval($mybb->user['uid']),
					'username'		=> addslashes($mybb->user['username']),
					'score'			=> intval($score),
					'dateline'		=> time()
				);
				
				$db->update_query(TABLE_PREFIX."games_champions", $update_champ, "gid='".$gid."'");
				
				$plugins->run_hooks("games_submit_update_champ");
			}
		}
		else
		{
			$insert_champ = array(
				'gid'			=> intval($gid),
				'title'			=> addslashes($game['title']),
				'uid'			=> intval($mybb->user['uid']),
				'username'		=> addslashes($mybb->user['username']),
				'score'			=> intval($score),
				'dateline'		=> time()
			);
			
			$db->insert_query(TABLE_PREFIX."games_champions", $insert_champ);
			
			$plugins->run_hooks("games_submit_insert_champ");
		}
		
		//repair champions///////////////////////////////////////////////
		//Load the games
		$query = $db->query("SELECT * FROM ".TABLE_PREFIX."games");
		while($champs_games = $db->fetch_array($query))
		{
			//Load best score
			$query2 = $db->query("SELECT * FROM ".TABLE_PREFIX."games_scores WHERE gid='".$champs_games['gid']."' ORDER BY score ".$champs_games['score_type']." LIMIT 0,1");
			$champs_scores = $db->fetch_array($query2);
			$champs_scores_test = $db->num_rows($query2);
			
			//Set champ
			if($champs_scores_test == 1)
			{
				$champs_array = array(
					'uid'			=> intval($champs_scores['uid']),
					'username'		=> addslashes($champs_scores['username']),
					'score'			=> addslashes($champs_scores['score']),
					'dateline'		=> addslashes($champs_scores['dateline']),
				);
			
				$db->update_query(TABLE_PREFIX."games_champions", $champs_array, "gid='".$champs_scores['gid']."'");
			}
		}
		
		//cpredirect("games.php?".SID, $lang->repaired_champs);
		//////////////////////////////////
		
		redirect("games.php?action=newscore&gid=$gid", $lang->scoreadded);
	}
	

}





$plugins->run_hooks("games_submit_end");
?>


keep in mind that i am not familiar w/ php, but it seems to be working for now.

hope this helps.
I know you didn't write the Mod, I was hoping Paretje would modify the code and give us all the file to upload to our forums.

I might try copying your code...I'm glad you took the time to figure it out, and thanks for that...

thanks
Paretje,

Can you modify the code so we can all upload the fix that MadamZuZu came up with?

Thanks