Bank max button

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Bank max button

      Hi ;)
      Hi @Hike ^^

      I don't idea, what I can do:
      How can I use max resources button on bank:


      I edit tpl file:

      <td><input type="number" name="depot_metal" value="0"></td>
      change to:
      <td><input type="number" name="depot_metal" value="($resourceCurrent)"></td>


      Not work and in bank windows resources was nothing. [IMG:http://www.2moons.cc/wcf/images/smilies/unsure.png]
    • Good evening, to do this you had to do the code part in the js to have a max function button
      I remain at your disposal on the forum for any questions or help.

      A help is of course not a creation of a mod



      -------------------------------------------------------
      Spaccon
      • Uni Xterium Comming Soon
      • Uni Ogame Comming Soon
    • My bank php file:

      PHP Source Code

      1. <?php
      2. /**
      3. * @mods Bank
      4. * @package 2Moons
      5. * @author Hike
      6. * @licence MIT
      7. * @version 1.7.3
      8. */
      9. class ShowBankPage extends AbstractPage
      10. {
      11. public static $requireModule = 0;
      12. function __construct()
      13. {
      14. parent::__construct();
      15. }
      16. function commission()
      17. {
      18. /**
      19. * Une commision est prise par la banque pour chaque dépot (10%)
      20. * A commission is taken by the bank for each deposit (10%)
      21. **/
      22. $commision_bank = 10 / 100;
      23. return $commision_bank;
      24. }
      25. function show()
      26. {
      27. global $USER, $LNG;
      28. /**
      29. * Permet de mettre à jour le ressource des planètes dans la base de donnée (non obligatoire)
      30. * Allows to update the resource of the planets in the database (not required)
      31. **/
      32. $PlanetRess = new ResourceUpdate();
      33. /**
      34. * On vérifie si le joueur existe dans notre base de donnée
      35. * We check if the player exists in our database
      36. **/
      37. $sql = "SELECT * FROM ".BANK." WHERE user_id = ".$USER['id']." ;";
      38. $response = $GLOBALS['DATABASE']->getFirstRow($sql);
      39. /**
      40. * Si le joueur existe pas on force nos variable à 0
      41. * If the player does not exist we force our variables to 0
      42. **/
      43. if (!$response) {
      44. $response['bank_metal'] = 0;
      45. $response['bank_cristal'] = 0;
      46. $response['bank_deuterium'] = 0;
      47. $response['bank_time_update'] = TIMESTAMP;
      48. $response['bank_time_retrait'] = TIMESTAMP;
      49. }
      50. $this->tplObj->assign_vars([
      51. 'bank_metal' => $response['bank_metal'],
      52. 'bank_cristal' => $response['bank_cristal'],
      53. 'bank_deuterium' => $response['bank_deuterium'],
      54. 'commision_bank' => sprintf($LNG['bank_commision'], $this->commission() * 100),
      55. 'dernier_depot' => _date($LNG['php_tdformat'], $response['bank_time_update'], $USER['timezone']),
      56. 'dernier_retrait' => _date($LNG['php_tdformat'], $response['bank_time_retrait'], $USER['timezone']),
      57. ]);
      58. $this->display('page.bank.default.tpl');
      59. }
      60. function updateBank()
      61. {
      62. global $PLANET, $USER, $LNG;
      63. /**
      64. * On mes les boutons pour la reception des ressource mis en banque
      65. * I have the buttons for the reception of the resources put in the bank
      66. **/
      67. $depot_metal = HTTP::_GP('depot_metal', 0);
      68. $depot_cristal = HTTP::_GP('depot_cristal', 0);
      69. $depot_deuterium = HTTP::_GP('depot_deuterium', 0);
      70. /**
      71. * On vérifie que l'un des champs est remplis
      72. * One verifies that one of the fields is filled
      73. **/
      74. if (empty($depot_metal) && empty($depot_cristal) && empty($depot_deuterium)) {
      75. $this->printMessage($LNG['bank_error_empty']);
      76. }
      77. /**
      78. * On fait les vérification pour être sur que le joueur dispose des ressources
      79. * We make the checks to be sure that the player has the resources
      80. **/
      81. if ($PLANET['metal'] < $depot_metal || $PLANET['crystal'] < $depot_cristal || $PLANET['deuterium'] < $depot_deuterium) {
      82. $this->printMessage($LNG['bank_error_resource']);
      83. }
      84. /**
      85. * On crée le total pour les ressources mis en banque moins la commision
      86. * We create the total for the resources put in the bank less the commission
      87. **/
      88. $total_metal_bank = $depot_metal - ($depot_metal * $this->commission());
      89. $total_cristal_bank = $depot_cristal - ($depot_cristal * $this->commission());
      90. $total_deuterium_bank = $depot_deuterium - ($depot_deuterium * $this->commission());
      91. /**
      92. * On vérifie si le joueur à fait un premier dépot sinon on fait un INSERT INTO
      93. * We check if the player made a first deposit otherwise we do an INSERT INTO
      94. **/
      95. $sql_controle = "SELECT user_id FROM ".BANK." WHERE user_id = ".$USER['id']." ;";
      96. $response_controle = $GLOBALS['DATABASE']->getFirstRow($sql_controle);
      97. $sql = "UPDATE ";
      98. if (!$response_controle) {
      99. $sql = "INSERT INTO ";
      100. }
      101. /**
      102. * On insert le tout dans notre base de donnée pour le ressources mise en bank
      103. * We insert the whole in our database for resources put in bank
      104. **/
      105. $sql .= "".BANK." SET
      106. bank_metal = bank_metal + ".$total_metal_bank.",
      107. bank_cristal = bank_cristal + ".$total_cristal_bank.",
      108. bank_deuterium = bank_deuterium + ".$total_deuterium_bank.",
      109. bank_time_update = ".TIMESTAMP."";
      110. if (!$response_controle) {
      111. $sql .= ", user_id = ".$USER['id']." ;";
      112. } else {
      113. $sql .= " WHERE user_id = ".$USER['id']." ;";
      114. }
      115. $GLOBALS['DATABASE']->query($sql);
      116. /**
      117. * On déduit de la planète ou se trouve le joueur les ressource mise dans la banque
      118. * We deduce from the planet where the player is located the resource put in the bank
      119. **/
      120. $PLANET['metal'] -= $depot_metal;
      121. $PLANET['crystal'] -= $depot_cristal;
      122. $PLANET['deuterium'] -= $depot_deuterium;
      123. $this->printMessage($LNG['bank_update_ok']);
      124. }
      125. function debitBank()
      126. {
      127. global $PLANET, $USER, $LNG;
      128. /**
      129. * On mes les boutons pour la reception des ressource mis en banque
      130. * I have the buttons for the reception of the resources put in the bank
      131. **/
      132. $debit_metal = HTTP::_GP('debit_metal', 0);
      133. $debit_cristal = HTTP::_GP('debit_cristal', 0);
      134. $debit_deuterium = HTTP::_GP('debit_deuterium', 0);
      135. /**
      136. * On vérifie si le joueur existe dans notre base de donnée
      137. * We check if the player exists in our database
      138. **/
      139. $sql = "SELECT * FROM ".BANK." WHERE user_id = ".$USER['id']." ;";
      140. $response = $GLOBALS['DATABASE']->getFirstRow($sql);
      141. if (!$response) {
      142. $this->printMessage($LNG['bank_error_joueur']);
      143. }
      144. /**
      145. * On vérifie que l'un des champs est remplis
      146. * One verifies that one of the fields is filled
      147. **/
      148. if (empty($debit_metal) && empty($debit_cristal) && empty($debit_deuterium)) {
      149. $this->printMessage($LNG['bank_error_empty']);
      150. }
      151. /**
      152. * On fait les vérification pour être sur que le joueur dispose des ressources
      153. * We make the checks to be sure that the player has the resources
      154. **/
      155. if ($response['bank_metal'] < $debit_metal || $response['bank_cristal'] < $debit_cristal || $response['bank_deuterium'] < $debit_deuterium) {
      156. $this->printMessage($LNG['bank_error_resource']);
      157. }
      158. /**
      159. * On fait notre requête sql pour déduire les ressource à la bank
      160. * We make our sql query to deduce the resource to the bank
      161. **/
      162. $sql_debit = "UPDATE ".BANK." SET
      163. bank_metal = bank_metal - ".$debit_metal.",
      164. bank_cristal = bank_cristal - ".$debit_cristal.",
      165. bank_deuterium = bank_deuterium - ".$debit_deuterium.",
      166. bank_time_retrait = ".TIMESTAMP." WHERE user_id = ".$USER['id']." ;";
      167. $GLOBALS['DATABASE']->query($sql_debit);
      168. /**
      169. * On ajoute le retrait des ressources de la banque à la planète
      170. * We add the withdrawal of resources from the bank to the planet
      171. **/
      172. $PLANET['metal'] += $debit_metal;
      173. $PLANET['crystal'] += $debit_cristal;
      174. $PLANET['deuterium'] += $debit_deuterium;
      175. $this->printMessage($LNG['bank_debit_ok']);
      176. }
      177. }
      Display All
      If not max button, that mayby where is

      $response['bank_metal'] = 0
      $response['bank_cristal'] = 0
      $response['bank_deuterium'] = 0;


      rather than ,,0" put in curent_resources?
    • To make a max button wrong code this in js or jquery
      I remain at your disposal on the forum for any questions or help.

      A help is of course not a creation of a mod



      -------------------------------------------------------
      Spaccon
      • Uni Xterium Comming Soon
      • Uni Ogame Comming Soon
    • take an example on the max button for the resources in the shipment part of the fleet
      I remain at your disposal on the forum for any questions or help.

      A help is of course not a creation of a mod



      -------------------------------------------------------
      Spaccon
      • Uni Xterium Comming Soon
      • Uni Ogame Comming Soon