Command doesn't update floats. -
BleverCastard - 21.03.2015
When you /editfaction a list comes up. If you choose floats or integers to change, it seems to either display 0.00000(floats) or a random number around 50(integer) and doesn't want to update the correct input.
pawn Code:
if(ListItem[playerid] == 2)
{
format(GlobalQuery, sizeof(GlobalQuery), "UPDATE `factions` SET `IntX` = %0.2f WHERE `FacID` = %d", inputtext, FID[playerid]);
mysql_function_query(MySQLConnection, GlobalQuery, true, "Query", "");
format(GlobalString, sizeof(GlobalString), "Interior X set.", inputtext);
SendClientMessage(playerid, COLOR_WHITE, GlobalString);
FID[playerid] = 0;
ListItem[playerid] = 0;
}
Re: Command doesn't update floats. -
Loot - 21.03.2015
We can't guess why it won't update without looking at the logs..
Check the mysql_log.txt file to see if it failed or not... And if so, copy it to here.
Re: Command doesn't update floats. -
BleverCastard - 21.03.2015
Quote:
Originally Posted by Loot
We can't guess why it won't update without looking at the logs..
Check the mysql_log.txt file to see if it failed or not... And if so, copy it to here.
|
If there was an error in the log, I would have shown it. If you read the post properly, you'd realise that it does update, it doesn't update the correct input.
Re: Command doesn't update floats. - Emmet_ - 21.03.2015
Use floatstr(). It converts a string to a floating point value.
Make sure you wrap it around inputtext, e.g:
For integers, you use "strval":
Code:
pawn Code:
if(ListItem[playerid] == 2)
{
format(GlobalQuery, sizeof(GlobalQuery), "UPDATE `factions` SET `IntX` = %.2f WHERE `FacID` = %d", floatstr(inputtext), FID[playerid]);
mysql_function_query(MySQLConnection, GlobalQuery, true, "Query", "");
format(GlobalString, sizeof(GlobalString), "Interior X set to %.2f.", floatstr(inputtext));
SendClientMessage(playerid, COLOR_WHITE, GlobalString);
FID[playerid] = 0;
ListItem[playerid] = 0;
}
Re: Command doesn't update floats. -
BleverCastard - 21.03.2015
Quote:
Originally Posted by Emmet_
Use floatstr(). It converts a string to a floating point value.
Make sure you wrap it around inputtext, e.g:
For integers, you use "strval":
Code:
pawn Code:
if(ListItem[playerid] == 2) { format(GlobalQuery, sizeof(GlobalQuery), "UPDATE `factions` SET `IntX` = %.2f WHERE `FacID` = %d", floatstr(inputtext), FID[playerid]); mysql_function_query(MySQLConnection, GlobalQuery, true, "Query", ""); format(GlobalString, sizeof(GlobalString), "Interior X set to %.2f.", floatstr(inputtext)); SendClientMessage(playerid, COLOR_WHITE, GlobalString); FID[playerid] = 0; ListItem[playerid] = 0; }
|
Thanks it works. But only does 5. For example, 123.456 was entered, it'd be 123.45
Re: Command doesn't update floats. -
Konstantinos - 21.03.2015
In the format you can specify how many decimal places you want it. In the example Emmet_ gave, it uses 2 so you can use "%.3f" instead.
Re: Command doesn't update floats. -
BleverCastard - 22.03.2015
Thank you!