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

Random Popup

Comments in 'Plugin Development' started by KekerFamily, Dec 2, 2015.

  1. KekerFamily
    Offline

    KekerFamily New Member

    Joined:
    Nov 12, 2015
    Posts:
    12
    Minecraft User:
    Keker
    How to randomly popup?
    Help me please
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    What do you mean with "a random popup"? Please be more specific.
  3. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    PHP:
    switch (mt_rand(1,2)){
    case 
    1// random 1
    $p->sendPopup("By Nawaf");
    break;
    case 
    2:// random 2
    $p->sendPopup("Love");
    break;
    }
    KekerFamily likes this.
  4. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    Don't forget to define $p (which in this case, is a Player), you can simply define $p with whichever Event, you decide to choose.

    PHP:
    public function onDeath(PlayerDeathEvent $event){ //is used when the player dies
    $p $event->getPlayer(); //gets the players, when the player dies
    //code
    }
    Also please don't forget to registerEvents in onEnable
    KekerFamily likes this.
  5. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    PlayerDeathEvent doesn't make sense in that case. :p
  6. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    Agreed, Im thinking of RepeatingTask as he is saying random popup :p
  7. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    It does... He just wants to send a popup
  8. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Nop. Sending a popup to a dead player doesn't make sense, does it?
    Andrey Nazarchuk likes this.
  9. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    Sorry I have been thinking of Player respawning

Share This Page

Advertisement