MyBB Community Forums

Full Version: RPG Level bug + question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I am using the RPG Level plugin ( https://community.mybb.com/mods.php?action=view&pid=189 ) and noticed that it works nicely for users with up to 999 posts, but then it gets crazy and displays "level 2" for everyone with more posts. Any suggestions how to fix that? 

Another question: what would one have to add to make that level thing work on the member profile page as well?
no one?
(2018-06-20, 08:05 AM)linguist Wrote: [ -> ]no one?
As this is third party plugin from a user, my suggestion is to contact the plugin dev as he will be able to help faster.
The dev has last been seen in this forum 3 years ago. I am not sure they'll check in here.
This plugin is based on the user titles.
Have you titles which need more than 1000 posts ?
Yes. But I don't see _where_ that number causes a problem.
OK, understand Smile The plugin uses $post['postnum'] to calculate, but this variable is formated with a comma as thousand separator. So the int value of the string, when number of posts is more than 999, is the thousand value.

The quick correction is to change the main function:
/**
 *	Prints the level and experience
 *	@param post PostClass
 */
function rpglevel_postbit(&$post)
{
	global $db;
	
	if(check_is_user())
	{
		$query = $db->simple_select("usertitles", "posts", "", array("order_by" => 'posts'));
		$usertitle_posts = get_usertitle_posts($query);
		// fill $upost whith postnum containing only digits
		$upost = preg_replace('/[^\d.]/', '',$post['postnum']);
		$act_level = get_level($usertitle_posts, (int)$upost);
		if($act_level == -1)
		{
			$act_level = "Maximum";
		}
		$exp = get_experience($usertitle_posts, $act_level, (int)$upost);
		
		$post['groupimage'] .= "Level: $act_level | EXP: $exp%";
	}
}
Thank you for that suggestion!
I had to change one tiny detail to make it work on my board:
/[^\d.]/
to
/[^\d,]/
since my board uses the period as a thousand separator and the comma as a decimal separator (German conventional style).
In fact, as the post number is an integer, you can simply use:
/[^\d]/
It works now.♥ (and didn't with the period)

Now I'm trying to find out how to make it appear on the user profiles as well.... I know I overlooked something somewhere ...
Pages: 1 2