Whenever my sendMessage function executes, it sends 4 messages insetad of one, heres my code if you need it Code: if((mt_rand($stone->get("itemchance"), 100) === 100)) { foreach ($stone->get("items") as $item) { $item1 = intval($item); if($this->invFull($p)) { $p->sendMessage($title . "You found a lucky block item, but your inventory was full!"); }else{ $p->sendMessage($lbmsg); $p->getInventory()->addItem(Item::get($item1)); } } }
because $stone->get("items") returns an array of 4 values, and the foreach loops accordingly you can escape this loop by doing PHP: if((mt_rand($stone->get("itemchance"), 100) === 100)){ foreach($stone->get("items") as $itemId){ $itemId = intval($itemId); if(!$this->invFull($p){ $p->sendMessage($lbmsg); $p->getInventory()->addItem(Item::get($itemId)); }else{ $p->sendMessage($title . "You found a lucky block item, but your inventory was full!"); break; } }}