vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Forum and Server Management (https://vborg.vbsupport.ru/forumdisplay.php?f=232)
-   -   How to calculate? (https://vborg.vbsupport.ru/showthread.php?t=262611)

DanTHEGREAT 04-25-2011 11:10 AM

How to calculate?
 
I basically want under my postbit template to say

Posts: X
Raffle Tickets: X (number)

But in order to get that number, I want it to calculate Raffle Tickets by posts / 20

How would I go about doing this?

Sorry, I'm a programmer and this seems really easy to make in C++ or Java but not sure with php and html.

Thanks

Lynne 04-25-2011 04:31 PM

What are Raffle Tickets? They are not a default vbulltin thing. You should ask this question in the modification thread where you downloaded the modification.

DanTHEGREAT 04-25-2011 04:43 PM

Its not a modification. Every 20 posts a member makes creates 1 raffle ticket SO,

the equation is:

Raffle = Posts / 20 (truncate decimal)

EXAMPLE:
Raffle = 40 / 20
Raffle= 2.

Display:
Posts: 40
Raffles: 2

Zachery 04-25-2011 04:51 PM

Do raffle tickets go away at any point?

Artistichaven 04-25-2011 06:58 PM

That doesn't make sense. Let's say we have 3 users. A, B, and C. A has 20 posts and thus one raffle ticket. B has 10 posts and no raffle tickets. C has 15 posts and no raffle tickets.

Total posts = 45
Total raffle tickets = 1

if (totalPosts%20 > 9)
(posts/20) - 1 = 2 (rounded)
else
posts/20 = 2 (rounded)
^Still inaccurate according to my above example.

2 != 1

Also, go into your statistics template and get the variable. ($totalposts)

kh99 04-25-2011 07:38 PM

Quote:

Originally Posted by DanTHEGREAT (Post 2188525)
Its not a modification. Every 20 posts a member makes creates 1 raffle ticket SO, ...

You don't say if you're using vb3 or vb4, but in vb3 although you can't put php in a template, you can cheat by using the side-effect of a condition, like

Code:

<if condition="$post['tickets'] = (int)($post['posts'] / 20)"></if>
Total raffle tickets = $post[tickets]

The same thing might work in vb4 with the appropriate tags, I don't know - or maybe there's a better way to do it in vb4.

Boofo 04-25-2011 08:11 PM

Can you use (int) in a template like that?

kh99 04-25-2011 08:27 PM

Quote:

Originally Posted by Boofo (Post 2188612)
Can you use (int) in a template like that?

It seems to work. In fact after I posted this I tried it in vb 4.1.3 and it works there too. I just started working with vb4, I was disappointed to find it didn't work with the vb:math tag - I'm not sure why since there's little documentation in the manual. I guess it doesn't allow parens at all or something.

Boofo 04-25-2011 08:38 PM

Do you mean parenthesis? I use those in conditional for wrapping some conditions and they seem to work fine. Unless I got your meaning wrong.

They use the math in the style vars, though. Not that that would mean anything.

How's this for some screwed up code?

Code:

if ((int)round(abs($postdays)) > 1)

kh99 04-25-2011 09:10 PM

Quote:

Originally Posted by Boofo (Post 2188621)
Do you mean parenthesis?

Yeah, I'm just lazy. :) I meant they don't seem to work in the vb:math tag. But I'm probaby like, what, a year and a half behind everyone else figuring that out.


All times are GMT. The time now is 02:49 AM.

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.00965 seconds
  • Memory Usage 1,731KB
  • 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
  • (2)bbcode_code_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete