From 996dde826da965ce9dc54ac2d50a1506fc425073 Mon Sep 17 00:00:00 2001 From: Beu Date: Sat, 23 Dec 2023 12:15:00 +0100 Subject: [PATCH] add getAccountId function --- core/Players/Player.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 *