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

setDrops()

Discussion in 'Development' started by abimalek, Dec 28, 2017.

  1. abimalek

    abimalek Witch

    Messages:
    74
    GitHub:
    megagastpvp
    how would I setDrop the already existing drops and an item I tried $e->setDrops([$item, $e->getDrops()]); but only droped the $item
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Teamblocket and OnTheVerge like this.
  3. abimalek

    abimalek Witch

    Messages:
    74
    GitHub:
    megagastpvp
    I fixed it I used
    Code:
    $drop = $e->getDrops();
    $d = array_push($drops, $item);
    [CODE]
     
  4. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    There's nothing wrong doing it that way but if performance is one of your priorities, then you are better off using square brackets.
    Screenshot_20171229-100233.jpg

    "Note: If you use array_push() to add one element to the array it's better to use $array[] = because in that way there is no overhead of calling a function."
     
    Teamblocket likes this.
  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.