Solved Enchantment Cost

Discussion in 'Development' started by xXNiceAssassinlo YT, Jul 8, 2019.

  1. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    700
    GitHub:
    xXNiceYT
    Hello there, i am having a issue in my enchantment shop. Everytime i buy the enchantment it should increases price by 100 so for example if normal price is 100 and the enchantment max level is 5 the price should increases till its 500.

    PHP:
    $id 12//enchantment id
    $lvl 1//level increases when they buy enchantment

    if($nbt->hasTag("cost-" strval($id)) == false){
        
    $cost 100;
        
    $nbt->setInt("cost-" strval($id), $cost);
    }
    if(
    $lvl 0){
        
    $cost $nbt->getInt("cost-" strval($id)) * 2;
        
    $nbt->setInt("cost-" strval($id), $cost);
    }
    this code increases to 200 only idk why.
     
  2. Az928

    Az928 Baby Zombie

    Messages:
    144
    GitHub:
    theaz928
    Your post isn't clear, and I see it's functioning properly, 100 * 2 = 200
     
  3. Az928

    Az928 Baby Zombie

    Messages:
    144
    GitHub:
    theaz928
    also to increase cost by 100 each level, use 100 * $level instead of $nbtValue * 2
     
    OnTheVerge likes this.
  4. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    700
    GitHub:
    xXNiceYT
    Thank you I was trying my method for like day it hurt my head so I posted here tyyy so much az.
     
    OnTheVerge likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.