Smokey Posted July 7, 2011 Posted July 7, 2011 Ok, I'm sure I saw this somewhere last week but I cannot find it now...how would one add the decimal values for stats to the users homepage instead of it just rounding to a whole number? Quote
realmoflegends Posted July 7, 2011 Posted July 7, 2011 Assuming you have CPanel, I went into phpmyadmin and changed the userstats variable type to Decimal. That seemed to work fine. Now I have stats like 12.78, 11.34, etc. Necessary in my game since training isn't set to be super fast. Quote
Smokey Posted July 7, 2011 Author Posted July 7, 2011 They are already set to decimal (11, 4) in the database, so when training you see the decimal on the gains, it just does not show on the homepage. Quote
Kieran-R Posted July 7, 2011 Posted July 7, 2011 Check the value in the database, and see if it is a decimal number there. Tell us your findings. Quote
Smokey Posted July 7, 2011 Author Posted July 7, 2011 (edited) If you mean in the userstats table, yes it shows. For instance: Strength Agility Guard Labour 4099.5098 1136.0560 915.0077 1984.4896 This is an example of a users stats in the userstats table. I'm guessing its something in the index.php that is rounding off the numbers but I cannot find it, this is the only reference i see close. $ir['strength']=number_format($ir['strength']); Also in the gym, when you train it gives the decimal values, but only on the outcome message, before you train if you look at your current stats while in the gym it shows XXXX.0000 So it does show the decimal values but its been rounded off. Correction, the gym does in fact show the correct decimal values, i was looking at my own stats which i do not train so it was .0000 by default, but after training it did show the decimal values, so I'm going to have a look at the gym.php and see if i can see why it is working correctly there but not on the index.php Edited July 7, 2011 by Smokey Quote
Smokey Posted July 7, 2011 Author Posted July 7, 2011 It seems removing this from index.php allows the .0000 to show on the homepage, but it stays all zero's and does not pull this from the database, so I'm guessing I need to change "number_format" but to what I do not know, "decimal_format" surely does not work lol. $ir['strength']=number_format($ir['strength']); $ir['agility']=number_format($ir['agility']); $ir['guard']=number_format($ir['guard']); $ir['labour']=number_format($ir['labour']); $ir['IQ']=number_format($ir['IQ']); $ts=number_format($ts); Quote
Danny696 Posted July 7, 2011 Posted July 7, 2011 Please refrain from double posting, use http://www.php.net to check out php functions. You could either use number_format, or round.. Quote
Smokey Posted July 7, 2011 Author Posted July 7, 2011 If you had read my post I am already using number_format, and that is rounding it off, which is what I am trying to change, I do NOT want it rounded, I want the decimal to show. And please excuse the double post, this was only because I edited the post above several times and the "double" post was to show my final findings, I don't normally double post. I posted in the Support section because I have already checked php.net and did not find the information I am seeking. Quote
lucky3809 Posted July 7, 2011 Posted July 7, 2011 You need to change your number_format function to have it display the correct decimal. Post your number_format function and someone maybe able to help you. Quote
Smokey Posted July 8, 2011 Author Posted July 8, 2011 ok noob question but where is that located as I cannot find it? I am currently using v2.0.3. I am new to php coding so I'm not extremely familiar, I have checked global_func and globals but I do not see it. Quote
lucky3809 Posted July 8, 2011 Posted July 8, 2011 its in global_func.php that is why it is func at the end for functions lol. Quote
Smokey Posted July 8, 2011 Author Posted July 8, 2011 Just because I'm new to php doesn't mean I'm an idiot :P, as I said thats what I assumed and was the first place I looked. And there is no number_format function there. Here is a list of every single function in global_func and as you see there is no number_format function, unless one of these doubles as the number formatter, and my global_func is default, I have not added any functions to it since I bought the codes last week. function DateTime_Parse function money_formatter function itemtype_dropdown function item_dropdown function item2_dropdown function location_dropdown function shop_dropdown function user_dropdown function challengebot_dropdown function fed_user_dropdown function mailb_user_dropdown function job_dropdown function jobrank_dropdown function house_dropdown function house2_dropdown function course_dropdown function crime_dropdown function crimegroup_dropdown function event_add function mysql_escape function check_level function get_rank function item_add function item_remove function forum_dropdown function forum2_dropdown function make_bigint function stafflog_add Quote
Smokey Posted July 8, 2011 Author Posted July 8, 2011 Yea..thats kinda why I asked which file it would be in, because it isnt in global_func...does no one know which file its in for v2.0.3? Quote
Diesl Posted July 8, 2011 Posted July 8, 2011 @lucky and smokey number_format is not a McCode defined fuction, it is a PHP based function http://php.net/manual/en/function.number-format.php if you want decimals to show, you would do $new_number = number_format($number, 2); // shows 2 decimal places Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.