"dini_FloatSet" - decimal place from inputtext.
#1

When I enter value 2.3 in inputtext, it saves it as 2.30000 in the file, if I enter 1.1, then the value in the file is 1.09999, how can I change it? That the value should be saved with a maximum of 1 decimal place?


Code:
new Float:value;

if(sscanf(inputtext, "f", value)){
	ShowDialog(playerid, 32, DIALOG_STYLE_INPUT, "Admin", "You must write this value!", "Next", "Prev");
	return true;
}

dini_FloatSet(FILE_CONF, "gmk", value);
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "Lorem", "Changed!", "Close", "");
return true;
Reply
#2

That is a float precision issue. The problem is that even if you save it as 1.1 it will still load as 1.0999.

You can however save the inputtext as string. Use sscanf to verify the validity of the input (basically like now) but instead of saving the value variable, you can save the content of inputtext as string.
You'll still be able to load it as Float, but like I said it will most likely still load as 1.0999.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)