vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Based on Post Count (https://vborg.vbsupport.ru/showthread.php?t=295370)

Justin M 02-21-2013 10:40 PM

Based on Post Count
 
I'm wanting to create a template edit on my sports forum for "MLB ERA" - The more the member posts the lower the ERA goes down.

If you do not know what MLB ERA is:
http://www.ehow.com/how_9733_calculate-earned-run.html

What would I need to do to accomplish this?

kh99 02-22-2013 03:30 PM

It sounds like it's very similar to "posts per day" that this site displays, except lower is better. So I guess you'd have to figure out how you want to calculate that. I suppose you could do something like decide that N or more posts per day is "perfect", then calculate the number of posts per day for a user and subtract from N (although then anyone with N or more posts per day would have an "era" of 0, so maybe you need something like 1/PPD instead?).

As for actually implementing it, you'd probably need a plugin to calculate it. If you only want to display it in the postbit then you could use postbit_display_complete and use the values in $post (which should contain the author's data), and set $post['era'] or something like that.

Justin M 02-22-2013 07:25 PM

Thanks kh99! Seems like a very simple task, but I'm a beginner so I'll need a little help.

Will you help me with the plugin, as I'm not sure.

kh99 02-22-2013 10:24 PM

I think it's probably only a few lines so I could do that, if you can tell me exactly how you want to calculate it. Do you want it to be a "lifetime" value? Hopefully that's OK because it's easy enough to get the time since a user joined and the total posts since they've joined, otherwise it gets more difficult. But one issue with it being a lifetime value is that it of course gets harder and harder to change as time goes on.

Justin M 02-22-2013 10:28 PM

Yes lifetime value is okay - anything that's easy enough for you. Just make it go along with the ERA, the link I posted above. This will be greatly appreciated!

Justin M 02-24-2013 07:11 PM

kh99, I'm not replying to disturb you if you're busy but about long will it take you to get the plugin done? I'm interested in adding this asap. Thanks much!

-Justin

kh99 02-24-2013 07:15 PM

It's OK, it's good to remind me. But I had been hoping you'd specify how you wanted it calculated. The plugin's not an issue, it's figuring out the equation. Like I mentioned above, it doesn't really translate exactly because with era low is good. If you picked a certain number of posts per day or week that you wanted for someone to be "perfect" then a lot of people would probably have 0.00, which I figured you wouldn't want.

I can probably figure out something that works but I need to think about it.

mokujin 02-24-2013 07:19 PM

What does "Earned Run Average" mean in MLB? I'm from Europe and only watch Football :D

Justin M 02-24-2013 07:51 PM

Thanks kh99!

per predictem
Quote:

Add up a pitchers innings. An inning is three outs. If you see 6.1 or 6.2 that means 6.33 or 6.67 innings. Unlike some other baseball stats, we don't round up when we're talking about ERA.

Now add up all the earned runs the pitcher gave up during the innings he's pitched. For arguments sake, lets say he gave up 3 earned runs.

Now multiply the earned runs by 9.

Now divide by the total innings pitched.

Example: A pitcher goes 5 innings and gives up 3 earned runs. We take the earned runs x 9 which gives us 27. We then divide this by the innings pitched 27 divided by 5 = 5.40.
In case you're wondering what the good, bad and the ugly are ERA-wise in the big leagues it could be said that:

An earned run average of 2.00 or lower is an ace and a very sharp pitcher. Anything 3.00 or under is ROCK solid. An ERA of 3.00 to 3.50 is GOOD. Conversely, 4.00 to 5.00 is average and anything above 5.00 a guy is probably struggling to stay in the bigs and is getting hit pretty hard.
If you can figure out how to make the users posts go along with the time registered to show the ERA (I think I'm on the right path), that is pure genius. I'm not that good with equations.

mokujin, ERA or earned run average, is another way of saying "what a pitcher gives up per nine innings that he pitches."

kh99 02-25-2013 05:30 PM

I was hoping mokujin might decide to come up with something. Anyway, it's actually a pretty simple plugin, you just need to create a new plugin using hook postbit_display_complete and code something like:
Code:

if (!$post['posts'])
  $post['era'] = "No Posts Yet";
else
{
  $days = $post['joindateline'] / (3600 * 24); // 3600 * 24 = seconds in a day
  $era = $days / $post['posts'];
  $post['era'] = vb_number_format($era, 2);
}


Then use {vb:raw post.era} in your postbit or postbit_legacy template.

This just uses 1/posts per day so that lower is "better", but I'm kind of guessing that's going to give values for some users that don't look like reasonable ERA values, so you'll probably want some tweaking.


All times are GMT. The time now is 01:14 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00997 seconds
  • Memory Usage 1,739KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete