iCORE 33 Posted February 11, 2015 <?phpclass Cashpoints { public $server; public $cashRecords = array(); public $pointsType = '#CASHPOINTS'; public function __construct(Flux_Athena $athenaServer, $kafraPoints=false) { $this->server = $athenaServer; if ($kafraPoints) { $this->pointsType = '#KAFRAPOINTS'; } } public function getCash($accountID) { $this->initCash($accountID); $sql = "SELECT value FROM {$this->server->charMapDatabase}.global_reg_value "; $sql .= "WHERE `str` = ? AND account_id = ? LIMIT 1"; $sth = $this->server->connection->getStatement($sql); $sth->execute(array($this->pointsType, $accountID)); return (int)$sth->fetch()->value; } public function setCash($accountID, $amount) { $this->initCash($accountID); $sql = "UPDATE {$this->server->charMapDatabase}.global_reg_value "; $sql .= "SET value = ? WHERE `str` = ? AND account_id = ?"; $sth = $this->server->connection->getStatement($sql); return $sth->execute(array((int)$amount, $this->pointsType, $accountID)); } protected function initCash($accountID) { if (!array_key_exists($accountID, $this->cashRecords)) { $sql = "SELECT account_id FROM {$this->server->charMapDatabase}.global_reg_value "; $sql .= "WHERE `str` = ? AND account_id = ? LIMIT 1"; $sth = $this->server->connection->getStatement($sql); $sth->execute(array($this->pointsType, $accountID)); if ($sth->fetch()) { // Has prior cashpoints record. $this->cashRecords[$accountID] = true; } else { // Does not have prior cash points record. $this->cashRecords[$accountID] = false; } } // Initialize cash points record if it doesn't already exist. if (!$this->cashRecords[$accountID]) { $sql = "INSERT INTO {$this->server->charMapDatabase}.global_reg_value "; $sql .= "(`str`, value, type, account_id, char_id) "; $sql .= "VALUES (?, 0, 2, ?, 0)"; $sth = $this->server->connection->getStatement($sql); $sth->execute(array($this->pointsType, $accountID)); } }}?> how to make this work on Hercules Quote Share this post Link to post Share on other sites
0 Garr 117 Posted February 12, 2015 (edited) Replace all .global_reg_value with one of the following: .acc_reg_num_db - account wide points, you probably want this.global_acc_reg_num_db - also account wide, but across all map/char servers if there are many Also, replace WHERE `str` with WHERE `key` I think that should do it. ETA: For the last, where setting points first time if (!$this->cashRecords[$accountID]) { $sql = "INSERT INTO {$this->server->charMapDatabase}.global_reg_value "; $sql .= "(`str`, value, type, account_id, char_id) "; $sql .= "VALUES (?, 0, 2, ?, 0)"; $sth = $this->server->connection->getStatement($sql); $sth->execute(array($this->pointsType, $accountID)); } replace it with if (!$this->cashRecords[$accountID]) { $sql = "INSERT INTO {$this->server->charMapDatabase}.acc_reg_num_db "; $sql .= "(`key`, `value`, `account_id`) "; $sql .= "VALUES (?, 0, ?)"; $sth = $this->server->connection->getStatement($sql); $sth->execute(array($this->pointsType, $accountID)); } Edited February 12, 2015 by Garr 1 iCORE reacted to this Quote Share this post Link to post Share on other sites
0 iCORE 33 Posted February 12, 2015 finally thanks man Quote Share this post Link to post Share on other sites
how to make this work on Hercules
Share this post
Link to post
Share on other sites