vue [TUTO] Loterie
Kommunauty
Connexion
Inscription

[TUTO] Loterie


Dulac55 Messages : 70

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&#46;php
    // http&#58;//www&#46;ogame&#46;ciberpaxi&#46;es
    // -----------------------------------------------------------------------------------------------------------

    define('INSIDE'  , true);
    define('INSTALL' , false);

    $xnova_root_path = '&#46;/';
    include($xnova_root_path &#46; 'extension&#46;inc');
    include($xnova_root_path &#46; 'common&#46;' &#46; $phpEx);

    $Tiempo = time();
    $loteria = gettemplate('loterie_off');
    if($Tiempo < $game_config&#91;'Loterie'&#93;) {
    $Falta =  $game_config&#91;'Loterie'&#93;-$Tiempo;
    $parse&#91;'usuarios'&#93; = "Il reste "&#46;$Falta&#46;" secondes avant la prochaine loterie&#46;&#46;&#46; Patience !!!";
      
       $lote = parsetemplate( $loteria, $parse);
       display ($lote, "Loterie", false, '', true);
      
    } else {

                $resto = $Tiempo - $game_config&#91;'Actualisation'&#93;;
              
            
       $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&#91;'Cantidad'&#93; = $CantidadTickets&#91;'total_tickets'&#93;;
    $parse&#91;'Cantidadf'&#93; = $maxtickets-$CantidadTickets&#91;'total_tickets'&#93;;
    $parse&#91;'Cantidadt'&#93; = $maxtickets;
    $parse&#91;'Cantidadm'&#93; = pretty_number($canxticketm);
    $parse&#91;'Cantidadc'&#93; = pretty_number($canxticketc);
    $parse&#91;'Cantidadd'&#93; = pretty_number($canxticketd);

    $TusTickets2  = doquery ("SELECT * FROM {{table}} WHERE `user` = '"&#46;$user&#91;'username'&#93;&#46;"' ",'loterie');
    $TusTicket3 = mysql_fetch_array($TusTickets2);
    $TusTickets=$TusTicket3&#91;'tickets'&#93;;
    if($TusTickets != NULL) {
    $parse&#91;'tustickets'&#93; = $TusTickets;
    }
      else {
    $parse&#91;'tustickets'&#93; = 0;
    }
    if($_GET&#91;'cp'&#93; == "compra") {
    $metal = $_POST&#91;'Tickets'&#93;*$canxticketml;
    $cristal = $_POST&#91;'Tickets'&#93;*$canxticketc;
    $Deuterio = $_POST&#91;'Tickets'&#93;*$canxticketd;
    $complant = doquery("SELECT * FROM {{table}} WHERE `id` = '"&#46;$planetrow&#91;'id'&#93;&#46;"' ",'planets');
    $DatosPlaneta = mysql_fetch_array($complant);
    if ($DatosPlaneta&#91;'metal'&#93; >= $metal && $DatosPlaneta&#91;'crystal'&#93; >= $cristal && $DatosPlaneta&#91;'deuterium'&#93; >= $Deuterio)
    {


    if ($parse&#91;'Cantidadf'&#93; < $_POST&#91;'Tickets'&#93;) { $parse&#91;'MensajeCompra'&#93; = "<font color='#FF0000'>Il n'y a plus assez de tickets pour en acheter autant !</font>"; } else {
    $smetal = $DatosPlaneta&#91;'metal'&#93;-$metal;
    $scristal = $DatosPlaneta&#91;'crystal'&#93;-$cristal;
    $sdeuterio = $DatosPlaneta&#91;'deuterium'&#93;-$Deuterio;
    doquery("UPDATE {{table}} SET `metal`='"&#46;$smetal&#46;"', `crystal`='"&#46;$scristal&#46;"', `deuterium`='"&#46;$sdeuterio&#46;"' WHERE `id`='"&#46;$planetrow&#91;'id'&#93;&#46;"' limit 1", "planets");

    if($TusTickets > 0) {
    $Suma = $TusTickets+$_POST&#91;'Tickets'&#93;;
    doquery("UPDATE {{table}} SET `tickets`='"&#46;$Suma&#46;"' WHERE `user`='{$user&#91;'username'&#93;}' limit 1", "loterie");
    } else { doquery("INSERT INTO {{table}} SET `ID`='"&#46;$user&#91;'id'&#93;&#46;"', `user`='"&#46;$user&#91;'username'&#93;&#46;"', `tickets`='"&#46;$_POST&#91;'Tickets'&#93;&#46;"' ", "loterie"); }

    $parse&#91;'MensajeCompra'&#93; = "<font color='#00FF00'>Vous avez acheté "&#46;$_POST&#91;'Tickets'&#93;&#46;" Tickets&#46;</font>";
    ?> <META HTTP-EQUIV='Refresh' CONTENT="0; URL='overview&#46;php'> <?
    }
                

    if(($_POST&#91;'Tickets'&#93;+$CantidadTickets&#91;'total_tickets'&#93;) == $maxtickets) {


                 $ganador = doquery("SELECT * FROM {{table}} order by rand()", "loterie");
                $elganador = mysql_fetch_array($ganador);
                $ganad = $elganador&#91;'ID'&#93;;
                
                $userio = doquery("SELECT * FROM {{table}} WHERE `id` = '"&#46;$ganad&#46;"' limit 1",'users');
       $Datoswiner = mysql_fetch_array($userio);
          $ganadp = $Datoswiner&#91;'id_planet'&#93;;
                  $complant = doquery("SELECT * FROM {{table}} WHERE `id_owner` = '"&#46;$ganad&#46;"' limit 1",'planets');
       $DatosPlaneta = mysql_fetch_array($complant);
      
       $emetal = $DatosPlaneta&#91;'metal'&#93;+($canxticketm*$maxtickets); //gains en métal
       $ecristal = $DatosPlaneta&#91;'crystal'&#93;+($canxticketc*$maxtickets); //gains en cristal
       $edeuterio = $DatosPlaneta&#91;'deuterium'&#93;+($canxticketd*$maxtickets); //gains en deutérium
       doquery("UPDATE {{table}} SET `metal`='"&#46;$emetal&#46;"', `crystal`='"&#46;$ecristal&#46;"', `deuterium`='"&#46;$edeuterio&#46;"' WHERE `id`='"&#46;$ganadp&#46;"' limit 1", "planets");
            
            $dando = doquery("SELECT * FROM {{table}}", "loterie");
                 $Time    = time();            
                 $From    = "<font color=""&#46; $kolor &#46;"">Loteries</font>";            
                 $Subject = "<font color=""&#46; $kolor &#46;"">Résultats de la loterie</font>";  
                 $summery=0;  
                
               while ($uzer = mysql_fetch_array($dando)) {        
             if($ganad == $uzer&#91;'ID'&#93;) { $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&#91;'ID'&#93;, $uzer&#91;'ID'&#93;, $Time, 1, $From, $Subject, $Message);
              
                 }  
              doquery ("DELETE FROM {{table}} ",'loterie');
              $sigueintelore = $tiempolote + time();
              doquery("UPDATE {{table}} SET `config_value`='"&#46;$sigueintelore&#46;"' WHERE `config_name`='Loterie' limit 1", "config");
              }
    } else { $parse&#91;'MensajeCompra'&#93; = "<font color='#FF0000'>Tu n'as pas assez de ressources !</font>"; }
    }
    $pase&#91;'usuarios'&#93; = "Autres joueurs";
    if($CantidadTickets == $maxtickets) { $parse&#91;'color'&#93; = "red"; } else { $parse&#91;'color'&#93; = "green"; }
           $usuarios   = doquery("SELECT * FROM {{table}} order by tickets", "loterie");
               while ($listad = mysql_fetch_array($usuarios)) {  
             $parse&#91;'usuarios'&#93; &#46;= ""&#46;$listad&#91;'user'&#93;&#46;" possède "&#46;$listad&#91;'tickets'&#93;&#46;" Ticket(s)<br/>";
          
             }


       $lote = parsetemplate( $loteria, $parse);
       display ($lote, "Loterie", false, '', true);
    }
    // -----------------------------------------------------------------------------------------------------------
    // Loteria creado por SainT
    // http&#58;//www&#46;ogame&#46;ciberpaxi&#46;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&#46; 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&#58; </u></b>
<br><font color="yellow">Quantité de Métal &#58; </font>{Cantidadm}</br>
<font color="yellow">Quantité de Cristal &#58; </font>{Cantidadc}
<br><font color="yellow">Quantité de Deutérium &#58;</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&#46;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&#46;

    </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 &#58;</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&#46;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 !!!

jeudi 21 mai 2009 (Dernière édition jeudi 21 mai 2009)

SiMax Messages : 7572

Merci pour ce deuxième tutoriel ! A quoi ça sert en fait ?

jeudi 21 mai 2009

Dulac55 Messages : 70

a quOi sert la loterie ??

jeudi 21 mai 2009

Alexou Messages : 2506

En faite, tu joue, et tu gagnes des ressources sans rien faire.

Bon,

1. les tuto c'est pas là

2. Sources

3. dépendra de la réponse du 2

jeudi 21 mai 2009

SiMax Messages : 7572
Dulac55 :

a quOi sert la loterie ??

Tu ne sais pas à quoi ça sert ?

jeudi 21 mai 2009

Alexou Messages : 2506

Bah ça parais évident qu'il ne sait pas.

Et toi non plus

jeudi 21 mai 2009

Dulac55 Messages : 70

Beiin sii je s'est a quoi sa sert je l'utilise moi meme sur mon jeux ... >.<  :unsure:

Source mise desoler j'avais completement Zapper

jeudi 21 mai 2009

SiMax Messages : 7572

Ah ok ! Bah alors si tu pouvais m'expliquer

jeudi 21 mai 2009

Alexou Messages : 2506

ok.

Bah tu connais le loto?

Bah la c'est pareil

[flash]c'est l'explication qui pète!!![]

jeudi 21 mai 2009

SiMax Messages : 7572

Oui mais les joueurs reçoivent des ressources de temps en temps ou ils doivent s'inscrire ?

jeudi 21 mai 2009

Page suivante »