Jump to content
  • 0

Vote For Points Support


Lelouch vi Britannia

Question


  • Group:  Members
  • Topic Count:  45
  • Topics Per Day:  0.01
  • Content Count:  715
  • Reputation:   83
  • Joined:  01/05/12
  • Last Seen:  

Well the issue was the Coins are unidentified when it goes into the storage.

Here is the script

<?php
class Coins {
	public $server;
	public $coinsID;
	
	public function __construct(Flux_Athena $server, $coinsID)
	{
		$this->server  = $server;
		$this->coinsID = $coinsID;
	}
	
	public function getCoins($accountID)
	{
		$sql = "SELECT amount FROM {$this->server->loginDatabase}.storage WHERE account_id = ? AND nameid = ? LIMIT 1";
		$sth = $this->server->connection->getStatement($sql);
		$sth->execute(array($accountID, $this->coinsID));
		$num = $sth->fetch();
		if ($num) {
			return (int)$num->amount;
		}
		else {
			return 0;
		}
	}
	
	public function setCoins($accountID, $amount)
	{
		$num = $this->getCoins($accountID);
		if (!$num) {
			$sql  = "INSERT INTO {$this->server->loginDatabase}.storage (account_id, nameid, amount) ";
			$sql .= "VALUES (?, ?, ?)";
			$sth  = $this->server->connection->getStatement($sql);
			return $sth->execute(array($accountID, $this->coinsID, $amount));
		}
		else {
			$sql  = "UPDATE {$this->server->loginDatabase}.storage SET amount = ? WHERE account_id = ? AND nameid = ?";
			$sth  = $this->server->connection->getStatement($sql);
			return $sth->execute(array($amount, $accountID, $this->coinsID));
		}
	}
}
?>

 

Edited by Lelouch vi Britannia
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  70
  • Reputation:   18
  • Joined:  01/28/12
  • Last Seen:  

$sql  = "INSERT INTO {$this->server->loginDatabase}.storage (account_id, nameid, amount, identify) ";
$sql .= "VALUES (?, ?, ?, 1)";

update the insert part it should flag that the item is identified

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  45
  • Topics Per Day:  0.01
  • Content Count:  715
  • Reputation:   83
  • Joined:  01/05/12
  • Last Seen:  

12 hours ago, Aries said:

$sql  = "INSERT INTO {$this->server->loginDatabase}.storage (account_id, nameid, amount, identify) ";
$sql .= "VALUES (?, ?, ?, 1)";

update the insert part it should flag that the item is identified

Not Working

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  70
  • Reputation:   18
  • Joined:  01/28/12
  • Last Seen:  

The amount will only get updated if you tested it on an account with coins already in storage.
Try it again to an account without the coin in the  storage.

Link to comment
Share on other sites

×
×
  • Create New...