本文整理汇总了PHP中SR_Player::getInvItem方法的典型用法代码示例。如果您正苦于以下问题:PHP SR_Player::getInvItem方法的具体用法?PHP SR_Player::getInvItem怎么用?PHP SR_Player::getInvItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SR_Player
的用法示例。
在下文中一共展示了SR_Player::getInvItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: giveItem
public static function giveItem(SR_Player $player, SR_Player $target, $id, $amt = 1)
{
if ($amt < 1) {
$player->msg('1038');
// $player->message('Please give a positive amount of items.');
return false;
}
if (false === ($item = $player->getInvItem($id))) {
$player->msg('1029');
// $player->message('You don`t have that item.');
return false;
}
// if (false === $item->isItemTradeable())
// {
// $player->message('You are not allowed to trade this item.');
// return false;
// }
if ($item->isItemStackable()) {
if ($amt > $item->getAmount()) {
$player->msg('1040', array($item->getItemName()));
// $player->message(sprintf('You only have %d %s.', $item->getAmount(), $item->getName()));
return false;
}
$giveItem = SR_Item::createByName($item->getItemName(), $amt, true);
$item->useAmount($player, $amt);
} else {
if ($amt !== 1) {
$player->message('Currently you can only give one equipment at a time.');
return false;
}
$player->removeFromInventory($item);
$giveItem = $item;
}
$busymsg = $player->isFighting() ? Shadowfunc::displayBusy($player->busy(SR_Player::GIVE_TIME)) : '';
self::rply($player, '5115', array($amt, $giveItem->displayFullName($player), $target->getName(), $busymsg));
// $player->message(sprintf('You gave %d %s to %s.%s', $amt, $giveItem->getName(), $target->getName(), $busymsg));
$target->giveItems(array($giveItem), $player->getName());
// if ($target instanceof SR_TalkingNPC)
// {
// $target->onNPCGive($player, $items);
// }
return true;
}
示例2: giveQuesties
public function giveQuesties(SR_Player $player, $itemname, $have, $need)
{
$left = $need - $have;
$give = 0;
while ($left > 0) {
if (false === ($item = $player->getInvItem($itemname))) {
break;
}
$possible = Common::clamp($item->getAmount(), 0, $left);
$item->useAmount($player, $possible);
$give += $possible;
$left -= $possible;
$have += $possible;
}
if ($give > 0) {
$player->msg('5239', array($give, $itemname, $this->getName()));
}
return $have;
}