Mods-Market-V1.8-V1.9

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

  • Mods-Market-V1.8-V1.9

    <X

    The post was edited 3 times, last by SKY WARS ().

  • Hmmm: never downloaded 1.9, but do you really think $CONF still exist in it ? Is @Danter14 using a such old pack for 1.9 ?

    Also

    PHP Source Code

    1. if( $USER['urlaubs_modus'] == 1){
    2. $this->printMessage('If you desire to use Black Market Shop, please verify if your account is allowed play. Disable Vacation Mode on Settings Page and then, try again!', true, array('game.php?page=blackMarket', 1));
    3. exit;
    4. }


    This redirection will created a unlimited loop that will never end... shouldnt it be better to redirect to overview or setting page.. and not sure player has time to read such a long message in 1 second...


    PHP Source Code

    1. $BuildingID = HTTP::_GP('buildingID', '', UTF8_SUPPORT);


    If you know the input would be a number, then there is no need to accept text in the input (open leaks in your database) you should change that to , 0

    PHP Source Code

    1. if( $BuildingID == '1' && $USER['darkmatter'] >= $MetalMineDM && $USER['bm_MetalMine_time'] < TIMESTAMP && $PLANET['planet_type'] == 1){
    2. $USER['darkmatter'] -= $MetalMineDM;
    3. $db->update("UPDATE %%USERS%% SET bm_MetalMine_price= '".$MetalMineNewPrice."' WHERE id= '".$USER['id']."';");
    4. $db->update("UPDATE %%USERS%% SET `bm_MetalMine_time` = '".(TIMESTAMP + 108000)."' WHERE `id` = '".$USER['id']."' ;");
    5. $db->update("UPDATE %%USERS%% SET `bm_MetalMine_amount` = bm_MetalMine_amount+1 WHERE `id` = '".$USER['id']."' ;");
    6. $db->update("UPDATE %%PLANETS%% SET metal_mine = metal_mine+1 WHERE `id` ='".$PLANET['id']."';");
    7. $this->printMessage('Metal Mine Purchased!', true, array('game.php?page=blackMarket', 1));
    8. exit;
    9. }
    10. if( $BuildingID == '1' && $USER['darkmatter'] < $MetalMineDM){
    11. $this->printMessage('Please verify your Dark Matter to purchase Metal Mine !', true, array('game.php?page=blackMarket', 1));
    12. exit;
    13. }
    14. if( $BuildingID == '1' && $USER['bm_MetalMine_time'] > TIMESTAMP){
    15. $this->printMessage('Please verify your cooldown time to purchase Metal Mine !', true, array('game.php?page=blackMarket', 1));
    16. exit;
    17. }
    18. if( $BuildingID == '1' && $PLANET['planet_type'] == 3){
    19. $this->printMessage('Once you are on the moon, you can not purchase Metal Mine !', true, array('game.php?page=blackMarket', 1));
    20. exit;
    21. }
    Display All


    I would personaly have used elseif on that point and all following similar points... (exit; is also not required everywhere, the printmessage function will quit the file itself)

    And as last, what a long file, you could code this in 10 lines with a foreach and some arrays.

    Regards

    The post was edited 1 time, last by Thisishowwedoit ().

  • an example of simplified code, i did it for the 3 first of the file (metal mine, crystal mine, deuterium mine, there is simply one line to edit to add the other ones :)

    PHP Source Code

    1. <?php
    2. // EXAMPLE OF BLACKMARKET BY THISISHOWWEDOIT
    3. class ShowBlackMarketPage extends AbstractGamePage
    4. {
    5. public static $requireModule = 0;
    6. function __construct()
    7. {
    8. parent::__construct();
    9. }
    10. public function show()
    11. {
    12. global $USER, $PLANET, $LNG, $resource;
    13. $this->tplObj->loadscript('jquery.countdown.js');
    14. $BuildingID = HTTP::_GP('buildingID', 0);
    15. if( $USER['urlaubs_modus'] == 1){
    16. $this->printMessage('If you desire to use Black Market Shop, please verify if your account is allowed play. Disable Vacation Mode on Settings Page and then, try again!', true, array('game.php?page=settings', 5));
    17. }elseif(!isset($resource[$BuildingID])){
    18. $this->printMessage('This id does not exist. Try again or report the error to the admins', true, array('game.php?page=BlackMarket', 5));
    19. }else{
    20. $marketArray = array("1"=>"MetalMine", "2" => "CrystalMine", "3" => "DeuteriumSynthesizer")
    21. $itemDM = $USER['bm_'.$marketArray[$BuildingID].'_price'];
    22. $itemPurchased = $USER['bm_'.$marketArray[$BuildingID].'_amount'];
    23. $NewPrice = $itemDM * 2;
    24. if($USER['darkmatter'] >= $itemDM && $USER['bm_'.$marketArray[$BuildingID].'_time'] < TIMESTAMP && $PLANET['planet_type'] == 1){
    25. $USER['darkmatter'] -= $itemDM;
    26. database::get()->update("UPDATE %%USERS%% SET bm_".$marketArray[$BuildingID]."_price= '".$NewPrice."', `bm_".$marketArray[$BuildingID]."_time` = '".(TIMESTAMP + 108000)."', `bm_".$marketArray[$BuildingID]."_amount` WHERE id= '".$USER['id']."';");
    27. if(isset($PLANET[$resource[$BuildingID]]))
    28. database::get()->update("UPDATE %%PLANETS%% SET ".$resource[$BuildingID]." = ".$PLANET[$resource[$BuildingID]]."+1 WHERE `id` ='".$PLANET['id']."';");
    29. else
    30. database::get()->update("UPDATE %%USERS%% SET ".$resource[$BuildingID]." = ".$USER[$resource[$BuildingID]]."+1 WHERE `id` ='".$USER['id']."';");
    31. $this->printMessage($LNG['tech'][$BuildingID].' Purchased!', true, array('game.php?page=blackMarket', 1));
    32. }elseif( $BuildingID == '1' && $USER['darkmatter'] < $MetalMineDM){
    33. $this->printMessage('Please verify your Dark Matter to purchase '.$LNG['tech'][$BuildingID].' !', true, array('game.php?page=blackMarket', 1));
    34. }elseif( $BuildingID == '1' && $USER['bm_'.$marketArray[$BuildingID].'_time'] > TIMESTAMP){
    35. $this->printMessage('Please verify your cooldown time to purchase '.$LNG['tech'][$BuildingID].' !', true, array('game.php?page=blackMarket', 1));
    36. }elseif( $BuildingID == '1' && $PLANET['planet_type'] == 3){
    37. $this->printMessage('Once you are on the moon, you can not purchase '.$LNG['tech'][$BuildingID].' !', true, array('game.php?page=blackMarket', 1));
    38. }
    39. }
    40. $this->tplObj->assign_vars(array(
    41. //HERE ALL YOUR TEMPLATES VARS DEFINED.
    42. ));
    43. $this->display('page.blackmarket.default.tpl');
    44. }
    45. }
    46. ?>
    Display All
    I coded this in less then 5 min, so there could be an error or 2 very simple to fix as i didnt tested it.

    40 Lines vs 500+ Lines (we are all for a limitted time on world, dont lost time writing code when u can do easier :p)

    and also i code in 2moons but never permitted to revove the head copyright in a php file to own it on my name, i would have left qwatayakan if i remember correctly the owner of it
    Regards

    The post was edited 8 times, last by Thisishowwedoit ().