Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need help making a pocket money compatable plugin

Comments in 'Plugin Development' started by Xfusionios, Aug 24, 2013.

  1. Xfusionios
    Offline

    Xfusionios Active Member Plugin Developer

    Joined:
    Aug 24, 2013
    Posts:
    67
    Plugins:
    2
    Minecraft User:
    XFusionios
    Ok so i cant the money to be set to $money variable when they do /moneytest. Please help! After i get this to work i can work from there. Im try to make it suport Pocketmoney Plugin and i need it to ready the money and do a something based on how much money they got. So..

    PHP:
    <?php

    /*
    __PocketMine Plugin__
    name=testmoney
    version=0.0.1
    author=Xfusionios
    class=testmoney
    apiversion=9
    */

    class testmoney implements Plugin{
        private 
    $api;
        public function 
    __construct(ServerAPI $api$server false){
            
    $this->api $api;
        }
       
        public function 
    init(){
            
    $this->api->console->register("testmoney""", array($this"handleCommand"));
        }
       
        public function 
    __destruct(){
       
        }
       
        public function 
    handleCommand($cmd$arg$issuer$username){
            switch(
    $cmd){
                case 
    "testmoney":
                    
    $data = array(
    'username' => $issuer->username
    );
    $money $this->api->dhandle("money.player.get"$data);
                    break;
            }
        }

    }
  2. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    218
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    Hi,

    First: You register the command

    PHP:
        $this->api->console->register("testmoney""", array($this"handleCommand")); //You register the command testmoney not moneytest
    Second:
    To handle the money of a player you need to dhandle "money.handle", like this:
    PHP:
        $this->api->dhandle("money.handle", array(
                
    'issuer' => 'MoneySetTo600Plugin'//Here goes the name of the Plugin
                
    'username' => 'MinecrafterJPN'// Here the name of the player to be change the money
                
    'method'=>'set'// Here the mthod to be executed
                
    'amount'=>600 // Here the amount of money to set
        
    ));

    // If you want to get the amout of a player is like this
          
    $this->api->dhandle("money.player.get", array('username' => $issuer)); // I think that you don't need the "->username"
    I hope that helped you.
    Last edited: Aug 25, 2013
    Xfusionios likes this.
  3. Xfusionios
    Offline

    Xfusionios Active Member Plugin Developer

    Joined:
    Aug 24, 2013
    Posts:
    67
    Plugins:
    2
    Minecraft User:
    XFusionios
    Did i do this correct because i seem to not get it to work?
    PHP:
    <?php

    /*
    __PocketMine Plugin__
    name=CommandShop
    version=0.0.1
    author=Xfusionios
    class=Commandshop
    apiversion=9
    */

    class Commandshop implements Plugin{
        private 
    $api;
        public function 
    __construct(ServerAPI $api$server false){
            
    $this->api $api;
        }
     
        public function 
    init(){
            
    $this->api->console->register("cs""", array($this"handleCommand"));
        }
     
        public function 
    __destruct(){
     
        }
     
        public function 
    handleCommand($cmd$arg$issuer$username){
            switch(
    $cmd){
                case 
    "cs":
                    
    $amount $this->api->dhandle("money.player.get", array('username' => $issuer));
                    return 
    $amount;
                    break;
            }
        }

    }
  4. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    218
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    If you want to print the amount don't return it, print out to the console:
    PHP:
    //you are doind this
    $amount $this->api->dhandle("money.player.get", array('username' => $issuer));
    return 
    $amount;

    //You need to do this:
    $amount $this->api->dhandle("money.player.get", array('username' => $issuer));
    console($amount);

  5. Xfusionios
    Offline

    Xfusionios Active Member Plugin Developer

    Joined:
    Aug 24, 2013
    Posts:
    67
    Plugins:
    2
    Minecraft User:
    XFusionios
    Can someone tell me why this no work?

    PHP:
    <?php

    /*
    __PocketMine Plugin__
    name=Shop
    version=0.0.1
    author=Xfusionios
    class=shop
    apiversion=9
    */

    class shop implements Plugin{
        private 
    $api;
        public function 
    __construct(ServerAPI $api$server false){
            
    $this->api $api;
        }

        public function 
    init(){
            
    $this->api->console->register("cs""", array($this"handleCommand"));
        }

        public function 
    __destruct(){

        }

        public function 
    handleCommand($cmd$arg$issuer){
            switch(
    $cmd){
                case 
    "cs":
                    
    $amount $this->api->dhandle("money.player.get", array('username' => $issuer));
                    
    console($amount);
                    break;
            }
        }

    }
  6. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    218
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    Change this:
    PHP:
    $amount $this->api->dhandle("money.player.get", array('username' => $issuer));

    //to this:
    $amount $this->api->dhandle("money.player.get", array('username' => $issuer->username));
    You should review how it works with plugins PocketMine encontarias well as future bugs in your plugins
  7. Xfusionios
    Offline

    Xfusionios Active Member Plugin Developer

    Joined:
    Aug 24, 2013
    Posts:
    67
    Plugins:
    2
    Minecraft User:
    XFusionios
    Its always the little things im so sorry but thanks for the help! :)

Share This Page

Advertisement