Author Topic: Change "7.00 cedits" to "7 credits"  (Read 7192 times)

Offline Raymond

Change "7.00 cedits" to "7 credits"
« on: November 29, 2007, 01:00:02 am »
At the moment my forum says that someone has for example "17.00" credits.
Is there a way to Change the 17.00 cedits to 17 credits?

Thanks for the help.

Offline Dark_Zero

Re: Change "7.00 cedits" to "7 credits"
« Reply #1 on: November 29, 2007, 04:46:27 am »
i looked around in the source and i saw the function making the money a 'floating- point' value.
in Shop-Subs.php, at the top, find "// Cast to float", and the line under that, either delete the two lines or put two succeeding slashes at the beginning of the line to make it a comment. (to preserve the code for the future if needed)
i.e. delete this..
// Cast to float
$money = (float) $money;

or.. make it a comment like this

// Cast to float
// $money = (float) $money;

either one works.
« Last Edit: November 30, 2007, 12:01:55 am by Dark_Zero »

Offline Daniel15

Re: Change "7.00 cedits" to "7 credits"
« Reply #2 on: December 03, 2007, 12:44:45 pm »
Alternatively you could change it to
Code: [Select]
$money = (int) $money;
Which will round off the value if needed.

Offline Vincent Volmer

Re: Change "7.00 cedits" to "7 credits"
« Reply #3 on: January 06, 2008, 11:59:16 pm »
Alternatively you could change it to
Code: [Select]
$money = (int) $money;
Which will round off the value if needed.
Hello,

thanks for the hack.
Maybe I'm doing something wrong but this hack didn't change anything for me. It's still displaying 123.00 instead of 123

Regards
Vincent Volmer

DarkAxi0m

  • Guest
Re: Change "7.00 cedits" to "7 credits"
« Reply #4 on: January 08, 2008, 10:40:45 am »
Hi just wondering if it would be Possible to Have the bank show 7.00 and else where 7.

All i can think of is to change the bank sections to not use
function formatMoney($money)

Offline Daniel15

Re: Change "7.00 cedits" to "7 credits"
« Reply #5 on: January 11, 2008, 03:09:01 pm »
Vincent Volmer, are you sure you updated the file correctly?
DarkAxi0m, perhaps make a new function called "formatMoneyBank" in Shop-Subs.php? Edit the normal function as mentioned above, and then add something like:
Code: [Select]
function formatMoneyBank($money)
{
global $modSettings;

// Cast to float
$money = (float) $money;
// Return amount with prefix and suffix added
return $modSettings['shopCurrencyPrefix'] . $money . $modSettings['shopCurrencySuffix'];
}
(this is the original code, except it's a function called formatMoneyBank instead of formatMoney)
Then, go through the code, and whenever you want something to appear with the decimal places, change formatMoney( to formatMoneyBank( (probably in Shop-Bank.php and Shop.template.php, among others)

Hope this helps you :)

Offline Vincent Volmer

Re: Change "7.00 cedits" to "7 credits"
« Reply #6 on: January 12, 2008, 02:17:55 am »
Vincent Volmer, are you sure you updated the file correctly?

I see that there are some places: ( index.php?action=shop ) which display the credits correct like 7 credits. On other places like the member list or in the shop ( index.php?action=shop;do=buy ) still are displaying 7.00 credits. I really think I did something wrong or I misunderstood the hack.... but I don't know what or how.

If you don't understand what I mean, please take a look at our website but you need to register first. I can do that for you if you like because the whole website is in Dutch language. If needed I'll send you a PM.

Regards Vincent Volmer