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

WHAT IS HAPPENING?!?!??!

Comments in 'Plugin Development' started by Samueljh1, Mar 5, 2015.

  1. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    Omg, guys help... why is this an undefined index?!?

    EDIT: PARTLY RESOLVED :eek: something to do with $player->getName();

    Var_dump:
    PHP:
    array(5) {

      [
    "samueljh1"]=>

      
    float(5)

      [
    "samueljh1_sdf"]=>

      
    float(100)

      [
    "steve"]=>

      
    float(-500)

      [
    "samueljh1_"]=>

      
    float(1000)

      [
    "frazo_06130"]=>

      
    float(1000)

    }

    then , with this code:

    PHP:

                $path 
    Server::getInstance()->getDataPath() . "plugins/EconomyAPI/Money.yml";
                
    $bc = new Config($pathConfig::YAML);
         
                
    //var_dump($bc->get("money"));
         
                
    return $bc->get('money')[strtolower($p)];

    THIS ERROR:
    Code:
    [CRITICAL] Unhandled exception executing command 'rankup' in rankup: Undefined index: money: samueljh1_
    Its SO WEIRD! It works if I do:

    PHP:
    return $bc->get('money')['samueljh1_'];
    $p is samueljh1_
    Last edited: Mar 5, 2015
  2. Dinokiller
    Offline

    Dinokiller Notable Member

    Joined:
    Sep 22, 2013
    Posts:
    376
    Minecraft User:
    Dinokiller_
    What is the value of $p?
  3. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    samueljh1_
  4. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    And what variable did you print with var_dump?
  5. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    var_dump($bc->get("money"));

    this is the config:

    PHP:
    ---
    version2
    money
    :
      
    samueljh15.000000
      samueljh1_sdf
    100.000000
      steve
    : -500.000000
      samueljh1_
    1000.000000
      frazo_06130
    1000.000000
    debt
    :
      
    samueljh10.000000
      samueljh1_sdf
    0.000000
      samueljh1_
    0.000000
      frazo_06130
    0.000000
    ...
  6. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    look at the bit after the error, i edited it
  7. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    Hmm...
    Instead of
    PHP:
    $bc->get('money')[strtolower($p)];
    Try with
    PHP:
    $test $bc->getAll();
    return 
    $test['money'][strtolower($p)];
  8. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    i have done that too. and did you read what i said? after the error
  9. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    Hmm...
    Add
    PHP:
    $p "samueljh1_";
    Before the $bc->get line
  10. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    "samueljh1_" , but its a returned value of player->getName()
  11. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    Yes but try to assign a string because the problem can be also on player->getName()
  12. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    ok ill try that :) also, i am using strtolower($p)
  13. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    that works, its an issue with getName()
    EvolSoft likes this.
  14. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    No problem
  15. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    Yes. Maybe you made some mistakes getting player
  16. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    so , how can i fix this! :eek:
  17. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    Can you post the code about $player variable declaration?
  18. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    its this:

    PHP:
    $sender->sendMessage($this->getPlayerMoney("Money: " $sender->getPlayer()->getName()));
    and i tried this

    PHP:
    $sender->sendMessage($this->getPlayerMoney("Money: " $sender->getName()));
  19. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    OHHHH I worked it out!!! i put the input "Money:" and then the name! xD
  20. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    Good :D

Share This Page

Advertisement