PDA

View Full Version : How to calculate?


DanTHEGREAT
04-25-2011, 11:10 AM
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
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

<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
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?

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

kh99
04-25-2011, 09:10 PM
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.