Command doesn't update floats.
#1

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;
            }
Reply
#2

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.
Reply
#3

Quote:
Originally Posted by Loot
View Post
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.
Reply
#4

Use floatstr(). It converts a string to a floating point value.

Make sure you wrap it around inputtext, e.g:

pawn Code:
floatstr(inputtext)
For integers, you use "strval":

pawn Code:
strval(inputtext)
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;
}
Reply
#5

Quote:
Originally Posted by Emmet_
View Post
Use floatstr(). It converts a string to a floating point value.

Make sure you wrap it around inputtext, e.g:

pawn Code:
floatstr(inputtext)
For integers, you use "strval":

pawn Code:
strval(inputtext)
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
Reply
#6

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.
Reply
#7

Thank you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)