Hi, i found on the internet on interesting feature. Lotery ticket. i added to my ogame and it is working fine, but it only make desapear my resources, it does not give the winner nothing, only a message that he/her wins
I want to add the lottery a feature, when someone wins the ticket, it gives DarkMatter, i think that is the camp rpg_points in the users table. But i am not a coder, i am a systems guy, with does some coding... lol
Can someone help me with this?
The code, of the Lottery tickets system is this:
PHP Code:
<?php
define('INSIDE' , true);
define('INSTALL' , false);
$ugamela_root_path = './';
include($ugamela_root_path . 'extension.inc');
include($ugamela_root_path . 'common.' . $phpEx);
$Tiempo = time();
$loteria = gettemplate('lotery_off');
if($Tiempo < $game_config['lotery']) {
$Falta = $game_config['lotery']-$Tiempo;
$parse['usuarios'] = "It remains ".$Falta." seconds before the next lotery... Please wait !!!";
$lote = parsetemplate( $loteria, $parse);
display ($lote, "lotery", false, '', true);
} else {
$resto = $Tiempo - $game_config['Refresh'];
$loteria = gettemplate('lotery_body');
$tiempolote = 63600;
$maxtickets = 100;
$canxticketm = 250000;
$canxticketc = 250000;
$canxticketd = 250000;
$totaltickets = doquery ("SELECT sum(tickets) as total_tickets FROM {{table}} ",'lotery');
$CantidadTickets = mysql_fetch_array($totaltickets);
$parse['Cantidad'] = $CantidadTickets['total_tickets'];
$parse['Cantidadf'] = $maxtickets-$CantidadTickets['total_tickets'];
$parse['Cantidadt'] = $maxtickets;
$parse['Cantidadm'] = $canxticketm;
$parse['Cantidadc'] = $canxticketc;
$parse['Cantidadd'] = $canxticketd;
$TusTickets2 = doquery ("SELECT * FROM {{table}} WHERE `user` = '".$user['username']."' ",'lotery');
$TusTicket3 = mysql_fetch_array($TusTickets2);
$TusTickets=$TusTicket3['tickets'];
if($TusTickets != NULL) {
$parse['tustickets'] = $TusTickets;
}
else {
$parse['tustickets'] = 0;
}
if($_GET['cp'] == "compra") {
$metal = $_POST['Tickets']*$canxticketm;
$cristal = $_POST['Tickets']*$canxticketc;
$Deuterio = $_POST['Tickets']*$canxticketd;
$complant = doquery("SELECT * FROM {{table}} WHERE `id` = '".$planetrow['id']."' ",'planets');
$DatosPlaneta = mysql_fetch_array($complant);
if ($DatosPlaneta['metal'] >= $metal && $DatosPlaneta['crystal'] >= $cristal && $DatosPlaneta['deuterium'] >= $Deuterio)
{
if ($parse['Cantidadf'] < $_POST['Tickets']) { $parse['MensajeCompra'] = "<font color='#FF0000'>There isn't enough tickets !</font>"; } else {
$smetal = $DatosPlaneta['metal']-$metal;
$scristal = $DatosPlaneta['crystal']-$cristal;
$sdeuterio = $DatosPlaneta['deuterium']-$Deuterio;
doquery("UPDATE {{table}} SET `metal`='".$smetal."', `crystal`='".$scristal."', `deuterium`='".$sdeuterio."' WHERE `id`='".$planetrow['id']."' limit 1", "planets");
if($TusTickets > 0) {
$Suma = $TusTickets+$_POST['Tickets'];
doquery("UPDATE {{table}} SET `tickets`='".$Suma."' WHERE `user`='{$user['username']}' limit 1", "lotery");
} else { doquery("INSERT INTO {{table}} SET `ID`='".$user['id']."', `user`='".$user['username']."', `tickets`='".$_POST['Tickets']."' ", "lotery"); }
$parse['MensajeCompra'] = "<font color='#00FF00'>Just buy".$_POST['Tickets']." Tickets</font>";
?> <META HTTP-EQUIV='Refresh' CONTENT="0; URL='overview.php'> <?
}
if(($_POST['Tickets']+$CantidadTickets['total_tickets']) == $maxtickets) {
$ganador = doquery("SELECT * FROM {{table}} order by rand()", "lotery");
$elganador = mysql_fetch_array($ganador);
$ganad = $elganador['ID'];
$userio = doquery("SELECT * FROM {{table}} WHERE `id` = '".$ganad."' limit 1",'users');
$Datoswiner = mysql_fetch_array($userio);
$ganadp = $Datoswiner['id_planet'];
$complant = doquery("SELECT * FROM {{table}} WHERE `id_owner` = '".$ganad."' limit 1",'planets');
$DatosPlaneta = mysql_fetch_array($complant);
$emetal = $DatosPlaneta['metal']+($canxticketm*$maxtickets);
$ecristal = $DatosPlaneta['crystal']+($canxticketc*$maxtickets);
$edeuterio = $DatosPlaneta['deuterium']+($canxticketd*$maxtickets);
doquery("UPDATE {{table}} SET `metal`='".$emetal."', `crystal`='".$ecristal."', `deuterium`='".$edeuterio."' WHERE `id`='".$ganadp."' limit 1", "planets");
$dando = doquery("SELECT * FROM {{table}}", "lotery");
$Time = time();
$From = "<font color=\"". $kolor ."\">Loteries</font>";
$Subject = "<font color=\"". $kolor ."\">Result of lotery</font>";
$summery=0;
while ($uzer = mysql_fetch_array($dando)) {
if($ganad == $uzer['ID']) { $Message = "<font color='#00ff00'>Congratulations !!!
You have the winning ticket !
We hope see you soon !</font>"; } //Message en cas de gain
else { $Message = "<font color='#FF0000'>
You haven't winning ticket,
We hope see you soon !</font>"; } //Message en cas de perte
SendSimpleMessage ( $uzer['ID'], $uzer['ID'], $Time, 1, $From, $Subject, $Message);
}
doquery ("DELETE FROM {{table}} ",'lotery');
$sigueintelore = $tiempolote + time();
doquery("UPDATE {{table}} SET `config_value`='".$sigueintelore."' WHERE `config_name`='lotery' limit 1", "config");
}
} else { $parse['MensajeCompra'] = "<font color='#FF0000'>You haven't enough resources !</font>"; }
}
$pase['usuarios'] = "Autres joueurs";
if($CantidadTickets == $maxtickets) { $parse['color'] = "red"; } else { $parse['color'] = "green"; }
$usuarios = doquery("SELECT * FROM {{table}} order by tickets", "lotery");
while ($listad = mysql_fetch_array($usuarios)) {
$parse['usuarios'] .= "".$listad['user']." has ".$listad['tickets']." Ticket(s)<br/>";
}
$lote = parsetemplate( $loteria, $parse);
display ($lote, "lotery", false, '', true);
}
?