here is a mod that i have converted from 'Budget streets' mod, this could probably be modified to be more elegant..
create a new line in users table called 'gamegoes' as an integer and set your day cron to update by one
<?php
//Budget streets mod made into a lucky dip mod.. hehe
//Author: on_fire (and a bit from veteran)
//Converted for Lite by Dabomstew (and veteran)
session_start();
require "global_func.php";
if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
require "header.php";
$h = new headers;
$h->startheaders();
include "mysql.php";
global $c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);
$lv=date('F j, Y, g:i a',$ir['laston']);
$h->userdata($ir,$lv,$fm);
$h->menuarea();
if($ir['hospital'])
{
die ("ErrorWhat are you doing out of hospital!! go back and rest. What are you thinking??.");
}
if($ir['jail'])
{
die ("ErrorWhat are you doing your in prison!!. What are you thinking??.");
}
print "
";
$cost=($ir[level]*100); // cost of lucky dip
if ($_GET['action'] != 'explore') {
print "You have only 1 chance each day on the lucky dip, it will cost you £$cost
You have {$ir['gamegoes']} turns left for today and will be topped up to 1 at midnight.
";
print "
";
} else {
$steps=abs((int) $_POST['gamegoes']);
for($i=0;$i<$steps;$i++)
{
if ($ir['gamegoes'] < 1) {
print("You only have one go per day for the lucky dip. come back another day
");
}
if ($ir['money'] < $cost+1) {
print("You don't have the funds to play
");
}else{
$chance = rand(1,10); //total of random chances
mysql_query("update users set gamegoes=gamegoes-1 where userid=$userid",$c);
mysql_query("update users set money=money-$cost where userid=$userid",$c);
if ($chance == 1) { //random money
$gained=rand(300,400)*$ir['level'];
print "You have won [b]£$gained[/b]
";
mysql_query("update users set money=money+$gained where userid=$userid",$c);
}
if ($chance == 2) { //random money
$gain = rand(90,150)*(floor($ir['level']/2)+1);
print "You have won [b]£$gain[/b].
";
mysql_query("update users set money=money+$gain where userid=$userid",$c);
}
if ($chance == 3) { //random money
$gain = rand(200,250)*(floor($ir['level']/2)+1);
print "You have won [b]£$gain[/b].
";
mysql_query("update users set money=money+$gain where userid=$userid",$c);
}
if ($chance == 4) { //random item amount
$gain = rand(1,5);
print "You have won [b]$gain[/b] Red Ball(s) ";
mysql_query("INSERT INTO inventory VALUES('',1,$userid,$gain)",$c);
}
if ($chance == 5) { //random item amount
$gain = rand(4,9);
print "You have won [b]$gain[/b] crystals.";
mysql_query("update users set crystals=crystals+$gain where userid=$userid",$c);
}
if ($chance == 6) { //random item amount
$gain = rand(1,5);
print "You have won [b]$gain[/b] morphine(s)";
$itemidexplore = 10;
mysql_query("INSERT INTO inventory VALUES('',$itemidexplore,$userid,$gain)",$c);
print"
";
}
if ($chance == 7) {//random item amount
$gain = rand(1,5);
print "You have won [b]$gain[/b] co proxamol(s)";
mysql_query("INSERT INTO inventory VALUES('',18,$userid,$gain)",$c);
}
if ($chance == 8) { //random money
$gained=rand(200,250)*$ir['level'];
print "You have won [b]£$gained[/b]
";
mysql_query("update users set money=money+$gained where userid=$userid",$c);
}
if ($chance == 9) {//random items i have used the first 26 items in the inventory
$gain = rand(1,26);
$q=mysql_query("SELECT i.*,it.* FROM items i LEFT JOIN itemtypes it ON i.itmtype=itmtypeid WHERE i.itmid=$gain LIMIT 1",$c);
$t=mysql_fetch_array($q);
print "You have won a/an {$t['itmname']}";
mysql_query("INSERT INTO inventory VALUES('',$gain,$userid,1)",$c);
}
if ($chance == 10) {//random dontator days
$gain = rand(1,5);
print "You have won [b]$gain[/b] donator days!!!!
";
mysql_query("update users set donator=donator+$gain where userid=$userid",$c);
}
}
}
if($ir['gamegoes']==0)
{
print "Sorry, you only have one go each day!
";
}
}
$h->endpage;
?>
you will have to change £ to $