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

how do i randomly pick something from an array and set it to a variable for PlayerInteractEvent

Discussion in 'Development' started by abimalek, Oct 12, 2017.

  1. abimalek

    abimalek Witch

    Messages:
    74
    GitHub:
    megagastpvp
    I'm trying to make a cratekey plugin and I need to know how to randomly get something from an array and set it to a variable and it will become a variable every time someone touches the crate so its random
     
  2. QuiverlyRivalry

    QuiverlyRivalry Zombie Pigman

    Messages:
    491
    GitHub:
    quiverlyrivalry
    Am I living in the future or did someone else ask the exact same thing?
     
  3. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    Muqsit and Sandertv like this.
  4. abimalek

    abimalek Witch

    Messages:
    74
    GitHub:
    megagastpvp
    pls help
     
  5. QuiverlyRivalry

    QuiverlyRivalry Zombie Pigman

    Messages:
    491
    GitHub:
    quiverlyrivalry
  6. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    PHP:
    $stuff = ["Juice""dktapps""shoghicp"];
    $randomstuff $stuff[array_rand($stuff)];
    The event for touching blocks is PlayerInteractEvent, there are many resources to find out how to use it
     
  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.