MyBB Community Forums

Full Version: Last Poster Trophy On Postbit v1.01
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
One of (if not the) most inane forum games ever created, devoid of all creativity and productivity and yet insanely, widely popular is 'The Last Poster Wins'. Almost every forum has some version of it and I thought I might make a simple little plugin to display a trophy on the postbit of the user in your forum that currently has the last post in your forum's version of 'The Last Poster Wins' thread.





Installation:

  1. Copy all the files in the Upload directory to your forum's root directory.
  2. Copy a trophy image to the images directory of your forum. Some sample trophies are provided.
  3. Install & Activate the plugin in Admin CP
  4. Edit and Save the plugin settings to point to your forum's last poster wins thread and the trophy image you uploaded in step 2

[Image: ssadmincp.png]

Then you should see your trophy image on the postbit of the user that currently has the last post in your last poster thread.

[Image: sspostbit-1.gif]

Removal:

Uninstall the plugin and remove all files.

Upgrade:

Uninstall the plugin and repeat steps 1,3 and 4 from the installation instructions.

Support:

I make no guarantees of support but I will always try. If you need support for this plugin please create a support thread at MyBB forums.

Omar G. provided a much better idea for getting the information the plugin needs without so many queries

Thanks Omar Smile


have updated the plugin and attached a copy to serve until the plugin is updated on the mods site.

The plugin had been updated at the mods site and is available for download: http://mods.mybb.com/download/last-poste...on-postbit
Approved Smile
Thanks so much Smile
Nice idea.
Thank you Smile
Congratulations on the plugin - a really neat idea.
This will awfully increase a query by post Sad To solve this find:
		// Find the last two posts in the 'Last Poster Wins' thread
		$last_post_query = $db->simple_select("posts", "uid", "tid=" . intval($mybb->settings['last_poster_setting2']), array("order_by" => 'dateline', "order_dir" => 'DESC', "limit" => 2));

		if ($db->num_rows($last_post_query) > 0)
		{
			// Get uid of the last two posters
			$last_post = $db->fetch_array($last_post_query);
			$next_to_last_post = $db->fetch_array($last_post_query);

Replace with:
        // Find the last two posts in the 'Last Poster Wins' thread
        static $winnir_thread = null;

        if(!isset($winnir_thread))
        {
            $last_post_query = $db->simple_select("posts", "uid", "tid=" . intval($mybb->settings['last_poster_setting2']), array("order_by" => 'dateline', "order_dir" => 'DESC', "limit" => 2));
            $winnir_thread = array('count' => (int)$db->num_rows($last_post_query));
            $winnir_thread['first'] = (int)$db->fetch_field($last_post_query, 'uid');
            $winnir_thread['second'] = (int)$db->fetch_field($last_post_query, 'uid');
        }

        if ($winnir_thread['count'] > 0)
        {
            // Get uid of the last two posters
            $last_post = array('uid' => $winnir_thread['first']);
            $next_to_last_post = array('uid' => $winnir_thread['second']);

As you can see, you don't really need to query, good plugin and nice idea!
(2012-10-30, 03:31 PM)Leefish Wrote: [ -> ]Congratulations on the plugin - a really neat idea.

Thanks a lot Smile

(2012-10-30, 06:09 PM)Omar G. Wrote: [ -> ]This will awfully increase a query by post Sad To solve this find:
		// Find the last two posts in the 'Last Poster Wins' thread
		$last_post_query = $db->simple_select("posts", "uid", "tid=" . intval($mybb->settings['last_poster_setting2']), array("order_by" => 'dateline', "order_dir" => 'DESC', "limit" => 2));

		if ($db->num_rows($last_post_query) > 0)
		{
			// Get uid of the last two posters
			$last_post = $db->fetch_array($last_post_query);
			$next_to_last_post = $db->fetch_array($last_post_query);

Replace:
		// Find the last two posts in the 'Last Poster Wins' thread
		$last_post_query = $db->simple_select("posts", "uid", "tid=" . intval($mybb->settings['last_poster_setting2']), array("order_by" => 'dateline', "order_dir" => 'DESC', "limit" => 2));

		if ($db->num_rows($last_post_query) > 0)
		{
			// Get uid of the last two posters
			$last_post = $db->fetch_array($last_post_query);
			$next_to_last_post = $db->fetch_array($last_post_query);

Replace with:
		// Find the last two posts in the 'Last Poster Wins' thread
		if ($post['tid'] == (int)$mybb->settings['last_poster_setting2'])
		{
			// Get uid of the last two posters
			$last_post = $next_to_last_post = array('uid' => &$post['uid']);

First of all, thanks for taking the time to help me with my code. The only thing is my friend I do not understand how this code can work . . . this line:

$last_post = $next_to_last_post = array('uid' => &$post['uid']);

Doesn't seem to be looking up the last two posters in the LPW thread, but rather the last two posts in the current thread which isn't the same thing.

If I can do this without a query (or if I am wrong about the code) please let me know.

(2012-10-30, 06:09 PM)Omar G. Wrote: [ -> ]As you can see, you don't really need to query, good plugin and nice idea!

Thanks so much for that and for your advice that I will try to understand. Smile
I failed to understand you code, sorry. Check my last post, it should work now.
(2012-10-30, 08:31 PM)Omar G. Wrote: [ -> ]I failed to understand you code, sorry. Check my last post, it should work now.

Okay now that is a great idea! Smile

I had 34 queries per page and now I'm at 25!

The only problem is this line:

// Get uid of the last two posters
$last_post = $next_to_last_post = array('uid' => $winner_thread);

doesn't correctly retrieve the last two poster's uid (from the LPW thread). Instead it places the uid for the Last Poster in both $last_post and $next_to_last_post . . . so the JavaScript to clear the old trophies is never coded (and the old trophies stay on the screen Sad
Pages: 1 2