diff --git a/core/Players/Player.php b/core/Players/Player.php index b65891f0..ef9a4357 100644 --- a/core/Players/Player.php +++ b/core/Players/Player.php @@ -196,6 +196,23 @@ class Player implements Dumpable, UsageInformationAble { return ($this->pid <= 0 || substr($this->login, 0, 1) === '*'); } + /** + * Get AccountId from Login + * + * @api + * @return string + */ + public function getAccountId() { + if (strlen($this->login) !== 22) return $this->login; + + $login = str_pad($this->login, 24, "=", STR_PAD_RIGHT); + + $login = str_replace("_","/", str_replace("-","+", $login)); + $login = base64_decode($login); + + return vsprintf("%s%s-%s-%s-%s-%s%s%s", str_split(bin2hex($login), 4)); + } + /** * Get province *