Jump to content

Scratch Tickets


Monkuar

Recommended Posts

I need to use the rand function but how would I go about incorporating into let's say..

 

somone spends some (Forum gold) on my site, (you get these golds from posting)

 

Somone buys a Scratch Ticket and it will give them 1-200 forum Gold (random chance) how would I go about doing that with the rand function?

 

Also, could there be something I add like a % value that it will be less then 200 inside the 1-200 phase? Kinda confusing, but pretty much can I say 50% of users will get less then 50 Forum Gold from the 1-200FG Chance Ticket?

Pretty much adding a % modifier with the rand function so people don't get essentially "Free" forum gold, that there is a 20% of actually getting 100-200 AMOUNT, and 80% of actually getting less then 100?

 

Any idea?

 

i know how to code it with mysql/php I just need somone to lift me up right now and get a little boost of code/help to get me started and a explanation

Link to comment
https://forums.phpfreaks.com/topic/255652-scratch-tickets/
Share on other sites

Something like this is what comes to mind. This would end up with roughly a 20% chance of having a chance of getting an amount from 100 to 200. There's probably a better way, but it's late, and I'm tired.

Link to comment
https://forums.phpfreaks.com/topic/255652-scratch-tickets/#findComment-1310548
Share on other sites

So tired I forgot to paste in the code, apparently. :P

 

But anyhow, I had a flaw in it. This would give about a 50/50 shot at the ensuing 50/50 shot of getting 100+ points. Overall should be about a 25% probability of getting 100+.

 

$max = array_rand( array_flip(array(99,200)) );
$rand = mt_rand(1, $max);
echo $rand;

Link to comment
https://forums.phpfreaks.com/topic/255652-scratch-tickets/#findComment-1310549
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.