本文整理汇总了PHP中Shadowrun4::getPlayerByShortName方法的典型用法代码示例。如果您正苦于以下问题:PHP Shadowrun4::getPlayerByShortName方法的具体用法?PHP Shadowrun4::getPlayerByShortName怎么用?PHP Shadowrun4::getPlayerByShortName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shadowrun4
的用法示例。
在下文中一共展示了Shadowrun4::getPlayerByShortName方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public static function execute(SR_Player $player, array $args)
{
$bot = Shadowrap::instance($player);
if (count($args) !== 1) {
$bot->reply(Shadowhelp::getHelp($player, 'gmp'));
return false;
}
if (false === ($target = Shadowrun4::getPlayerByShortName($args[0]))) {
$bot->reply(sprintf('The user %s is unknown.', $args[0]));
return false;
} elseif ($target === -1) {
$bot->reply('The player name is ambigious.');
return false;
}
if (false === $target->isCreated()) {
$bot->reply(sprintf('The player %s has not started a game yet.', $args[0]));
return false;
}
$p = $target->getParty();
$a = $p->getAction();
if ($a !== SR_Party::ACTION_INSIDE && $a !== SR_Party::ACTION_OUTSIDE) {
$bot->reply('The party with ' . $args[0] . ' is moving.');
return false;
}
$p->pushAction(SR_Party::ACTION_INSIDE, 'Prison_Block1');
}
示例2: execute
public static function execute(SR_Player $player, array $args)
{
$bot = Shadowrap::instance($player);
if (count($args) !== 2) {
$bot->reply(Shadowhelp::getHelp($player, 'gmloot'));
return false;
}
$target = Shadowrun4::getPlayerByShortName($args[0]);
if ($target === -1) {
$player->message('The username is ambigious.');
return false;
}
if ($target === false) {
$player->message('The player is not in memory or unknown.');
return false;
}
if (false === $target->isCreated()) {
$bot->reply(sprintf('The player %s has not started a game yet.', $args[0]));
return false;
}
if (Common::isNumeric($args[1])) {
$target->giveItems(Shadowfunc::randLoot($target, $args[1]), 'gmloot');
} else {
}
return true;
}
示例3: execute
public static function execute(SR_Player $player, array $args)
{
$bot = Shadowrap::instance($player);
if (count($args) < 2 || count($args) > 3) {
$bot->reply(Shadowhelp::getHelp($player, 'gmi'));
return false;
}
$target = Shadowrun4::getPlayerByShortName($args[0]);
if ($target === -1) {
$player->message('The username is ambigious.');
return false;
}
if ($target === false) {
$player->message('The player is not in memory or unknown.');
return false;
}
if (false === $target->isCreated()) {
$bot->reply(sprintf('The player %s has not started a game yet.', $args[0]));
return false;
}
if (false === ($item = SR_Item::createByName($args[1]))) {
$bot->reply(sprintf('The item %s could not be created.', $args[1]));
return false;
}
if (isset($args[2])) {
if (!$item->isItemStackable()) {
$bot->reply('No amount for equipment!');
return false;
}
$item->saveVar('sr4it_amount', intval($args[2]));
}
$b = chr(2);
$target->giveItems(array($item), sprintf("{$b}[GM]_%s{$b}", $player->getName()));
return true;
}
示例4: getClanByPName
/**
* Get a clan by playerid.
* @param int $pid
* @return SR_Clan
*/
public static function getClanByPName($pname)
{
echo "TRY PID {$pname}\n";
if (false === ($player = Shadowrun4::getPlayerByShortName($pname))) {
return false;
} elseif ($player === -1) {
return false;
}
return self::getClanByPID($player->getID());
}
示例5: execute
public static function execute(SR_Player $player, array $args)
{
$bot = Shadowrap::instance($player);
if (count($args) < 2 || count($args) > 3) {
$bot->reply(Shadowhelp::getHelp($player, 'gml'));
return false;
}
$action = SR_Party::ACTION_OUTSIDE;
if (count($args) > 2) {
switch ($args[2]) {
case SR_Party::ACTION_INSIDE:
case SR_Party::ACTION_OUTSIDE:
$action = $args[2];
break;
default:
$bot->reply(Shadowhelp::getHelp($player, 'gml'));
return false;
}
}
if (false === ($target = Shadowrun4::getPlayerByShortName($args[0]))) {
$bot->reply(sprintf('The user %s is unknown.', $args[0]));
return false;
} elseif ($target === -1) {
$bot->reply('The player name is ambigious.');
return false;
}
if (false === $target->isCreated()) {
$bot->reply(sprintf('The player %s has not started a game yet.', $args[0]));
return false;
}
$p = $target->getParty();
$a = $p->getAction();
if ($a !== SR_Party::ACTION_INSIDE && $a !== SR_Party::ACTION_OUTSIDE) {
$bot->reply('The party with ' . $args[0] . ' is moving.');
return false;
}
if (false === ($location = self::getLocationByAbbrev($p->getCity(), $args[1]))) {
$bot->reply('What location?');
return false;
}
$p->pushAction(SR_Party::ACTION_DELETE);
$cl = $location->getName();
$p->pushAction($action, $cl);
$bot->reply(sprintf('The party is now %s of %s.', $action, $cl));
$p->giveKnowledge('places', $cl);
return true;
}
示例6: execute
public static function execute(SR_Player $player, array $args)
{
# Syntax
if (count($args) !== 2) {
self::reply($player, Shadowhelp::getHelp($player, 'gmul'));
return false;
}
# Args
if (false === ($target = Shadowrun4::getPlayerByShortName($args[0]))) {
self::rply($player, '1017');
return false;
} elseif ($target === -1) {
self::rply($player, '1018');
return false;
}
# Valid cost?
$field = $args[1];
if (false === ($cost = Shadowcmd_lvlup::getKarmaCostFactor($field))) {
self::rply($player, '1024');
return false;
}
# Gather data
if (false !== ($spell = $target->getSpell($field))) {
$have_level = $target->getSpellBaseLevel($field);
$is_spell = true;
} else {
$have_level = $target->getBase($field);
$is_spell = false;
}
$karma_back = $cost * $have_level;
# Limit
if ($have_level <= 0) {
self::reply($player, 'Lowered to 0 already!');
return false;
}
# Apply
if ($is_spell === true) {
$target->levelupSpell($field, -1);
} else {
$target->increaseField($field, -1);
}
$target->increaseField('karma', $karma_back);
$target->modify();
# Announce
return self::reply($player, sprintf('%s reverted %s back to level %s and got %s karma back.', $target->getName(), $field, $have_level - 1, $karma_back));
}
示例7: execute
public static function execute(SR_Player $player, array $args)
{
$bot = Shadowrap::instance($player);
$p = $player->getParty();
if (count($args) !== 1) {
$bot->reply(Shadowhelp::getHelp($player, 'hunt'));
return false;
}
if (false === self::checkLeader($player)) {
return false;
}
if (false === self::checkMove($p)) {
return false;
}
$target = Shadowrun4::getPlayerByShortName($args[0]);
if ($target === false) {
self::rply($player, '1017');
// $bot->reply('This player is not in memory.');
return false;
} elseif ($target === -1) {
self::rply($player, '1018');
// $bot->reply('The player name is ambigous. Try the {server} version.');
return false;
}
$name = $target->getName();
$p = $player->getParty();
$ep = $target->getParty();
if ($p->getID() === $ep->getID()) {
self::rply($player, '1083');
// $bot->reply('You cannot hunt own party members.');
return false;
}
if ($p->getCity() !== $ep->getCity()) {
self::rply($player, '1084', array($name, $p->getCity(), $name, $ep->getCity()));
// $bot->reply(sprintf('You cannot hunt %s because you are in %s and %s is in %s.', $name, $p->getCity(), $name, $ep->getCity()));
return false;
}
$city = $p->getCityClass();
$eta = round($city->getExploreETA($p) * 1.2);
$p->pushAction(SR_Party::ACTION_HUNT, $target->getName() . ' in ' . $city->getName(), $eta);
$p->setContactEta(rand(10, 20));
$p->ntice('5134', array($target->getName(), GWF_Time::humanDuration($eta)));
// $p->notice(sprintf('You start to hunt %s. ETA: %s.', $target->getName(), GWF_Time::humanDuration($eta)));
return true;
}
示例8: execute
public static function execute(SR_Player $player, array $args)
{
if (count($args) !== 2) {
$player->message(Shadowhelp::getHelp($player, 'gmns'));
return false;
}
$username = $args[0];
$remote = Shadowrun4::getPlayerByShortName($username);
if ($remote === -1) {
$player->message('The username is ambigious.');
return false;
}
if ($remote === false) {
$player->message('The player is not in memory or unknown.');
return false;
}
return self::onGMNS($player, $remote, $args[1]);
}
示例9: execute
public static function execute(SR_Player $player, array $args)
{
$bot = Shadowrap::instance($player);
# Own info
if (count($args) === 0) {
return self::showClanInfo($player, $player);
}
# 1 Numeric == clan history.
if (count($args) === 1 && Common::isNumeric($args[0])) {
if ($args[0] < 1) {
$bot->reply(Shadowhelp::getHelp($player, 'clan'));
return false;
}
return self::showHistoryPage($player, (int) $args[0]);
}
# !members shows your clan members.
if (count($args) === 1 || count($args) === 2) {
if ($args[0] === '!m' || $args[0] === '!members') {
$page = isset($args[1]) ? (int) $args[1] : 1;
return self::showMembers($player, $page);
}
}
# Show another player.
if (count($args) !== 1) {
$bot->reply(Shadowhelp::getHelp($player, 'clan'));
return false;
}
if (false === ($target = Shadowrun4::getPlayerByShortName($args[0]))) {
self::rply($player, '1017');
// $bot->reply('This player is unknown or not in memory.');
return false;
} else {
if ($target === -1) {
self::rply($player, '1018');
// $bot->reply('This playername is ambigous.');
return false;
}
}
return self::showClanInfo($player, $target);
}
示例10: execute
public static function execute(SR_Player $player, array $args)
{
$bot = Shadowrap::instance($player);
if (count($args) < 2 || count($args) > 3) {
$bot->reply(Shadowhelp::getHelp($player, 'gm'));
return false;
}
$target = Shadowrun4::getPlayerByShortName($args[0]);
if ($target === -1) {
$player->message('The username is ambigious.');
return false;
}
if ($target === false) {
$player->message('The player is not in memory or unknown.');
return false;
}
if (false === $target->isCreated()) {
$bot->reply(sprintf('The player %s has not started a game yet.', $args[0]));
return false;
}
$var = $args[1];
if (!$target->hasVar('sr4pl_' . $var)) {
$bot->reply(sprintf('The var %s does not exist.', $var));
return false;
}
$old = $target->getVar('sr4pl_' . $var);
if (count($args) === 2) {
$bot->reply(sprintf('Var %s of %s is set to %s.', $var, $target->getUser()->getName(), $old));
return true;
}
$new = $args[2];
$target->updateField($var, $new);
if ($var === 'const_vars') {
$target->reloadConstVars();
} else {
$target->modify();
}
return $bot->reply(sprintf('Set %s`s %s from %s to %s.', $target->getUser()->getName(), $var, $old, $new));
}
示例11: execute
public static function execute(SR_Player $player, array $args)
{
$bot = Shadowrap::instance($player);
if (count($args) !== 1) {
$bot->reply(Shadowhelp::getHelp($player, 'gmstats'));
return false;
}
if (false !== ($npc = Shadowrun4::getPlayerByShortName($args[0]))) {
} elseif ($npc === -1) {
$bot->reply('The playername is ambigious.');
return false;
} elseif (false !== ($npc = Shadowrun4::getPlayerByPID($args[0]))) {
} else {
$bot->reply('The player ' . $args[0] . ' is not in memory.');
return false;
}
self::reply($player, Shadowfunc::getStatus($npc, '5301'));
self::reply($player, Shadowfunc::getEquipment($npc, '5303'));
self::reply($player, Shadowfunc::getAttributes($npc, '5304'));
self::reply($player, Shadowfunc::getSkills($npc, '5305'));
// $bot->reply(sprintf('Party: %s.', Shadowfunc::getPartyStatus($npc)));
return true;
}
示例12: execute
public static function execute(SR_Player $player, array $args)
{
$c = count($args);
if ($c < 2) {
$player->message(Shadowhelp::getHelp($player, 'whisper'));
return false;
}
$name = array_shift($args);
$message = implode(' ', $args);
// if (self::whisperToRealNPC($player, $name, $message))
// {
// return true;
// }
$result = Shadowrun4::getPlayerByShortName($name);
if ($result === false) {
return $player->msg('1017');
// return $player->message('The player is unknown or not in memory.');
} elseif ($result === -1) {
return $player->msg('1018');
// return $player->message('The player name is ambigous. Try the {server} version.');
} else {
return self::onWhisper($player, $result, $message);
}
}
示例13: execute
public static function execute(SR_Player $player, array $args)
{
$bot = Shadowrap::instance($player);
if (count($args) < 2 || count($args) > 4) {
$bot->reply(Shadowhelp::getHelp($player, 'gmq'));
return false;
}
$target = Shadowrun4::getPlayerByShortName($args[0]);
if ($target === -1) {
$player->message('The username is ambigious.');
return false;
}
if (false === $target) {
$player->message('The player is not in memory or unknown.');
return false;
}
if (false === $target->isCreated()) {
$bot->reply(sprintf('The player %s has not started a game yet.', $args[0]));
return false;
}
$questname = $args[1];
$quests = SR_Quest::getQuests();
if (false === array_key_exists($questname, $quests)) {
$bot->reply(sprintf('The quest %s does not exist.', $args[1]));
return false;
}
$quest = $quests[$questname];
$internalname = substr(get_class($quest), 6);
if (false === ($quest = SR_Quest::getQuest($target, $internalname))) {
$bot->reply(sprintf('Cannot get quest %s. (Should not happen.)', $args[1]));
return false;
}
$questname = $quest->getQuestName();
if (count($args) === 2) {
$old = $quest->getOptions();
$bot->reply(sprintf('Quest %s of %s has status 0x%x (%s).', $questname, $target->getUser()->getName(), $old, SR_Quest::optionsToString($old)));
return true;
}
if (strtolower($args[2]) === 'amount') {
$old = $quest->getAmount();
if (count($args) === 3) {
$bot->reply(sprintf('Quest %s of %s has amount %d.', $questname, $target->getUser()->getName(), $old));
return true;
}
$new = (int) $args[3];
$quest->saveAmount($new);
$bot->reply(sprintf('Set amount of quest %s of %s from %d to %d.', $questname, $target->getUser()->getName(), $old, $new));
return true;
} elseif (strtolower($args[2]) === 'data') {
$old = $quest->getQuestDataBare();
if (count($args) === 3) {
$msg = sprintf('Quest %s of %s has ', $questname, $target->getUser()->getName());
if (NULL !== $old) {
$msg .= "has data {$old}.";
} else {
# XXX Perhaps show serialisation of getQuestData (array()) in this case?
$msg .= 'no data.';
}
$bot->reply($msg);
return true;
}
$new = $args[3];
if ($new === serialize(false)) {
$new = false;
} elseif (false === ($new = unserialize($new))) {
$bot->reply('Invalid serialized data supplied!');
return false;
}
$quest->saveQuestData($new);
$new = $quest->getQuestDataBare();
$bot->reply(sprintf('Set data of quest %s of %s from %s to %s.', $questname, $target->getUser()->getName(), $old, $new));
return true;
}
# Not amount or data --> set status
$old = $quest->getOptions();
$new = $args[2] * 1;
# XXX ugly conversion to int (allowing "0x...")
$quest->saveOption(-1, false);
# first clear all bits
$quest->saveOption($new);
$bot->reply(sprintf('Set status of quest %s of %s from 0x%x to 0x%x.', $questname, $target->getUser()->getName(), $old, $new));
return true;
}
示例14: execute
public static function execute(SR_Player $player, array $args)
{
$bot = Shadowrap::instance($player);
if (count($args) !== 2) {
$bot->reply(Shadowhelp::getHelp($player, 'gmt'));
return false;
}
$target = Shadowrun4::getPlayerByShortName($args[0]);
if ($target === -1) {
$player->message('The username is ambigious.');
return false;
}
if ($target === false) {
$player->message('The player is not in memory or unknown.');
return false;
}
if (false === $target->isCreated()) {
$bot->reply(sprintf('The player %s has not started a game yet.', $args[0]));
return false;
}
# Check for valid enemies.
$npcnames = explode(',', $args[1]);
foreach ($npcnames as $i => $npcname) {
if (false === ($npc = Shadowrun4::getNPCByAbbrev($player, $npcname))) {
$bot->reply(sprintf('Unknown NPC: %s.', $npcname));
return false;
}
$npcnames[$i] = $npc->getNPCClassName();
}
# Prepare for action cases
$p = $target->getParty();
$a = $p->getAction();
$ep = NULL;
switch ($a) {
case SR_Party::ACTION_TALK:
$p->getEnemyParty()->popAction(true);
# we pop the enemies talking
# we pop the enemies talking
case SR_Party::ACTION_SLEEP:
$p->popAction(false);
# and pop our own fallthrough
break;
case SR_Party::ACTION_FIGHT:
$ep = $p->getEnemyParty();
# Stack and re-init the fight :)
break;
# Nothing todo here
# Nothing todo here
case SR_Party::ACTION_INSIDE:
case SR_Party::ACTION_OUTSIDE:
case SR_Party::ACTION_EXPLORE:
case SR_Party::ACTION_GOTO:
case SR_Party::ACTION_HUNT:
break;
# Impossibru
# Impossibru
case SR_Party::ACTION_HIJACK:
case SR_Party::ACTION_TRAVEL:
case SR_Party::ACTION_DELETE:
default:
$bot->reply('Cannot #gmt because target action is ' . $a . '!');
return false;
}
# Generate NPCs
if (false === ($ep2 = SR_NPC::createEnemyParty($npcnames))) {
$bot->reply('cannot create party! check logs');
return false;
}
# Merge?
if ($ep === NULL) {
$ep = $ep2;
} else {
$ep->mergeParty($ep2);
}
# Delegate new actions
if ($p->isFighting()) {
# Already fighting
$p->popAction(false);
$p->fight($ep, true);
} elseif ($ep->getLeader() instanceof SR_TalkingNPC) {
# Init a talk
$p->talk($ep, true);
} else {
# Init a fight
$p->fight($ep, true);
}
# That's it!
return $bot->reply('The party now encountered some enemies!');
}