本文整理汇总了PHP中SR_Player::getByID方法的典型用法代码示例。如果您正苦于以下问题:PHP SR_Player::getByID方法的具体用法?PHP SR_Player::getByID怎么用?PHP SR_Player::getByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SR_Player
的用法示例。
在下文中一共展示了SR_Player::getByID方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cleanupPlayers
private static function cleanupPlayers()
{
echo __METHOD__ . PHP_EOL;
$players = GDO::table('SR_Player');
$before = $players->countRows();
if (false === ($result = $players->select('sr4pl_id, sr4pl_partyid'))) {
echo GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
return;
}
$sr_time = Shadowrun4::getTime();
while (false !== ($row = $players->fetch($result, GDO::ARRAY_N))) {
if (false !== ($player = SR_Player::getByID($row[0]))) {
if (false === SR_Party::getByID($player->getPartyID())) {
if ($player->isHuman()) {
printf("WARNING: %s has not party!!\n", $player->getName());
} else {
$player->delete();
}
}
}
}
$players->free($result);
$after = $players->countRows();
printf("I removed %s players from the database and %s are left.\n", $before - $after, $after);
}
示例2: getRequest
/**
* Get the player for a join request.
* @param SR_Player $leader
* @param SR_Clan $clan
* @param string $pname
* @return SR_Player
*/
public static function getRequest(SR_Player $leader, SR_Clan $clan, $pname)
{
$ename = GDO::escape($pname);
if (false === ($pid = self::table(__CLASS__)->selectVar('sr4cr_pid', "sr4cr_pname='{$ename}'"))) {
return false;
}
if (false === ($player = Shadowrun4::getPlayerByPID($pid))) {
if (false === ($player = SR_Player::getByID($pid))) {
return false;
}
}
return $player;
}
示例3: cleanupItemsForPlayer
private static function cleanupItemsForPlayer($player_id)
{
if (false === ($player = SR_Player::getByID($player_id))) {
echo GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
return false;
}
$items = GDO::table('SR_Item');
if (false === ($itemIDs = $items->selectColumn('sr4it_id', "sr4it_uid={$player_id}"))) {
echo GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
return false;
}
foreach ($itemIDs as $itemID) {
if (!self::hasItem($player, $itemID)) {
printf("Deleted lonely item %d for player %s.\n", $itemID, $player->getName());
$items->deleteWhere("sr4it_id={$itemID}");
}
}
}
示例4: getPlayerByPID
/**
* Get or load a player.
* @param int $playerid
* @return SR_Player
*/
public static function getPlayerByPID($playerid)
{
$playerid = (int) $playerid;
# Cached
if (true === isset(self::$players[$playerid])) {
return self::$players[$playerid];
}
# Load?
if (false === ($player = SR_Player::getByID($playerid))) {
return false;
}
# Cache (if real player, not NPC)
if (true === $player->isHuman()) {
self::addPlayer($player);
}
return $player;
}
示例5: getLeader
/**
* Get the leader of this clan.
* @return SR_Player
*/
public function getLeader()
{
$lead_id = $this->getLeaderID();
if (false === ($leader = Shadowrun4::getPlayerByPID($lead_id))) {
if (false === ($leader = SR_Player::getByID($lead_id))) {
return false;
}
}
return $leader;
}