Posts: 2,754
Threads: 63
Joined: Nov 2011
Reputation:
261
2012-10-26, 02:43 AM
(This post was last modified: 2012-12-27, 02:26 AM by Wildcard.)
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:
- Copy all the files in the Upload directory to your forum's root directory.
- Copy a trophy image to the images directory of your forum. Some sample trophies are provided.
- Install & Activate the plugin in Admin CP
- 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
Then you should see your trophy image on the postbit of the user that currently has the last post in your last poster thread.
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
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
[retired]
Posts: 5,236
Threads: 101
Joined: Aug 2008
Reputation:
96
Approved
Thanks, Polarbear541
Posts: 2,754
Threads: 63
Joined: Nov 2011
Reputation:
261
Thanks so much
[retired]
Posts: 4,385
Threads: 162
Joined: Jul 2010
Reputation:
138
This user has been denied support.
Nice idea.
Posts: 2,754
Threads: 63
Joined: Nov 2011
Reputation:
261
Thank you
[retired]
Posts: 7,458
Threads: 144
Joined: Oct 2009
Reputation:
441
Congratulations on the plugin - a really neat idea.
Random Fish and Sims Maniac
MY PLUGINS
Help MyBBSupport help you - remember to mark your threads as solved
Posts: 9,905
Threads: 399
Joined: Jan 2010
Reputation:
548
2012-10-30, 06:09 PM
(This post was last modified: 2012-10-30, 09:41 PM by Omar G..)
This will awfully increase a query by post 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!
Soporte en Español
Discord at omar.gonzalez ( Omar G.#6117 ); Telegram at @omarugc ;
Posts: 2,754
Threads: 63
Joined: Nov 2011
Reputation:
261
(2012-10-30, 03:31 PM)Leefish Wrote: Congratulations on the plugin - a really neat idea.
Thanks a lot
(2012-10-30, 06:09 PM)Omar G. Wrote: This will awfully increase a query by post 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.
[retired]
Posts: 9,905
Threads: 399
Joined: Jan 2010
Reputation:
548
I failed to understand you code, sorry. Check my last post, it should work now.
Soporte en Español
Discord at omar.gonzalez ( Omar G.#6117 ); Telegram at @omarugc ;
Posts: 2,754
Threads: 63
Joined: Nov 2011
Reputation:
261
2012-10-30, 09:07 PM
(This post was last modified: 2012-10-30, 09:08 PM by Wildcard.)
(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!
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
[retired]
|