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

Error in plugin

Comments in 'Plugin Development' started by Kabluinc, Aug 27, 2016.

  1. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    String literal quotes?!!
  2. Kabluinc
    Offline

    Kabluinc New Member

    Joined:
    Mar 2, 2016
    Posts:
    29
    Minecraft User:
    Kabluinc
    @Ragnok1233 so if i use your code and send a popup to player $theme will the theme keep changing to a new random one or stay as one theme for the whole game time?

    The problem i currently have is that i have themes written as $themes = array("car, pet"); etc then i do $theme = $themes[rand(0, 2)]; but when i do $pl->sendPopup("Theme:" .$theme.); it keeps showing a diffrent random theme each time the popup refreshes

    Will your code u gave me not keep refreshing with a new theme each second?
    Last edited: Aug 29, 2016
  3. Ragnok1234
    Offline

    Ragnok1234 Active Member

    Joined:
    Jul 18, 2016
    Posts:
    53
    Minecraft User:
    Ragnok123
    Yes, but only with this, if mt_rand isnt in Task.
  4. Ragnok1234
    Offline

    Ragnok1234 Active Member

    Joined:
    Jul 18, 2016
    Posts:
    53
    Minecraft User:
    Ragnok123
    If my random is in task, it will showed in every ticks, that are in your task
  5. Ragnok1234
    Offline

    Ragnok1234 Active Member

    Joined:
    Jul 18, 2016
    Posts:
    53
    Minecraft User:
    Ragnok123
    Example i have:
    PHP:
     public function blockBreak(BlockBreakEvent $e){
    $p=$e->getPlayer();
    $b=$e->getBlock();
    $rand=mt_rand(14);
    switch(
    $rand){
      case 
    1:
    $block 56;
    break;
    case 
    2:
    $block 1;
    break;
    case 
    3:
    $block 1;
    break;
    case 
    4:
    $block 1;
    break;
    }
    if(
    $b->getId() == 1){
    $this->getServer()->getDefaulLevel()->setBlock(new Vector 3($b->getX(), $b->getY(), $b->getZ() + 1), Block::get($block0));
    }
    }











  6. Kabluinc
    Offline

    Kabluinc New Member

    Joined:
    Mar 2, 2016
    Posts:
    29
    Minecraft User:
    Kabluinc
    So how can i have the rand theme sonewhere in the code where there isnt a task but be able to $pl->sendPopup($theme) all throughout the game?

    I tried putting the random theme code in if($time==619)
    but if i also put the player send popup here, it only displays it for 1 second

    How can i make the get random theme only happen once but send player theme many times

    I tried putting $pl->sendPopup($theme); in if($time>=619) so that it gets a theme in the previous statement ($time==619) and sends a popup all the way from 619 to 0..

    But it showed undefined variable $theme in console on the popup line
  7. Kabluinc
    Offline

    Kabluinc New Member

    Joined:
    Mar 2, 2016
    Posts:
    29
    Minecraft User:
    Kabluinc
  8. Kabluinc
    Offline

    Kabluinc New Member

    Joined:
    Mar 2, 2016
    Posts:
    29
    Minecraft User:
    Kabluinc
    Solved. Thanks allot for all your help

Share This Page

Advertisement