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 'Facepalm' 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. 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.