The post was edited 3 times, last by SKY WARS ().
Mods-Market-V1.8-V1.9
This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.
-
-
Mod was adapted by me under 1,8-1,9
-
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
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...
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
- if( $BuildingID == '1' && $USER['darkmatter'] >= $MetalMineDM && $USER['bm_MetalMine_time'] < TIMESTAMP && $PLANET['planet_type'] == 1){
- $USER['darkmatter'] -= $MetalMineDM;
- $db->update("UPDATE %%USERS%% SET bm_MetalMine_price= '".$MetalMineNewPrice."' WHERE id= '".$USER['id']."';");
- $db->update("UPDATE %%USERS%% SET `bm_MetalMine_time` = '".(TIMESTAMP + 108000)."' WHERE `id` = '".$USER['id']."' ;");
- $db->update("UPDATE %%USERS%% SET `bm_MetalMine_amount` = bm_MetalMine_amount+1 WHERE `id` = '".$USER['id']."' ;");
- $db->update("UPDATE %%PLANETS%% SET metal_mine = metal_mine+1 WHERE `id` ='".$PLANET['id']."';");
- $this->printMessage('Metal Mine Purchased!', true, array('game.php?page=blackMarket', 1));
- exit;
- }
- if( $BuildingID == '1' && $USER['darkmatter'] < $MetalMineDM){
- $this->printMessage('Please verify your Dark Matter to purchase Metal Mine !', true, array('game.php?page=blackMarket', 1));
- exit;
- }
- if( $BuildingID == '1' && $USER['bm_MetalMine_time'] > TIMESTAMP){
- $this->printMessage('Please verify your cooldown time to purchase Metal Mine !', true, array('game.php?page=blackMarket', 1));
- exit;
- }
- if( $BuildingID == '1' && $PLANET['planet_type'] == 3){
- $this->printMessage('Once you are on the moon, you can not purchase Metal Mine !', true, array('game.php?page=blackMarket', 1));
- exit;
- }
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.
RegardsThe 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
- <?php
- // EXAMPLE OF BLACKMARKET BY THISISHOWWEDOIT
- class ShowBlackMarketPage extends AbstractGamePage
- {
- public static $requireModule = 0;
- function __construct()
- {
- parent::__construct();
- }
- public function show()
- {
- global $USER, $PLANET, $LNG, $resource;
- $this->tplObj->loadscript('jquery.countdown.js');
- $BuildingID = HTTP::_GP('buildingID', 0);
- if( $USER['urlaubs_modus'] == 1){
- $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));
- }elseif(!isset($resource[$BuildingID])){
- $this->printMessage('This id does not exist. Try again or report the error to the admins', true, array('game.php?page=BlackMarket', 5));
- }else{
- $marketArray = array("1"=>"MetalMine", "2" => "CrystalMine", "3" => "DeuteriumSynthesizer")
- $itemDM = $USER['bm_'.$marketArray[$BuildingID].'_price'];
- $itemPurchased = $USER['bm_'.$marketArray[$BuildingID].'_amount'];
- $NewPrice = $itemDM * 2;
- if($USER['darkmatter'] >= $itemDM && $USER['bm_'.$marketArray[$BuildingID].'_time'] < TIMESTAMP && $PLANET['planet_type'] == 1){
- $USER['darkmatter'] -= $itemDM;
- 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']."';");
- if(isset($PLANET[$resource[$BuildingID]]))
- database::get()->update("UPDATE %%PLANETS%% SET ".$resource[$BuildingID]." = ".$PLANET[$resource[$BuildingID]]."+1 WHERE `id` ='".$PLANET['id']."';");
- else
- database::get()->update("UPDATE %%USERS%% SET ".$resource[$BuildingID]." = ".$USER[$resource[$BuildingID]]."+1 WHERE `id` ='".$USER['id']."';");
- $this->printMessage($LNG['tech'][$BuildingID].' Purchased!', true, array('game.php?page=blackMarket', 1));
- }elseif( $BuildingID == '1' && $USER['darkmatter'] < $MetalMineDM){
- $this->printMessage('Please verify your Dark Matter to purchase '.$LNG['tech'][$BuildingID].' !', true, array('game.php?page=blackMarket', 1));
- }elseif( $BuildingID == '1' && $USER['bm_'.$marketArray[$BuildingID].'_time'] > TIMESTAMP){
- $this->printMessage('Please verify your cooldown time to purchase '.$LNG['tech'][$BuildingID].' !', true, array('game.php?page=blackMarket', 1));
- }elseif( $BuildingID == '1' && $PLANET['planet_type'] == 3){
- $this->printMessage('Once you are on the moon, you can not purchase '.$LNG['tech'][$BuildingID].' !', true, array('game.php?page=blackMarket', 1));
- }
- }
- $this->tplObj->assign_vars(array(
- //HERE ALL YOUR TEMPLATES VARS DEFINED.
- ));
- $this->display('page.blackmarket.default.tpl');
- }
- }
- ?>
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
RegardsThe post was edited 8 times, last by Thisishowwedoit ().
-
hey bio dragon thank you for contributing this mod is really appreciate it...
-
Share
- Facebook 0
- Twitter 0
- Google Plus 0
- Reddit 0
-
Users Online 1
1 Guest