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

FormAPI math not working

Discussion in 'Development' started by xXNiceAssassinlo YT, Jun 28, 2018.

  1. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    it sets my config to
    PHP:
    coins988.000000
    i want
    PHP:
    coins988
    and the mutlipe thingy wont work
    code:
    PHP:
                    $cfg->set("coins"$cfg->get("coins") - Shop::get()->pay $data[0]);
                    
    $cfg->save();
                    
    $inv->addItem($item);
                    
    $player->sendMessage(C::GREEN "You bought $data[0] " $item->getName() . "'s for " Shop::get()->pay $data[0] . " coins.");
    it wont multipe $data[0] and the pay
     
  2. Marabou

    Marabou Baby Zombie

    Messages:
    137
    GitHub:
    wiligangster
    Use the function round()
     
  3. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
  4. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Screenshot_20180629-025239_Chrome.jpg
     
    corytortoise likes this.
  6. Marabou

    Marabou Baby Zombie

    Messages:
    137
    GitHub:
    wiligangster
  7. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    The round is still unneeded here
     
    jasonwynn10 likes this.
  8. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    (int) only truncates the number. It doesn't round the number. They are different behaviours. Not that I am saying which one is working.
     
    jasonwynn10 likes this.
  9. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Fair point, don't really know what the integer should be rounded to but he only specified a number with trailing zeroes and wanted to remove the zeroes, so I guess an int casting would be sufficient from the information given.
     
    jasonwynn10 and HimbeersaftLP like 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.