rituel 2 Posted July 7, 2014 (edited) Hello to all. Is it possible to use #CASHPOINTS during a donation on FluxCP ? It exist a paying patch on rathena but not functional for hercules. I have not found anything about Hercules. Cordialy. Edited July 7, 2014 by rituel Quote Share this post Link to post Share on other sites
0 Dastgir 1246 Posted July 8, 2014 if (!$this->hasCreditsRecord($targetAccountID)) { $sql = "INSERT INTO {$this->charMapDatabase}.`acc_reg_num_db` (`account_id`, `key`, `index`, `value`) VALUES (?,'#CASHPOINTS',0,?) ON DUPLICATE KEY UPDATE `value`=`value`+?"; $sth = $this->connection->getStatement($sql); $vals = array($targetAccountID, $credits,$credits); return $sth->execute($vals); } Works fine for me... well for the exact error, enable the error reporting from config/error.php : Change $showExceptions = false; to $showExceptions = true; 1 Azael Dev reacted to this Quote Share this post Link to post Share on other sites
0 stiflerxx 2 Posted July 7, 2014 hi good ... I've tried to put pro have no knowledge even more believe it is possible ... yes Quote Share this post Link to post Share on other sites
0 jTynne 101 Posted July 8, 2014 An alternative is to just insert an item and sell that in the cash shop that can either be consumed or turned in to an NPC for Cash Points. Alternatively, and with a bit of adjusting of the default rewards NPC code, it would be possible to make it not give a physical item to the player when redeeming if the ID of the reward(s) match the ID of a specific item sold on the panel and just adjust cash points accordingly. Just an idea. Quote Share this post Link to post Share on other sites
0 rituel 2 Posted July 8, 2014 (edited) Hello to you. Today I'm stuck on this part: public function hasCreditsRecord($accountID) { $creditsTable = Flux::config('FluxTables.CreditsTable'); $sql = "SELECT COUNT(account_id) AS hasRecord FROM {$this->charMapDatabase}.`acc_reg_num_db` where `account_id` = ? and `key` = '#CASHPOINTS'"; $sth = $this->connection->getStatement($sql); $sth->execute(array($accountID)); if ($sth->fetch()->hasRecord) { return true; } else { return false; } } /** * */ public function depositCredits($targetAccountID, $credits, $donationAmount = null) { $sql = "SELECT COUNT(account_id) AS accountExists FROM {$this->loginDatabase}.login WHERE account_id = ?"; $sth = $this->connection->getStatement($sql); if (!$sth->execute(array($targetAccountID)) || !$sth->fetch()->accountExists) { return false; // Account doesn't exist. } $creditsTable = Flux::config('FluxTables.CreditsTable'); if (!$this->hasCreditsRecord($targetAccountID)) { $fields = 'account_id, balance'; $values = '?, ?'; /*if (!is_null($donationAmount)) { $fields .= ', last_donation_date, last_donation_amount'; $values .= ', NOW(), ?'; }*/ $sql = "INSERT INTO {$this->loginDatabase}.$creditsTable ($fields) VALUES ($values)"; $sth = $this->connection->getStatement($sql); $vals = array($targetAccountID, $credits); /*if (!is_null($donationAmount)) { $vals[] = $donationAmount; }*/ return $sth->execute($vals); } else { $vals = array(); $sql = "UPDATE {$this->loginDatabase}.$creditsTable SET balance = balance + ? "; /*if (!is_null($donationAmount)) { $sql .= ", last_donation_date = NOW(), last_donation_amount = ? "; }*/ $vals[] = $credits; /*if (!is_null($donationAmount)) { $vals[] = $donationAmount; }*/ $vals[] = $targetAccountID; $sql .= "WHERE account_id = ?"; $sth = $this->connection->getStatement($sql); return $sth->execute($vals); } } This part, update or insert the crédtis in "cp_credits" table. So to be on, I modified like this to write (insert into) fix values and see if it was well written. $sql = "INSERT INTO {$this->loginDatabase}.$creditsTable ($fields) VALUES ($values)"; $sth = $this->connection->getStatement($sql); $vals = array(999, 999); Result after credits transfert on the website: Now I change that (INSERT INTO & UPDATE) works (normally) in "acc_reg_num_db" table with the variable (# CASHPOINTS) public function hasCreditsRecord($accountID) { $creditsTable = Flux::config('FluxTables.CreditsTable'); $sql = "SELECT COUNT(account_id) AS hasRecord FROM {$this->charMapDatabase}.`acc_reg_num_db` where `account_id` = ? and `key` = '#CASHPOINTS'"; $sth = $this->connection->getStatement($sql); $sth->execute(array($accountID)); if ($sth->fetch()->hasRecord) { return true; } else { return false; } } /** * */ public function depositCredits($targetAccountID, $credits, $donationAmount = null) { $sql = "SELECT COUNT(account_id) AS accountExists FROM {$this->loginDatabase}.login WHERE account_id = ?"; $sth = $this->connection->getStatement($sql); if (!$sth->execute(array($targetAccountID)) || !$sth->fetch()->accountExists) { return false; // Account doesn't exist. } $creditsTable = Flux::config('FluxTables.CreditsTable'); if (!$this->hasCreditsRecord($targetAccountID)) { $fields = 'account_id, key, index, value'; $values = '?, ?, ?, ?'; /*if (!is_null($donationAmount)) { $fields .= ', last_donation_date, last_donation_amount'; $values .= ', NOW(), ?'; }*/ $sql = "INSERT INTO {$this->charMapDatabase}.`acc_reg_num_db` ($fields) VALUES ($values)"; $sth = $this->connection->getStatement($sql); $vals = array($targetAccountID, '#CASHPOINTS', 0, $credits); /*if (!is_null($donationAmount)) { $vals[] = $donationAmount; }*/ return $sth->execute($vals); } else { $vals = array(); $sql = "UPDATE {$this->charMapDatabase}.`acc_reg_num_db` SET value = value + ? "; /*if (!is_null($donationAmount)) { $sql .= ", last_donation_date = NOW(), last_donation_amount = ? "; }*/ $vals[] = $credits; /*if (!is_null($donationAmount)) { $vals[] = $donationAmount; }*/ $vals[] = $targetAccountID; $sql .= "WHERE account_id = ? and `key` = '#CASHPOINTS'"; $sth = $this->connection->getStatement($sql); return $sth->execute($vals); } } Voila. Now try a tranferst on a player already possessing #CASHPOINTS in "acc_reg_num_db" table [uPDATE]. Result ? Finally, try transferring to a player who has not yet #CASHPOINTS in "acc_reg_num_db" table [iNSER INTO]. We will call "Fiotass" that exists in the table "char" and his account in "login" under the accound_id "2000008" Result ? I've been here yesterday but I did not find my error. Edited July 8, 2014 by rituel Quote Share this post Link to post Share on other sites
0 Dastgir 1246 Posted July 8, 2014 tried something like? public function depositCredits($targetAccountID, $credits, $donationAmount = null) { $sql = "SELECT COUNT(account_id) AS accountExists FROM {$this->loginDatabase}.login WHERE account_id = ?"; $sth = $this->connection->getStatement($sql); if (!$sth->execute(array($targetAccountID)) || !$sth->fetch()->accountExists) { return false; // Account doesn't exist. } $creditsTable = Flux::config('FluxTables.CreditsTable'); $fields = 'account_id, key, index, value'; $values = '?, ?, ?, ?'; /*if (!is_null($donationAmount)) { $fields .= ', last_donation_date, last_donation_amount'; $values .= ', NOW(), ?'; }*/ $sql = "INSERT INTO {$this->charMapDatabase}.`acc_reg_num_db` ($fields) VALUES ($values) ON DUPLICATE KEY UPDATE `value`=`value`+?"; $sth = $this->connection->getStatement($sql); $vals = array($targetAccountID, '#CASHPOINTS', 0, $credits, $credits); /*if (!is_null($donationAmount)) { $vals[] = $donationAmount; }*/ return $sth->execute($vals); } Quote Share this post Link to post Share on other sites
0 rituel 2 Posted July 8, 2014 (edited) Hi /fluxcp/lib/Flux/LoginServer.php Unexpected error occurred. Again and again Work: (UPDATE): else { $vals = array(); $sql = "UPDATE {$this->charMapDatabase}.`acc_reg_num_db` SET value = value + ? "; /*if (!is_null($donationAmount)) { $sql .= ", last_donation_date = NOW(), last_donation_amount = ? "; }*/ $vals[] = $credits; /*if (!is_null($donationAmount)) { $vals[] = $donationAmount; }*/ $vals[] = $targetAccountID; $sql .= "WHERE account_id = ? and `key` = '#CASHPOINTS'"; $sth = $this->connection->getStatement($sql); return $sth->execute($vals); } } Not Work: (INSERT INTO): if (!$this->hasCreditsRecord($targetAccountID)) { $fields = 'account_id, key, index, value'; $values = '?, ?, ?, ?'; /*if (!is_null($donationAmount)) { $fields .= ', last_donation_date, last_donation_amount'; $values .= ', NOW(), ?'; }*/ $sql = "INSERT INTO {$this->charMapDatabase}.`acc_reg_num_db` ($fields) VALUES ($values)ON DUPLICATE KEY UPDATE `value`=`value`+?"; $sth = $this->connection->getStatement($sql); $vals = array($targetAccountID, '#CASHPOINTS', 0, $credits); /*if (!is_null($donationAmount)) { $vals[] = $donationAmount; }*/ return $sth->execute($vals); } Not Work: (INSERT INTO & UPDATE): public function depositCredits($targetAccountID, $credits, $donationAmount = null) { $sql = "SELECT COUNT(account_id) AS accountExists FROM {$this->loginDatabase}.login WHERE account_id = ?"; $sth = $this->connection->getStatement($sql); if (!$sth->execute(array($targetAccountID)) || !$sth->fetch()->accountExists) { return false; // Account doesn't exist. } $creditsTable = Flux::config('FluxTables.CreditsTable'); $fields = 'account_id, key, index, value'; $values = '?, ?, ?, ?'; /*if (!is_null($donationAmount)) { $fields .= ', last_donation_date, last_donation_amount'; $values .= ', NOW(), ?'; }*/ $sql = "INSERT INTO {$this->charMapDatabase}.`acc_reg_num_db` ($fields) VALUES ($values) ON DUPLICATE KEY UPDATE `value`=`value`+?"; $sth = $this->connection->getStatement($sql); $vals = array($targetAccountID, '#CASHPOINTS', 0, $credits, $credits); /*if (!is_null($donationAmount)) { $vals[] = $donationAmount; }*/ return $sth->execute($vals); } Edited July 8, 2014 by rituel Quote Share this post Link to post Share on other sites
0 rituel 2 Posted July 8, 2014 Thanks I have also been able to find my mistake. Not work: if (!$this->hasCreditsRecord($targetAccountID)) { $fields = $fields = 'account_id, key, index, value'; $values = '?, ?, ?, ?'; /*if (!is_null($donationAmount)) { $fields .= ', last_donation_date, last_donation_amount'; $values .= ', NOW(), ?'; }*/ $sql = "INSERT INTO {$this->charMapDatabase}.`acc_reg_num_db` ($fields) VALUES ($values)"; $sth = $this->connection->getStatement($sql); $vals = array($targetAccountID, '#CASHPOINTS', 0, $credits); /*if (!is_null($donationAmount)) { $vals[] = $donationAmount; }*/ return $sth->execute($vals); } Work! if (!$this->hasCreditsRecord($targetAccountID)) { $fields = $fields = '`account_id`, `key`, `index`, `value`'; $values = '?, ?, ?, ?'; /*if (!is_null($donationAmount)) { $fields .= ', last_donation_date, last_donation_amount'; $values .= ', NOW(), ?'; }*/ $sql = "INSERT INTO {$this->charMapDatabase}.`acc_reg_num_db` ($fields) VALUES ($values)"; $sth = $this->connection->getStatement($sql); $vals = array($targetAccountID, '#CASHPOINTS', 0, $credits); /*if (!is_null($donationAmount)) { $vals[] = $donationAmount; }*/ return $sth->execute($vals); } 1 kokastein reacted to this Quote Share this post Link to post Share on other sites
0 rituel 2 Posted July 8, 2014 (edited) Another question: Is there a way that cash shop tests with sandbox.paypal, credit my game account on my Fluxcp site? What is complicated currently for testing . Fix & Work With 0.01€ Edited July 8, 2014 by rituel Quote Share this post Link to post Share on other sites
0 jcarvallo 0 Posted August 3, 2015 Hey rituel, can you post the files you modified to make it work? I'm trying to figure it out right now and it would be really appreciated. Thank you very much, Quote Share this post Link to post Share on other sites
Share this post
Link to post
Share on other sites