Skip to content

Commit

Permalink
Config to display CashPoints instead of Credits (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
Akkarinage authored Apr 24, 2024
1 parent 4936530 commit cd96819
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
'BackwardYears' => 60, // (Visual) The number of years to display behind the current year in date inputs.
'ColumnSortAscending' => '', // (Visual) Text displayed for ascending sorted column names.
'ColumnSortDescending' => '', // (Visual) Text displayed for descending sorted column names.
'DisplayCashPoints' => false, // Whether or not to display "Cash Points" instead of the player's "Credits" in the control panel.
'CreditExchangeRate' => 1.0, // The rate at which credits are exchanged for dollars.
'MinDonationAmount' => 2.0, // Minimum donation amount. (NOTE: Actual donations made that are less than this account won't be exchanged)
'DonationCurrency' => 'USD', // Preferred donation currency. Only donations made in this currency will be processed for credit deposits.
Expand Down
9 changes: 9 additions & 0 deletions modules/account/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,5 +240,14 @@

$itemAttributes = Flux::config('Attributes')->toArray();
$type_list = Flux::config('ItemTypes')->toArray();

if(Flux::config('DisplayCashPoints')) {
$regTable = 'acc_reg_num';
$sql = "SELECT * FROM {$server->loginDatabase}.{$regTable} WHERE `key` = '#CASHPOINTS' AND account_id = ?";
$sth = $server->connection->getStatement($sql);
$sth->execute(array($accountID));
$account->balance = $sth->fetch()->value;

This comment has been minimized.

Copy link
@wiryawanadipa

wiryawanadipa Jun 23, 2024

In PHP 7.4.33 (I don't know with other PHP versions) it shows an error when there are no cash points.
To fix this I had to add a default value (0) if there are no cash points.
$account->balance = $sth->fetch()->value ?? 0;

}

}
?>

1 comment on commit cd96819

@mazvi
Copy link
Contributor

@mazvi mazvi commented on cd96819 Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about #KAFRAPOINTS ?

Please sign in to comment.