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

Solved what the problem

Comments in 'Plugin Development' started by Praxthisnovcht, Oct 17, 2015.

  1. Praxthisnovcht
    Offline

    Praxthisnovcht Notable Member Plugin Developer

    Joined:
    Mar 10, 2014
    Posts:
    699
    Plugins:
    4
    Minecraft User:
    PraxHellTag
    hi guys, I is not no errors just do not get it when using the kit.

    PHP:
                            if ($sender->hasPermission("sw.command.kit")) {
                                if (isset(
    $this->gamePlayers[$name])) {
                                    if (
    $this->gameState[$this->gamePlayers[$name]] == 0) {
                                        if (isset(
    $args[1])) {
                                            
    $kit strtoupper($args[1]);
                                            echo 
    "Peut être que";
                                            foreach (
    $this->getKits() as $file) {
                                                if (isset(
    $file["Kits"][$kit])) {
                                                    echo 
    "Test3";
                                                    
    $H $file["Kits"][$kit]["Items"]["Helmet"];
                                                    if (
    $H == "" || $H == null) {
                                                        
    $H 0;
                                                    }
                                                    
    $CP $file["Kits"][$kit]["Items"]["Chestplate"];
                                                    if (
    $CP == "" || $CP == null) {
                                                        
    $CP 0;
                                                    }
                                                    
    $L $file["Kits"][$kit]["Items"]["Leggs"];
                                                    if (
    $L == "" || $L == null) {
                                                        
    $L 0;
                                                    }
                                                    
    $B $file["Kits"][$kit]["Items"]["Boots"];
                                                    if (
    $B == "" || $B == null) {
                                                        
    $B 0;
                                                    }
                                                    
    $sender->getInventory()->addItem(Item::get($H01));
                                                    
    $sender->getInventory()->addItem(Item::get($CP01));
                                                    
    $sender->getInventory()->addItem(Item::get($L01));
                                                    
    $sender->getInventory()->addItem(Item::get($B01));
                                                    for (
    $x 1$x 36$x++) {
                                                        if (isset(
    $file["Kits"][$kit]["Items"]["Slot$x"])) {
                                                            
    $sender->getInventory()->addItem(Item::get($file["Kits"][$kit]["Items"]["Slot$x"]["ItemID"], 0$file["Kits"][$kit]["Items"]["Slot$x"]["Amount"]));
                                                        }
                                                    }
                                                    echo 
    "Peut être que 2";


    PHP:
        public function createKit($enabled) {

            @
    file_put_contents($this->getDataFolder() . "kits.yml", @yaml_emit([
                
    "Kits" => [
                    
    "BARBARIAN" => [
                        
    "Items" => [
                            
    "Helmet" => 298,
                            
    "Chestplate" => 299,
                            
    "Leggs" => 300,
                            
    "Boots" => 301,
                            
    "Slot1" => [
                                
    "Amount" => 1,
                                
    "ItemID" => 267
                            
    ],
                        ],
                        
    "data" => $enabled
                    
    ],
                ],
            ], 
    YAML_UTF8_ENCODING));
        }
        public function 
    getKits() {

            
    $resule = [];
            foreach (
    scandir($this->getDataFolder()) as $file) {
                if (
    substr($file, -3) === "yml") {
                    
    $data = @yaml_parse(Config::fixYAMLIndexes(@file_get_contents($this->getDataFolder() . $file)));
                    if (isset(
    $data['Kits'])) {
                        
    $resule[] = $data;
                    }
                }
            }
            return 
    $resule;
        }
  2. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    EDITTED : I thought echo didn't work in Pocketmine API (like you don't need ?>), if you want to send player a message, you can simply just do:
    PHP:
    $player->sendMessage("Test");
    Last edited: Oct 18, 2015
  3. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Please, just stop. echo works, why don't you try it for yourself? If you can't properly help someone, I recommend you to stop trying to.
    I can't seem to find the problem, try placing a var_dump() here and there, and you might find the problem from there on.
    CavinMiana likes this.
  4. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    Calm down... everyone is learning.....
  5. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Obviously based on what you posted I can tell you're still learning. But right now you are doing more harm than help, by providing invalid solutions, you are misleading everyone(who doesn't know about coding but wants to). Avoid trying to help until you actually fully understand it yourself, it will benefit everyone. :)
    Last edited: Oct 18, 2015
    PEMapModder and HotFireyDeath like this.
  6. CavinMiana
    Offline

    CavinMiana Active Member

    Joined:
    Aug 26, 2015
    Posts:
    101
    Minecraft User:
    CavinMiana
    Ohhhhhhh shots firedddddd!!!!!
    HotFireyDeath likes this.
  7. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    I do take my responsibility that I should have looked more about "echo" before posting.
  8. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    The PocketMine API is written in php, therefore, all php functions should work.
    Legoboy0215 and zombie_Power like this.
  9. iDirtPlayzMC
    Offline

    iDirtPlayzMC Active Member

    Joined:
    Apr 10, 2015
    Posts:
    264
    Minecraft User:
    iZenith_xPr
    Meany
  10. Praxthisnovcht
    Offline

    Praxthisnovcht Notable Member Plugin Developer

    Joined:
    Mar 10, 2014
    Posts:
    699
    Plugins:
    4
    Minecraft User:
    PraxHellTag
    I just wanted to help ..
    a discussion not teach another person
    iDirtPlayzMC likes this.
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    OCD alert: echo is a control structure, not a function.
  12. Praxthisnovcht
    Offline

    Praxthisnovcht Notable Member Plugin Developer

    Joined:
    Mar 10, 2014
    Posts:
    699
    Plugins:
    4
    Minecraft User:
    PraxHellTag
    thank you for help lol.

    resolved

Share This Page

Advertisement