Skip to content

Instantly share code, notes, and snippets.

@Omattyao
Last active January 2, 2016 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Omattyao/8267515 to your computer and use it in GitHub Desktop.
Save Omattyao/8267515 to your computer and use it in GitHub Desktop.
<?php
$username = "Steve"; //対象プレイヤー名
$id = 1; //対象アイテムをIDで指定
$amount = 10; //個数
$player = $this->api->player->get($username);
foreach ($player->inventory as $slot => $item) {
if ($item->getID() == $id) {
while ($item->count >= 1 and $amount >= 1) {
--$item->count;
--$amount;
}
//追加のひと手間
if ($item->count < 1) {
$player->inventory[$slot] = new AirBlock();
}
//ここまで
if ($amount < 1) {
break;
}
}
}
$player->sendInventorySlot();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment