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

Need Help With Code

Comments in 'Plugin Development' started by Adrian, Jun 28, 2014.

  1. iFootball
    Offline

    iFootball Active Member

    Joined:
    Jun 9, 2014
    Posts:
    84
    Minecraft User:
    iFootball
    I didn't know this, can someone else confirm it? And we did say "It doesn't work yet".
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    In a computer science perspective:
    A for-loop:
    PHP:
    for(statement1statement2statement3){
        
    statement4;
        
    statement5;
    }
    statement6...;
    It is like this:
    Code:
    1. Run statement1;
    2. If statement2 is true, run the code below (statement4 and statement5). Else, go to step 5.
    3. Run statement3;
    4. Go back to step 2;
    5. Run statement6...;
  3. iFootball
    Offline

    iFootball Active Member

    Joined:
    Jun 9, 2014
    Posts:
    84
    Minecraft User:
    iFootball
    And that's why it doesn't work?
  4. iFootball
    Offline

    iFootball Active Member

    Joined:
    Jun 9, 2014
    Posts:
    84
    Minecraft User:
    iFootball
    If that's the case then changed it to this, haven't tested it but it might work.
    PHP:
    <?php

    /*
    __PocketMine Plugin__
    name=MoneyRankUp
    version=1.0
    description=When you do "/rankup" you get rank "A" if you have 10000 PM's.
    author=iFootball, made for Adrian.
    class=MoneyRankUp
    apiversion=12
    */

    class MoneyRankUp implements Plugin{

    const 
    CONFIG_POCKETMONEY 0b01;

    private 
    $api;

    public function 
    __construct(ServerAPI $api$server false){
    $this->api $api;
    }

    public function 
    init(){
    //Thie receives data from the PocketMoney plugin, this will be used to figure out the players money, and retract it from their account.
    if (file_exists(DATA_PATH."plugins/PocketMoney.php")) {
    $this->api->console->register("rankup","ranks you up",array($this"rankup"));
    $this->api->ban->cmdWhitelist("rankup");
    }
    }
    public function 
    rankup($cmd$issuer){
    $username $issuer->username;
    10000-$money=$amount;
    $money PocketMoney::getMoney($issuer);
    //This retrieves the players money from the config
        
    if ($money >= 10000) {
        
    //This says if the players money is larger then 10000
        
    $this->api->console->run("rmgr sr " $username,"A");
        
    //Before you were having the console run "pay bank 10000" instead of the player, this runs it as the player.
        
    PocketMoneyAPI::getAPI()->grantMoney($issuer, -10000);
        
    //Tells the player this messege
        
    $issuer->sendChat("You have payed 10000 to rank up! You are now rank A!");
        
    //Tells the hole server this messege.
        
    $this->api->chat->broadcast("[RankUp] $username has ranked-up to rank A!");
        }
        else {
        
    //If they don't have enough money it will say:
        
    $issuer->sendChat("You do not have enough money to buy this rank. You need $amount to rank up.");
    //PocketMoneyAPI::getAPI()->grantMoney
    }
    }
    public function 
    __destruct(){
    }
    }
    ?>
  5. Adrian
    Offline

    Adrian Active Member

    Joined:
    Jun 26, 2014
    Posts:
    64
    Minecraft User:
    Adrian
    Wow, that looks way better :D In POCKETMONEY, does the player have to create their own account manually or is it upon join?
  6. iFootball
    Offline

    iFootball Active Member

    Joined:
    Jun 9, 2014
    Posts:
    84
    Minecraft User:
    iFootball
    It creates it automatically, can you test it?
  7. Adrian
    Offline

    Adrian Active Member

    Joined:
    Jun 26, 2014
    Posts:
    64
    Minecraft User:
    Adrian
  8. Adrian
    Offline

    Adrian Active Member

    Joined:
    Jun 26, 2014
    Posts:
    64
    Minecraft User:
    Adrian
    :cool::cool::cool:Thank You! Testing...
  9. Adrian
    Offline

    Adrian Active Member

    Joined:
    Jun 26, 2014
    Posts:
    64
    Minecraft User:
    Adrian
    It doesn't work, but thank you! It stops server and creates error dump.
    Here it is:

    Code:
    ```
    # PocketMine-MP Error Dump Mon Jun 30 17:53:32 UTC 2014
    Error: array (
      'type' => 'E_ERROR',
      'message' => 'Call to a member function sendChat() on a non-object',
      'file' => 'C:\\Users\\Tomas\\Desktop\\PocketMine\\plugins\\MoneyRankUp.php',
      'line' => 47,
    )
     
    THIS ERROR WAS CAUSED BY A PLUGIN. REPORT IT TO THE PLUGIN DEVELOPER.
    Code:
    [38]     //Before you were having the console run "pay bank 10000" instead of the player, this runs it as the player.
    [39]     PocketMoneyAPI::getAPI()->grantMoney($issuer, -10000);
    [40]     //Tells the player this messege
    [41]     $issuer->sendChat("You have payed 10000 to rank up! You are now rank A!");
    [42]     //Tells the hole server this messege.
    [43]     $this->api->chat->broadcast("[RankUp] $username has ranked-up to rank A!");
    [44]     }
    [45]     else {
    [46]     //If they don't have enough money it will say:
    [47]     $issuer->sendChat("You do not have enough money to buy this rank. You need $amount to rank up.");
    [48] //PocketMoneyAPI::getAPI()->grantMoney
    [49] }
    [50] }
    [51] public function __destruct(){
    [52] }
    [53] }
    [54] ?>
    [55]
    [56]
    [57]
    
    It looks like it was because of the sendChat, it says on top.
  10. Adrian
    Offline

    Adrian Active Member

    Joined:
    Jun 26, 2014
    Posts:
    64
    Minecraft User:
    Adrian
    On post #69 it has error dump.

    the plugins you need are XTi-rankmanager, and PocketMoney.
  11. PluginMastered
    Offline

    PluginMastered Active Member

    Joined:
    Mar 1, 2014
    Posts:
    161
    Minecraft User:
    Flexa33
    PHP:
    <?php

    /*
    __PocketMine Plugin__
    name=MoneyRankUp
    version=1.0
    description=When you do "/rankup" you get rank "A" if you have 10000 PM's.
    author=iFootball, made for Adrian.
    class=MoneyRankUp
    apiversion=12
    */

    class MoneyRankUp implements Plugin{

    const 
    CONFIG_POCKETMONEY 0b01;

    private 
    $api;

    public function 
    __construct(ServerAPI $api$server false){
    $this->api $api;
    }

    public function 
    init(){
    //Thie receives data from the PocketMoney plugin, this will be used to figure out the players money, and retract it from their account.
    if (file_exists(DATA_PATH."plugins/PocketMoney.php")) {
    $this->api->console->register("rankup","ranks you up",array($this"rankup"));
    $this->api->ban->cmdWhitelist("rankup");
    }
    }
    public function 
    rankup($cmd$issuer){
    $username $issuer->username;
    10000-$money=$amount;
    $money PocketMoney::getMoney($issuer);
    //This retrieves the players money from the config
        
    if ($money >= 10000) {
        
    //This says if the players money is larger then 10000
        
    $this->api->console->run("rmgr sr " $username,"A");
        
    //Before you were having the console run "pay bank 10000" instead of the player, this runs it as the player.
        
    PocketMoneyAPI::getAPI()->grantMoney($issuer, -10000);
        
    //Tells the player this messege
        
    $issuer->sendChat("You have payed 10000 to rank up! You are now rank A!");
        
    //Tells the hole server this messege.
        
    $this->api->chat->broadcast("[RankUp] $username has ranked-up to rank A!");
        }
        else {
        
    //If they don't have enough money it will say:
        
    $this->api->chat->sendTo(false"You don't have the sufficient funds to rankup""$issuer");
    //PocketMoneyAPI::getAPI()->grantMoney
    }
    }
    public function 
    __destruct(){
    }
    }
    ?>
    does this one work ;) if not tell me the error it outputs
  12. PluginMastered
    Offline

    PluginMastered Active Member

    Joined:
    Mar 1, 2014
    Posts:
    161
    Minecraft User:
    Flexa33
    if issuer gives error then replace it with this
    PHP:
    Default_Player
  13. Adrian
    Offline

    Adrian Active Member

    Joined:
    Jun 26, 2014
    Posts:
    64
    Minecraft User:
    Adrian
    It does nothing.
  14. PluginMastered
    Offline

    PluginMastered Active Member

    Joined:
    Mar 1, 2014
    Posts:
    161
    Minecraft User:
    Flexa33
    its still crashes???
  15. PluginMastered
    Offline

    PluginMastered Active Member

    Joined:
    Mar 1, 2014
    Posts:
    161
    Minecraft User:
    Flexa33
    I don't have a server to test these anymore btw
  16. Adrian
    Offline

    Adrian Active Member

    Joined:
    Jun 26, 2014
    Posts:
    64
    Minecraft User:
    Adrian
    No, it actually does nothing, I hadn't test "Default_Player"
  17. PluginMastered
    Offline

    PluginMastered Active Member

    Joined:
    Mar 1, 2014
    Posts:
    161
    Minecraft User:
    Flexa33
    yeah try that that might be the issue
  18. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    10000-$money = $amount?
  19. PluginMastered
    Offline

    PluginMastered Active Member

    Joined:
    Mar 1, 2014
    Posts:
    161
    Minecraft User:
    Flexa33
    I only edited the chat :D
  20. Adrian
    Offline

    Adrian Active Member

    Joined:
    Jun 26, 2014
    Posts:
    64
    Minecraft User:
    Adrian
    I think it is because of the run, put a space before the "A" such as

    PHP:
    $this->api->console->run("rmgr sr " $username " A"
    //With the space in quotation, wouldn't that make sense?

Share This Page

Advertisement