Chuckster Posted July 15, 2010 Posted July 15, 2010 Is there a WORKING free lottery mod? Ive tried a few, but most of them ave bugs.... Post here the link to a free working lottery :) Quote
Jordan Palmer Posted July 15, 2010 Posted July 15, 2010 Use the search feature, Work's great.. And this is in the wrong section.. Moved to requests Quote
ddgamedesign Posted July 15, 2010 Posted July 15, 2010 Hey there, This is a mod of a Lottery mod posted awhile back, and it worked perfectly in my game with no bugs. Many of the free ones on here, I had the same issue: they either didn't credit users, or had some type of bug or another. Winner is selected weekly, and the cost per ticket and max tickets allowed can changed at the top ($cost and $tick). lottery.php: <?php include "globals.php"; switch($_GET['action']) { case 'buysub': buy_sub(); break; default: index(); break; } function index() { global $db,$ir,$userid; $cost = 50; $tick = 5; $sql = sprintf("SELECT * FROM `lottery`"); $query = $db->query($sql); $row = $db->fetch_row($query); echo sprintf(" <center>[img=lottery.jpg]</center> <font color = 'black' size = '3' /><b /> You currently have %d tickets and are able to purchase up to %d tickets per week. Each ticket costs $%d. The jackpot is $%u.", $ir['lottery'], $tick, $cost, $row['jackpot']); echo " <form action = 'lottery.php?action=buysub' method = 'post' /> <input type = 'text' name = 'buysub' value = '1' /> <input type = 'submit' value = 'Buy Tickets' /> </form>"; } function buy_sub() { global $db,$ir,$userid; $_POST['buysub'] = abs((int) $_POST['buysub']); $cost = 50; $price = $cost * $_POST['buysub']; if($_POST['buysub'] > 5) { die("You can't buy more than 5 lottery tickets. <a href = 'index.php' />Go Home</a>"); } if($ir['lottery'] >= 5) { die("You have already purchased 5 tickets this week. <a href = 'index.php' />Go Home</a>"); } if($_POST['buysub'] + $ir['lottery'] > 5) { die("You can't buy this many tickets because you would exceed the maximum amount of allowed tickets. <a href = 'index.php' />Go Home</a>"); } if($ir['money'] < $price) { die("You don't have enough money to buy {$_POST['buysub']} tickets. <a href = 'index.php' />Go Home</a>"); } else { print "You have bought {$_POST['buysub']} lottery tickets. <a href = 'index.php' />Go Home</a>"; $sql = sprintf("UPDATE `users` SET `lottery` = `lottery` + '%d', `money` = `money` - '%d' WHERE `userid` = ('%u')", $_POST['buysub'], $price, $userid); $db->query($sql); $sql1 = sprintf("INSERT INTO `lottery` (id,userid, amount) VALUES (%d,%u, %d)", '',$userid, $price); $db->query($sql1); $sql2 = sprintf("UPDATE `lottery` SET `jackpot` = `jackpot` + '%d'", $price); $db->query($sql2); } } $h->endpage(); ?> Change text, etc as desired of course. I inserted a pic at the top of mine, you can change it just text if you like. Insert this into your cron_weekly.php: $sql = $db->query("SELECT * FROM `lottery`"); $rows = $db->num_rows($sql); $row = $db->fetch_row($sql); $winner = rand(1,$rows); $winnerq = sprintf("SELECT `userid` FROM `lottery` WHERE `id` = %d", $winner); $winnerq1 = $db->query($winnerq); $user = $db->fetch_row($winnerq1); $credit = sprintf("UPDATE `users` SET `money` = `money` + %d WHERE `userid` = (%u)", $row['jackpot'], $user['userid']); $db->query($credit); event_add($user['userid'],"You won the MegaCorp lottery and were credited \${$row['jackpot']}",$c); $db->query("UPDATE `users` SET `lottery` = 0"); $db->query("TRUNCATE TABLE `lottery`"); Quote
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.