1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

How to make a EggWars Shop?

Discussion in 'Development' started by WEATHERCRAFTYT1, Jul 31, 2020.

  1. WEATHERCRAFTYT1

    WEATHERCRAFTYT1 Baby Zombie

    Messages:
    121
    Hello im trying to make an EggWars shop but i want to add a option which the players buys the item like if he has 2 gold then he gets a sword but if he doesnt then it says you cant purchase this item. Here is my code.
    Code:
    public function openWeaponForm($player){
            $api = $this->getServer()->getPluginManager()->getPlugin("FormAPI");
            $form = $api->createSimpleForm(function (Player $player, int $data = null){
                $result = $data
                if ($result === null) {
                     return true;
                }
                switch($result) {
                    case 0:
                        
                    break;
                    
                    case 1:
                        
                    break;
                    
                    case 2:
                        
                    break;
                        
                    case 3:
                        
                    break;
                      
                    case 4:
                        
                    break;
                        
                    case 5:
                        
                    break;
                }
            });
            $form->setTitle("Armor");
            $form->setContent("Select an Armor");
            $form->addButton("Wooden Sword");
            $form->addButton("Stone Sword");
            $form->addButton("Iron Sword");
            $form->addButton("Diamond Sword");
            $form->addButton("Bow");
            $form->addButton("Arrow");
            $form->sendToPlayer($player);
        }
    Anyone knows how to do this?
     
  2. Diduhless

    Diduhless Baby Zombie

    Messages:
    199
    GitHub:
    Diduhless
    PHP:
    if(PlayerInventory->contains(Item)) {
        
    PlayerInventory->addItem(Item);
    }
     
    Primus likes this.
  3. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    create foreach loop, in to it set if for example Dianonds (in player inv) is 10, set to 0 or $item->getCount->setCount($diamond - 4); and add bow to player inv.
    and, if player dont have 10 diamond send message to player -> you dont have Enough Diamond.
    Solved?
     
  4. WEATHERCRAFTYT1

    WEATHERCRAFTYT1 Baby Zombie

    Messages:
    121
  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.