本文整理汇总了PHP中Shadowfunc::getTarget方法的典型用法代码示例。如果您正苦于以下问题:PHP Shadowfunc::getTarget方法的具体用法?PHP Shadowfunc::getTarget怎么用?PHP Shadowfunc::getTarget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shadowfunc
的用法示例。
在下文中一共展示了Shadowfunc::getTarget方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public static function execute(SR_Player $player, array $args)
{
$p = $player->getParty();
if (false === ($location = $p->getLocationClass('outside'))) {
return self::rply($player, '1031');
// return $player->message('This command only works when you are outside a location.');
}
$bot = Shadowrap::instance($player);
$loc = $location->getName();
if (count($args) > 1) {
return $bot->reply(Shadowhelp::getHelp($player, 'hijack'));
}
$victims = array();
foreach (Shadowrun4::getParties() as $pa) {
$pa instanceof SR_Party;
if (false === ($city = $pa->getCityClass())) {
continue;
# not even city
}
# Hax!
if ($city->isDungeon() && $city->getCityLocation() === $loc || $pa->getLocation('inside') === $loc) {
foreach ($pa->getMembers() as $pl) {
$pl instanceof SR_Player;
if ($pl->hasEquipment('mount')) {
$victims[] = $pl;
}
}
}
}
if (count($victims) === 0) {
self::rply($player, '5128');
return false;
// return $player->message('You see no mounts from other players to rob.');
}
$format = $player->lang('fmt_sumlist');
if (count($args) === 0) {
$out = '';
foreach ($victims as $i => $victim) {
$victim instanceof SR_Player;
$mount = $victim->getMount();
$out .= sprintf($format, $i + 1, $victim->getName(), $mount->getName());
// $out .= sprintf(", \x02%s\x02-%s(%s)", ($i+1), $victim->getName(), $mount->getName());
}
return self::rply($player, '5130', array(ltrim($out, ',; ')));
// return $bot->reply(substr($out, 2));
}
if (false === ($target = Shadowfunc::getTarget($victims, $args[0], true))) {
self::rply($player, '5128');
// $player->message('You see no mounts from other players to rob.');
return false;
}
$mount = $target->getMount();
if ($mount->getMountWeight() === 0) {
self::rply($player, '1037');
// $player->message('This mount cannot store anything.');
return false;
}
return $mount->initHijackBy($player);
}
示例2: getMemberByName
/**
* @param string $name
* @return SR_Player
*/
public function getMemberByName($name)
{
return Shadowfunc::getTarget($this->getMembers(), $name, false);
}