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.
jcay, for future reference, you don't need to deactivate your plugins before doing an upgrade, and you should ALWAYS back up your database before doing so!! But I think you have figured that out? Wink

And Paretje, let me say it one more time. The admin/games folder didn't get uploaded to my forum BECAUSE IT DIDN'T EXIST in your download! And to make it easier for others once you do create the full install instructions on your forum, make a little blurb in the readme with the link, so everyone knows where it is! Toungue
Yes Judel, i never miss backing up before doing something like that, i also managed to lock myself out of admin on one of the forums yesterday too lol, it was a really bad day for me... Wink
judel Wrote:And Paretje, let me say it one more time. The admin/games folder didn't get uploaded to my forum BECAUSE IT DIDN'T EXIST in your download! And to make it easier for others once you do create the full install instructions on your forum, make a little blurb in the readme with the link, so everyone knows where it is! Toungue

Okay okay, I only say that in 1.1.6 it's surely delivered. And you can find the After Installation here:
http://gamesection.org/wiki/After_Installation
judel Wrote:
Quote:No, the score isn't in the URL bar.
How can you say that? I can see it in the url bar before I click save. Do I need to attach a screen shot? I thought that was what everyone was saying when they said it was so easy to cheat. It's very easy to change that score before hitting submit.

I know what you mean, you mean when you are redirected to add a score? That's only to search the right page Wink
When I tried to view who was online (http://tacticsandfirearms.clanteam.com/mybb/online.php), I got this error:

Quote:Parse error: syntax error, unexpected '"' in /www/clanteam.com/t/a/c/tacticsandfirearms/htdocs/mybb/online.php on line 70

Do you know how to fix it? Sad I spent a good amount of time installing this MOD..
Ok, here is de online.php for MyBB 1.2.10 + the Game Section changes.
Yeah, MyBB's Who's Online list isn't exactly great for plugins...

Though there _is_ a way to use hooks and actually get it working. MyPlaza does it, however, it does require some forging and other dirty tricks of sorts...
If you're interested, Paretje, I can show you.

Dunno, just thought it'd be nice to have a plugin which works completely without code edits.


Admin/Usergroups is an issue... I completely copied MyBB's code just to insert a few of my own options (I also added a hook so further plugins can use it) - it's dirty, but if you want to remove the need for code edits, there isn't much you can do... (the only other option would be to enable output buffering, then use a shutdown function to do replacements - a lot dirtier IMO)
ZiNga BuRgA Wrote:Yeah, MyBB's Who's Online list isn't exactly great for plugins...
Indeed, but I thanks MyBB that they did what I asked a long time ago: first the language, then the hook (global.php).

When you use 1.2.10, you must to change admin/usergroups.php (yesno code, because the hook is before the yesno codes etc. Toungue) and online.php (because there is only one hook at the start and one at the end of the file Toungue)

ZiNga BuRgA Wrote:Though there _is_ a way to use hooks and actually get it working. MyPlaza does it, however, it does require some forging and other dirty tricks of sorts...
If you're interested, Paretje, I can show you.
When you run it afterwards, before it's outputted?

ZiNga BuRgA Wrote:Dunno, just thought it'd be nice to have a plugin which works completely without code edits.
I know, but it's currently impossible without any change. Or you add 2 hooks in the global.php and 2 in de admin/usergroups.php, or you add a code in it. In 1.2, maybe it's the first choice. But maybe it's already fixed in MyBB 1.4 ...

ZiNga BuRgA Wrote:Admin/Usergroups is an issue... I completely copied MyBB's code just to insert a few of my own options (I also added a hook so further plugins can use it) - it's dirty, but if you want to remove the need for code edits, there isn't much you can do... (the only other option would be to enable output buffering, then use a shutdown function to do replacements - a lot dirtier IMO)
I did that with the global.php, too. Before 1.2.10, you must to replace the code.
Paretje Wrote:
ZiNga BuRgA Wrote:Yeah, MyBB's Who's Online list isn't exactly great for plugins...
Indeed, but I thanks MyBB that they did what I asked a long time ago: first the language, then the hook (global.php).
They fixed that? O_O
I should make my plugin take advantage of that then. Thanks a lot for the tip!
It was possible to load the language twice, however, I'm sure you're aware of the extra unnecessary overhead Toungue

Paretje Wrote:When you use 1.2.10, you must to change admin/usergroups.php (yesno code, because the hook is before the yesno codes etc. Toungue) and online.php (because there is only one hook at the start and one at the end of the file Toungue)
You can hook before the yesno codes, and copy all the code that MyBB users. Then use exit; to escape executing MyBB's code. It's "dirty" in the fact that you have to duplicate a whole heap of code, however, it's a method of getting around the issue. The problem with this is, that it won't work well with multiple plugins doing the same thing (which is why it's "dirty" Toungue).
As for Who's Online, here's the code MyPlaza uses:


$plugins->add_hook('online_user', 'myplaza_wol_users', 10);

function myplaza_wol_users()
{
	global $user, $doneusers, $forums, $myplaza_wol_users, $plugins;
	$p = my_strpos($user['location'], '/plaza.php');
	if(!$p) return;
	$params = my_substr($user['location'], $p+10);
	
	if(my_strlen($params) > 1)
	{
		$params = explode('&', my_substr($params, 1));
		foreach($params as $param)
		{
			$temp = explode('=', $param);
			$parameters[$temp[0]] = $temp[1];
		}
	}
	
	$user['params'] = $parameters;
	
	$plugins->run_hooks('myplaza_wol_process');
	$myplaza_wol_users[] = $user;
	
	// dunno if it's quicker to use a static variable to count the users.... meh
	$placeholder = 'myplaza_'.count($myplaza_wol_users);
	
	// now that we have all the data, we'll have to do some forging to bypass MyBB's WOL restrictions :S
	//  we'll forge the location to announcements
	$user['location'] = 'forged_request/announcements.php?fid='.$placeholder;
	$forums[$placeholder] = $placeholder;
}



$plugins->add_hook('online_end', 'myplaza_wol_end', 100);
function myplaza_wol_end()
{
	global $lang, $forums, $myplaza_wol_users, $onlinerows, $user, $plugins;
	if(!isset($myplaza_wol_users) || empty($myplaza_wol_users)) return;
	$lang->load('myplaza');
	
	$finds = array();
	$replaces = array();
	$i=1;
	//for($i=1; $i<=count($myplaza_wol_params); $i++)
	foreach($myplaza_wol_users as $key => $user)
	{
		$finds[] = sprintf($lang->viewing_announcements, 'myplaza_'.$i, 'myplaza_'.$i);
		$replacement = '';
		
		if(isset($user['params']['action']))
		{
			if($user['params']['action'] == 'stats')
				$replacement = $lang->myplaza_wol_stats;
			if($user['params']['action'] == 'history')
				$replacement = $lang->myplaza_wol_history;
			if($user['params']['action'] == 'do_buy')
				$replacement = $lang->myplaza_wol_buying;
		}
		else
			$replacement = $lang->myplaza_wol_plaza;
		
		$plugins->run_hooks_by_ref('myplaza_wol', $replacement);
		if(!$replacement) $replacement = sprintf($lang->myplaza_wol_unknown, $user['location']);
		$replaces[] = $replacement;
		$i++;
	}
	$onlinerows = str_replace($finds, $replaces, $onlinerows);
}
Yeah, just please use a different prefix for $placeholder Toungue I plan to make some other plugins using the above trick.


Paretje Wrote:In 1.2, maybe it's the first choice. But maybe it's already fixed in MyBB 1.4 ...
Yeah, I'd really like to see "_code" hooks at the end, before endform() in the MyBB 1.4 AdminCP - would make plugin development a lot easier, and work better for users too Toungue

Still, a great plugin Smile
ZiNga BuRgA Wrote:They fixed that? O_O
Yesn they did Wink

ZiNga BuRgA Wrote:
Paretje Wrote:When you use 1.2.10, you must to change admin/usergroups.php (yesno code, because the hook is before the yesno codes etc. Toungue) and online.php (because there is only one hook at the start and one at the end of the file Toungue)
You can hook before the yesno codes, and copy all the code that MyBB users. Then use exit; to escape executing MyBB's code. It's "dirty" in the fact that you have to duplicate a whole heap of code, however, it's a method of getting around the issue. The problem with this is, that it won't work well with multiple plugins doing the same thing (which is why it's "dirty" Toungue).
Yes, it isn't exactly a good method, there are no other plugins possible then Toungue

ZiNga BuRgA Wrote:As for Who's Online, here's the code MyPlaza uses:
online_users ... I didn't see this one Toungue

ZiNga BuRgA Wrote:Still, a great plugin Smile
Thanks Wink