Ici c'est pour vous faire une loterie: (Source: Mixxis) Créé ce fichier puis le mettre a la racine: loterie.php <?php
// ----------------------------------------------------------------------------------------------------------- // Loteria creado por SainT // loteria.php // http://www.ogame.ciberpaxi.es // -----------------------------------------------------------------------------------------------------------
define('INSIDE' , true); define('INSTALL' , false);
$xnova_root_path = './'; include($xnova_root_path . 'extension.inc'); include($xnova_root_path . 'common.' . $phpEx);
$Tiempo = time(); $loteria = gettemplate('loterie_off'); if($Tiempo < $game_config['Loterie']) { $Falta = $game_config['Loterie']-$Tiempo; $parse['usuarios'] = "Il reste ".$Falta." secondes avant la prochaine loterie... Patience !!!"; $lote = parsetemplate( $loteria, $parse); display ($lote, "Loterie", false, '', true); } else {
$resto = $Tiempo - $game_config['Actualisation']; $loteria = gettemplate('loterie_body'); $tiempolote = 3600; //temps entre deux loteries (secondes) $maxtickets = 250; //nombre de tickets $canxticketm = 100000; //prix d'un ticket en métal $canxticketc = 50000; //prix d'un ticket en cristal $canxticketd = 20000; //prix d'un ticket en deutérium
$totaltickets = doquery ("SELECT sum(tickets) as total_tickets FROM {{table}} ",'loterie'); $CantidadTickets = mysql_fetch_array($totaltickets); $parse['Cantidad'] = $CantidadTickets['total_tickets']; $parse['Cantidadf'] = $maxtickets-$CantidadTickets['total_tickets']; $parse['Cantidadt'] = $maxtickets; $parse['Cantidadm'] = pretty_number($canxticketm); $parse['Cantidadc'] = pretty_number($canxticketc); $parse['Cantidadd'] = pretty_number($canxticketd);
$TusTickets2 = doquery ("SELECT * FROM {{table}} WHERE `user` = '".$user['username']."' ",'loterie'); $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']*$canxticketml; $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'>Il n'y a plus assez de tickets pour en acheter autant !</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", "loterie"); } else { doquery("INSERT INTO {{table}} SET `ID`='".$user['id']."', `user`='".$user['username']."', `tickets`='".$_POST['Tickets']."' ", "loterie"); }
$parse['MensajeCompra'] = "<font color='#00FF00'>Vous avez acheté ".$_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()", "loterie"); $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); //gains en métal $ecristal = $DatosPlaneta['crystal']+($canxticketc*$maxtickets); //gains en cristal $edeuterio = $DatosPlaneta['deuterium']+($canxticketd*$maxtickets); //gains en deutérium doquery("UPDATE {{table}} SET `metal`='".$emetal."', `crystal`='".$ecristal."', `deuterium`='".$edeuterio."' WHERE `id`='".$ganadp."' limit 1", "planets"); $dando = doquery("SELECT * FROM {{table}}", "loterie"); $Time = time(); $From = "<font color="". $kolor ."">Loteries</font>"; $Subject = "<font color="". $kolor ."">Résultats de la loterie</font>"; $summery=0; while ($uzer = mysql_fetch_array($dando)) { if($ganad == $uzer['ID']) { $Message = "<font color='#00ff00'>Félicitations !!! Tu as le Ticket gagnant de la loterie ! Nous espérons te revoir bientôt !</font>"; } //Message en cas de gain else { $Message = "<font color='#FF0000'> Tu n'as pas acheté le Ticket gagnant, Nous espérons te revoir bientôt !</font>"; } //Message en cas de perte SendSimpleMessage ( $uzer['ID'], $uzer['ID'], $Time, 1, $From, $Subject, $Message); } doquery ("DELETE FROM {{table}} ",'loterie'); $sigueintelore = $tiempolote + time(); doquery("UPDATE {{table}} SET `config_value`='".$sigueintelore."' WHERE `config_name`='Loterie' limit 1", "config"); } } else { $parse['MensajeCompra'] = "<font color='#FF0000'>Tu n'as pas assez de ressources !</font>"; } } $pase['usuarios'] = "Autres joueurs"; if($CantidadTickets == $maxtickets) { $parse['color'] = "red"; } else { $parse['color'] = "green"; } $usuarios = doquery("SELECT * FROM {{table}} order by tickets", "loterie"); while ($listad = mysql_fetch_array($usuarios)) { $parse['usuarios'] .= "".$listad['user']." possède ".$listad['tickets']." Ticket(s)<br/>"; }
$lote = parsetemplate( $loteria, $parse); display ($lote, "Loterie", false, '', true); } // ----------------------------------------------------------------------------------------------------------- // Loteria creado por SainT // http://www.ogame.ciberpaxi.es // -----------------------------------------------------------------------------------------------------------
?> ======================================================================================================== Maintenant créé ces fichier et les mettre dans /templates/OpenGame  : loterie_body.tpl <br></br> <br></br> <br></br> <table width="519"> <tr> <td class="c" colspan="4">Loterie</td> </tr> <tr> <th>Vous avez besoin de ressources? Profitez de la loterie pour récupérer des ressources! La loterie est comme le loto, vous gagnez le prix de la totalité des billets si vous gagnez. Il n'y a qu'un seul gagnant! (Il y a 1 heure d'attente entre chaque loterie)</th> <th>Il reste <font color="{color}">{Cantidadf}</font> Tickets à acheter ! <font color="{color}">{Cantidad}/{Cantidadt}</font></th> <th><b><u>Prix du Ticket: </u></b> <br><font color="yellow">Quantité de Métal : </font>{Cantidadm}</br> <font color="yellow">Quantité de Cristal : </font>{Cantidadc} <br><font color="yellow">Quantité de Deutérium :</font>{Cantidadm}</br> </th> </tr> <tr> <td class="c" colspan="4">Tickets de Loterie</td> </tr> <tr> <th class="c" colspan="2">
<form method="POST" action="loterie.php?cp=compra"> <select size="1" name="Tickets"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="20">20</option> <option value="30">30</option> <option value="40">40</option> <option value="50">50</option> <option value="60">60</option> <option value="70">70</option> <option value="80">80</option> <option value="90">90</option> <option value="100">100</option> <option value="200">200</option> </select> <input type="submit" value="Acheter" name="compra"> </form> </th> <th>Tu possède <font color="yellow">{tustickets}</font> tickets.
</tr> <tr> <td class="c" colspan="4">{MensajeCompra}</td> </tr> <tr> <th class="c" colspan="4"></th> </tr> <tr> <td class="c" colspan="4">Joueurs possedant des Tickets :</td> </tr> <tralign="left"> <th class="c" colspan="4" >- {usuarios}</th> </tr>
</body> </html> ________________________________________________________________________________________________________ loterie_off.tpl <br></br> <br></br> <br></br> <br></br> <br></br>
<table width="519"> <tr> <td class="c" colspan="3">Loterie</td> </tr>
<tr> <th class="c" colspan="3">{usuarios}</th> </tr>
</body> </html> ======================================================================================================== Après ouvrir templates/OpenGame/left_menu.tpl Et y inserer ce code : <tr> <td colspan="2"><a href="loterie.php" accesskey="3" target="{mf}">Loterie</a></td> </tr>
( vous pouvez le mettre ou vous voulez, tous dépend la position que vous voulez) ======================================================================================================== Et pour finir le SQL: CREATE TABLE `game_loterie` ( `ID` int(11) NOT NULL, `user` varchar(255) collate latin1_swedish_ci NOT NULL, `tickets` int(5) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; INSERT INTO `game_config` VALUES ('Loterie', '1214689842')
ET voila votre loterie est faite !!! |