lwb5-in-2025/scripts/game/beta5/player/library/getName.inc

30 lines
651 B
PHP
Raw Normal View History

2016-01-10 11:01:49 +01:00
<?php
class beta5_player_getName {
2024-12-31 00:50:29 +01:00
public function __construct($lib) {
2016-01-10 11:01:49 +01:00
$this->lib = $lib;
$this->db = $this->lib->game->db;
}
// Returns the name of a player
function run($id) {
if (is_null($id)) {
logText("****** BUG: beta5::player::getName(null) called");
l::backtrace();
return null;
}
if (!is_null($this->lib->mainClass->pNames[$id])) {
return $this->lib->mainClass->pNames[$id];
}
$q = $this->db->query(
"SELECT u.name,p.name FROM account u, player p WHERE p.id=$id AND u.id=p.userid"
);
list($an,$pn) = dbFetchArray($q);
return ($this->lib->mainClass->pNames[$id] = is_null($pn) ? $an : $pn);
}
}
?>