This repository has been archived on 2024-07-18. You can view files and clone it, but cannot push or open issues or pull requests.
lwb5/scripts/game/beta5/player/library/getName.inc

29 lines
653 B
PHP

<?php
class beta5_player_getName {
function beta5_player_getName($lib) {
$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);
}
}
?>