Samurai Legend Posted May 20, 2014 Share Posted May 20, 2014 Screen Shots - [ATTACH=CONFIG]1472[/ATTACH] [ATTACH=CONFIG]1473[/ATTACH] [ATTACH=CONFIG]1474[/ATTACH] SQLs - You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Call this file raffle.php - You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Make a daily cron - You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. [ATTACH=CONFIG]1475[/ATTACH] There you go and your done. Raffle.zip Quote Link to comment Share on other sites More sharing options...
Raven1992 Posted May 20, 2014 Share Posted May 20, 2014 nice mod +1 i test it out later Quote Link to comment Share on other sites More sharing options...
Samurai Legend Posted May 20, 2014 Author Share Posted May 20, 2014 Thank you very much :D Quote Link to comment Share on other sites More sharing options...
Reecey12345 Posted May 20, 2014 Share Posted May 20, 2014 Nice work Samurai! +1 Quote Link to comment Share on other sites More sharing options...
Raven1992 Posted May 20, 2014 Share Posted May 20, 2014 for the daily cron do we stick it anywhere in the daily cron itself and how do i change the prize money to my liking Quote Link to comment Share on other sites More sharing options...
NonStopCoding Posted May 20, 2014 Share Posted May 20, 2014 you can edit it into the daily cron or link a new cron job but i don't see it doing much harm linking it to a separate cron job Quote Link to comment Share on other sites More sharing options...
NonStopCoding Posted May 20, 2014 Share Posted May 20, 2014 EDIT: haha never mind i am blind Quote Link to comment Share on other sites More sharing options...
Samurai Legend Posted May 20, 2014 Author Share Posted May 20, 2014 [MENTION=68736]Raven1992[/MENTION] - Or just add this bit to your cron_day.php - You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. To change the prizes to your likings. Go to your database find the table "settings" Edit - payment-one_raffle payment-two_raffle payment-three_raffle However when someone buys a ticket. It gives a bigger reward. Quote Link to comment Share on other sites More sharing options...
Markku Posted May 20, 2014 Share Posted May 20, 2014 Nice modification, Well done with it buddy! After testing though, I noticed that 1 player can come in at more than 1 place. Example: Congrats, You won the 1st prize! - Congrats, You won the 2nd prize! (In 1 raffle - So you can be the winner and the second place winner so on.) Just thought I'd point that out ^_^ Other than that, Great mod! :) Keep up the good work! Quote Link to comment Share on other sites More sharing options...
Samurai Legend Posted May 20, 2014 Author Share Posted May 20, 2014 [MENTION=70359]Markku[/MENTION] - Thanks so much buddy! I have realised that to. I'll update my post as soon as I am home. Quote Link to comment Share on other sites More sharing options...
Raven1992 Posted May 20, 2014 Share Posted May 20, 2014 i can't see where the edit payment raffle is cause it not showing up on my phpmyadmin Quote Link to comment Share on other sites More sharing options...
Markku Posted May 20, 2014 Share Posted May 20, 2014 i can't see where the edit payment raffle is cause it not showing up on my phpmyadmin Look in your "settings" table. Quote Link to comment Share on other sites More sharing options...
Raven1992 Posted May 20, 2014 Share Posted May 20, 2014 Look in your "settings" table. i have but i dunno where to change the prize money to Quote Link to comment Share on other sites More sharing options...
Markku Posted May 20, 2014 Share Posted May 20, 2014 i have but i dunno where to change the prize money to You should have in your settings table: payment-one_raffle 333 payment-two_raffle 222 payment-three_raffle 111 Change the 333,222,111? Quote Link to comment Share on other sites More sharing options...
Raven1992 Posted May 20, 2014 Share Posted May 20, 2014 oh right thanks lol i still a noob on this Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted May 20, 2014 Share Posted May 20, 2014 Not bad but you should make this a bit more easily customizable. For example a setting for what the tickets are called. What if I want to call them something other than tickets? Or a setting to set the price of each ticket? And why not allow for the players to have a form to purchase tickets in bulk with a setting for the maximum amount of tickets they can purchase? Quote Link to comment Share on other sites More sharing options...
NonStopCoding Posted May 21, 2014 Share Posted May 21, 2014 You might need something like You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Quote Link to comment Share on other sites More sharing options...
SRB Posted May 21, 2014 Share Posted May 21, 2014 First thing; RAND() at mysql level is pretty heavy on the resources. Second thing; Why can't I win twice? If I buy 2 tickets in the lottery and both win with 3 numbers, I am entitled to both! Third; I'd do it at PHP level, since you can manipulate the data and create the winners pretty easily (And you can edit to just 1 prize per person easily too) You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. That renders $winners[0] as first prize, $winners[1] as second and $winners[2] as third. Much easier to then issue events and whatnot. To limit the wins to once per player, add a group by in the clause - simples. You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. to You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. As always, untested. Any problems, post here and somebody may help. Quote Link to comment Share on other sites More sharing options...
wrux Posted May 21, 2014 Share Posted May 21, 2014 First thing; RAND() at mysql level is pretty heavy on the resources. Second thing; Why can't I win twice? If I buy 2 tickets in the lottery and both win with 3 numbers, I am entitled to both! Third; I'd do it at PHP level, since you can manipulate the data and create the winners pretty easily (And you can edit to just 1 prize per person easily too) You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. That renders $winners[0] as first prize, $winners[1] as second and $winners[2] as third. Much easier to then issue events and whatnot. To limit the wins to once per player, add a group by in the clause - simples. You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. to You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. As always, untested. Any problems, post here and somebody may help. What MySQL's RAND is CPU intensive and iterating through potentially millions of records isn't? Also, wouldn't shuffle give a random order? Theres no reason to then do some sort of awkward split; $first[0], $second[1] and $third[2] is fine. Theres no need to over-complicate things. Quote Link to comment Share on other sites More sharing options...
Dominion Posted May 21, 2014 Share Posted May 21, 2014 What MySQL's RAND is CPU intensive and iterating through potentially millions of records isn't? Do some tests with about 1000. Quote Link to comment Share on other sites More sharing options...
wrux Posted May 21, 2014 Share Posted May 21, 2014 If it's slow then just do it differently.... SELECT MAX(`id`) as `max_id` FROM `lottery`; Use that to generate three numbers.... (self explanatory) and then just select them IDs. SELECT * FROM `lottery` WHERE `id` IN (X1, X2, X3); X1 X2 & X3 of course being the three random ID's. This way no iterations are being done, just two queries with not much going on, just logic. Quote Link to comment Share on other sites More sharing options...
SRB Posted May 21, 2014 Share Posted May 21, 2014 What MySQL's RAND is CPU intensive and iterating through potentially millions of records isn't? Also, wouldn't shuffle give a random order? Theres no reason to then do some sort of awkward split; $first[0], $second[1] and $third[2] is fine. Theres no need to over-complicate things. You are kind of getting it, I guess. We all (meaning a few people) know that random factors are not all that random. Shuffle shuffles the deck of data - then to add more randomness, you select a place in the shuffles array to select from. In theory, this could be done quicker too, but I'm unsure on what resources would be used and you'd have to, in theory, query twice... But this is an option... Pull all rows in a query and get the count, then just randomly split it somewhere and use LiMiT xx, 3 in the secondary query. If there was no use in "over complicating" things, half the functions within the manual wouldn't exist as there are simpler methods to most things ;) Quote Link to comment Share on other sites More sharing options...
dnenb Posted May 23, 2014 Share Posted May 23, 2014 If your point is that random number generators aren't really random then it won't help anything to do it twice (shuffle->random). Keep it simple and use rand(). Most mccode games doesn't have the userbase to make server load a big issue anyway. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.