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

Solved Economy Issue

Discussion in 'Development' started by Astro, Feb 3, 2019.

  1. Astro

    Astro Slime

    Messages:
    78
    GitHub:
    RealAstro
    error:
    InfernalCore\Player\HestraPlayer::addMoney() must be of the type float, string given, called in /plugins/HestraCore/src/InfernalCore/Economy/giveMoney.php on line 51" (EXCEPTION) in "HestraCore/src/InfernalCore/Player/HestraPlayer" at line 154

    code:
    PHP:
    public function takeMoney(float $balance): bool{
       
    $data $this->getData();
       
    $new $this->getBalance() - $balance;
       
    $data->set("balance"$new);
       
    $data->save();
       
    $this->updateScoreboard();
       return 
    true;
    }
    PHP:
            $target->addMoney($args[1]);
            
    $sender->takeMoney($args[1]);
            
    $sender->sendMessage(Main::PREFIX " §7You have paid " $target->getName() . " §e$" $args[1]);
            
    $target->sendMessage(Main::PREFIX " §7You have received §e$" $args[1] . " §7from " $sender->getName());
     
    Last edited: Feb 3, 2019
  2. Zach1603

    Zach1603 Spider Jockey

    Messages:
    27
    GitHub:
    zedstar16
    PHP:
            $target->addMoney(floatval($args[1]));
     
     
  3. Diduhless

    Diduhless Baby Zombie

    Messages:
    199
    GitHub:
    Diduhless
    I'd rather using (float) $var instead, it's faster than floatval()
    PHP:
    (float) $args[1]
     
    Zach1603 likes this.
  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.