adaptation errors

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

  • adaptation errors

    Hi trying to adapt the mod harvesting under 1.8-1.9

    ran into errors ;(

    PHP Source Code

    1. <?php
    2. /**
    3. * @package 2moons 1.8 - 2moons 1.9
    4. * @author BIO DRAGON
    5. * @copyright 2017 BIO DRAGON
    6. * @version 1.0
    7. * @link http://2moons.de
    8. */
    9. class ShowHarvestPage extends AbstractGamePage {
    10. public static $requireModule = 0;
    11. var $HarvestPrice = array(1=>500,3=>1000,6=>2000, 15=>4000); // (weeks => price dm)
    12. function __construct() {
    13. parent::__construct();
    14. }
    15. function show() {
    16. global $CONF, $LNG, $PLANET, $USER, $resource, $UNI;
    17. $db = Database::get();
    18. if($USER['harvest_delay'] < TIMESTAMP - 24*60*60){
    19. if($USER['harvest_time'] < 5){
    20. $time = TIMESTAMP;
    21. $db->query("UPDATE `uni1_users` SET `harvest_time` = 5, `harvest_delay` = ".$time." where `id` = ".$USER['id'].";");
    22. $this->printMessage("Whe are setting back your harvest counters to 5.", true, array('game.php?page=harvest', 2));
    23. die();
    24. } else{
    25. $time = TIMESTAMP;
    26. $db->update("UPDATE `uni1_users` SET `harvest_delay` = ".$time." where `id` = ".$USER['id'].";");
    27. $this->printMessage("Loading your data.", true, array('game.php?page=harvest', 2));
    28. die();
    29. }
    30. }
    31. if(!empty($USER['urlaubs_modus'])){
    32. $this->printMessage("You can't access this page while you are in V mode!", true, array('game.php?page=overview', 2));
    33. die();
    34. }
    35. if($_POST){
    36. $mode = HTTP::_GP('con', '');
    37. switch($mode){
    38. case 'extra':
    39. $take = HTTP::_GP('buy',0);
    40. if(!array_key_exists($take,$this->HarvestPrice)){
    41. $this->printMessage("Invalid Option", true, array('?page=Harvest', 3));
    42. }else{
    43. //option is ok . go forward
    44. //enough dm ?
    45. if($USER['darkmatter'] < $this->HarvestPrice[$take]){
    46. $this->printMessage("Not enough DM", true, array('?page=Harvest', 3));
    47. die();
    48. }
    49. $USER['darkmatter'] -= $this->HarvestPrice[$take];
    50. $db->update("UPDATE %%USERS%% SET `harvest_time` = `harvest_time` + ".($take)." WHERE `id` = ".$USER['id']." ; ");
    51. $this->printMessage("You have bought ".$take." Harvest Points", true, array('?page=Harvest', 3));
    52. die();
    53. }
    54. break;
    55. case 'gather':
    56. if($USER['harvest_time'] == 0 ){
    57. $this->printMessage("No Harvest Points Left!", true, array('game.php?page=Harvest', 2));
    58. die();
    59. }
    60. if (!isset($_POST['check_planet']) && !isset($_POST['check_moons']))
    61. $this->redirectTo('game.php?page=harvest');
    62. if(!isset($_POST['check_planet']))
    63. $_POST['check_planet'] = array();
    64. foreach($_POST['check_planet'] as $ID => $Value) {
    65. $sur =$db->uniquequery("SELECT metal, crystal, deuterium FROM %%PLANETS%% WHERE `id` = '".$Value."';");
    66. $sur =$db->multi_query("LOCK TABLE %%PLANETS%% WRITE; UPDATE %%PLANETS%% SET `metal` = metal - ".$sur['metal'].", `crystal` = crystal - ".$sur['crystal'].", `deuterium` = deuterium - ".$sur['deuterium']." WHERE `id` = '".$Value."'; UNLOCK TABLES;");
    67. $PLANET['metal'] += $metal;
    68. $PLANET['crystal'] += $crystal;
    69. $PLANET['deuterium'] += $deuterium ;
    70. }
    71. if(!isset($_POST['check_moons']))
    72. $_POST['check_moons'] = array();
    73. foreach($_POST['check_moons'] as $ID => $Value) {
    74. $db->uniquequery("SELECT metal, crystal, deuterium FROM %%PLANETS%% WHERE `id` = '".$Value."';");
    75. $db->multi_query("LOCK TABLE %%PLANETS%% WRITE; UPDATE %%PLANETS%% SET `metal` = metal - ".$surr['metal'].", `crystal` = crystal - ".$surr['crystal'].", `deuterium` = deuterium - ".$surr['deuterium']." WHERE `id` = '".$Value."'; UNLOCK TABLES;");
    76. $PLANET['metal'] += $metal;
    77. $PLANET['crystal'] += $crystal;
    78. $PLANET['deuterium'] += $deuterium ;
    79. }
    80. $db->update("UPDATE %%USERS%% SET `harvest_time` = `harvest_time` - 1 where `id` = '".$USER['id']."';");
    81. $this->printMessage($LNG['h_ok'], true, array('game.php?page=harvest', 4));
    82. break;
    83. }
    84. }
    85. $Planets= array();
    86. $Moons = array();
    87. if (isset($USER['PLANETS'])) {
    88. $USER['PLANETS'] = getPlanets($USER);
    89. }
    90. foreach($USER['PLANETS'] as $ID => $PlanetQuery) {
    91. if ($ID == $PLANET['id']) continue;
    92. if ($PlanetQuery['planet_type'] == 3) {
    93. $Moons[$PlanetQuery['id']] = " [" . $PlanetQuery['galaxy'] . ":" . $PlanetQuery['system'] . ":" . $PlanetQuery['planet'] . "]";
    94. } elseif ($PlanetQuery['planet_type'] == 1) {
    95. $Planets[$PlanetQuery['id']] = " [".$PlanetQuery['galaxy'] . ":" . $PlanetQuery['system'] . ":" . $PlanetQuery['planet'] . "]";
    96. }
    97. }
    98. $this->tplObj->loadscript("jquery.countdown.js");
    99. $this->tplObj->assign_vars(array(
    100. 'prices' => $this->HarvestPrice,
    101. 'PlanetsList'=> $Planets,
    102. 'MoonsList'=> $Moons,
    103. 'harvest'=> $USER['harvest_time'],
    104. 'p_state' => $USER['harvest_time'],
    105. 'p_delay' => ((($USER['harvest_delay']+24*60*60) < TIMESTAMP) ? true : (($USER['harvest_delay']+24*60*60) - TIMESTAMP)),
    106. ));
    107. $this->display('page.harvest.default.tpl');
    108. }
    109. }
    110. ?>
    Display All
  • I do not understand what to do with these lines


    SQL-Query

    1. $sur =$db->uniquequery("SELECT metal, crystal, deuterium FROM %%PLANETS%% WHERE `id` = '".$Value."';");
    2. $sur =$db->multi_query("LOCK TABLE %%PLANETS%% WRITE; UPDATE %%PLANETS%% SET `metal` = metal - ".$sur['metal'].", `crystal` = crystal - ".$sur['crystal'].", `deuterium` = deuterium - ".$sur['deuterium']." WHERE `id` = '".$Value."'; UNLOCK TABLES;");
    3. $db->uniquequery("SELECT metal, crystal, deuterium FROM %%PLANETS%% WHERE `id` = '".$Value."';");
    4. $db->multi_query("LOCK TABLE %%PLANETS%% WRITE; UPDATE %%PLANETS%% SET `metal` = metal - ".$surr['metal'].", `crystal` = crystal - ".$surr['crystal'].", `deuterium` = deuterium - ".$surr['deuterium']." WHERE `id` = '".$Value."'; UNLOCK TABLES;");
  • If you want help, do not change header copyright only because u changed GLOBAL-> to $db xD
    - Xterium Template
    - War of Alliance Template
    - Antaris-Legacy Template
    - Ogame Template

    I can and will only help with instalation with hostings including cpanel or plesk and an teamviewer access
  • Thisishowwedoit wrote:

    If you want help, do not change header copyright only because u changed GLOBAL-> to $db xD
    yes i agree to make a mods adaptation of 1.7.3 in 1.8 or 1.9 is not at all complicated even for beginners
    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 1.0 will be version 3.0 of 2moons that I'm coding
    Demo and coding 2moons 2.0