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

Solved If function does not work...

Comments in 'Plugin Development' started by Tim // robske Büba, Dec 17, 2015.

  1. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Don't know why the server just screams out both Messages...
    upload_2015-12-17_15-13-50.png
  2. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    What do you mean by it doesn't work? if $tps more than or equals to 10 AND $load less than or equals to 90, the server will display both messages
  3. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    I want to do:
    If the load is over or equal 90 it should show the messages
    And if the tps is below or equal 10 it should show the messages...
  4. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    learn PHP and use an else() statement.
  5. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    What did i do with the if statements?
    I come from c++/c devoping and have no idea why else should be useful here.
  6. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    Do you mean
    PHP:
    if($tps <= 10$this->getServer()->broadcastMessage("TPS below 10");
    elseif(
    $load >= 90$this->getServer()->broadcastMessage("Load above 90");
  7. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Yeah i meant that

    Thanks!
    But why elseif? Never used it anywhere...
  8. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    It is so that only one part of the code is run
  9. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Thanks guys for your quick resoponses!
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Basically it is like a fallback system. If first condition is true, run something, but otherwise, fallback to the second condition and run something if it is true.
  11. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Thanks for the explanation :)
    I am just starting with php and that "efficient" programming (My old c++ programms liked to hang around in loops)
    PEMapModder likes this.
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Welcome to PHP. This is a place where everything should only be small things and it makes no sense to use threads and do optimization and stuff. Actually, the PocketMine project was started in PHP because it was meant to be small things that wouldn't be used in production. https://botbot.me/freenode/pocketmine/2015-01-12/?msg=29344826&page=2

Share This Page

Advertisement