Jump to content
  • 0
Sign in to follow this  
iCORE

[Help] Cashpoints.php

Question

<?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

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

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 by Garr

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.