SQLite resetting floats
#1

when I load my gamemode, it loads factions. When I exit the gamemode, it sets the floats to where they should be.

For some reason, when I load my gamemode it sets all the floats to 0.0 agan...

Код:
[05:58:28] UPDATE `FACTIONS` (NAME = 'Bay Island PD', INTX = -2252.593994, INTY = 2323.233398, INTZ = 4.812500, EXTX = -2259.160156, EXTY = 2321.112548, EXTZ = 4.812500, VW = 0, INT = 0, CREATED = 1 WHERE `ID` = 1
[05:58:28] Faction ID 1 saved successfully
As you can see, the Query wrote it to the database...but when it loads back up, the floats are set to 0, therefore, you have to reset the HQ location to use it everytime the server restarts

pawn Код:
stock LoadFaction(ID)
{
    new Query[300], DBResult:Result, Float:X, Float:Y, Float:Z, string[100];
    format(Query, sizeof(Query), "SELECT * FROM `FACTIONS` WHERE `ID` = %d LIMIT 1", ID);
    Result = db_query(survival, Query);
    if(db_num_rows(Result))
    {
        new Field[30];
        db_get_field_assoc(Result, "NAME", Field, 30);
        FactionInfo[ID][fName] = Field;
        db_get_field_assoc(Result, "ID", Field, 30);
        FactionInfo[ID][fID] = strval(Field);
        db_get_field_assoc(Result, "INTX", Field, 30);
        FactionInfo[ID][fHQintX] = floatstr(Field);
        db_get_field_assoc(Result, "INTY", Field, 30);
        FactionInfo[ID][fHQintY] = floatstr(Field);
        db_get_field_assoc(Result, "INTZ", Field, 30);
        FactionInfo[ID][fHQintZ] = floatstr(Field);
        db_get_field_assoc(Result, "EXTX", Field, 30);
        FactionInfo[ID][fHQextX] = floatstr(Field);
        db_get_field_assoc(Result, "EXTY", Field, 30);
        FactionInfo[ID][fHQextY] = floatstr(Field);
        db_get_field_assoc(Result, "EXTZ", Field, 30);
        FactionInfo[ID][fHQextZ] = floatstr(Field);
        db_get_field_assoc(Result, "VW", Field, 30);
        FactionInfo[ID][fHQVW] = strval(Field);
        db_get_field_assoc(Result, "INT", Field, 30);
        FactionInfo[ID][fHQint] = strval(Field);
        db_get_field_assoc(Result, "CREATED", Field, 30);
        FactionInfo[ID][fCreated] = strval(Field);
        factionscreated++;
        X = FactionInfo[ID][fHQextX];
        Y = FactionInfo[ID][fHQextY];
        Z = FactionInfo[ID][fHQextZ];
        format(string, sizeof(string), "%s", FactionInfo[ID][fName]);
        FactionInfo[ID][fIcon] = Create3DTextLabel(string, COLRED, X, Y, Z, 20.0, 0, 1);
    }
    db_free_result(Result);
    print(Query);
    return printf("Faction ID %d loaded successfully", ID);
}
Reply
#2

I had the same problem and this fixed it:

In the saving query, try using %.4f for the float placeholder instead of %f.
Reply
#3

that didnt fix it D:
Reply
#4

show SaveFaction stock , your problem in saving not loading
Reply
#5

Quote:
Originally Posted by DaTa[X]
Посмотреть сообщение
show SaveFaction stock , your problem in saving not loading
Okay, but the query is correct?

pawn Код:
stock SaveFaction(ID)
    {
    new Query[600], string[100];
    format(Query, sizeof(Query), "UPDATE `FACTIONS` (NAME = '%s', INTX = %. 4f, INTY = %.4f, INTZ = %.4f, EXTX = %.4f, EXTY = %.4f, EXTZ = %.4f, VW = %d, INT = %d, CREATED = %d WHERE `ID` = %d", FactionInfo[ID][fName], FactionInfo[ID][fHQintX],    FactionInfo[ID][fHQintY], FactionInfo[ID][fHQintZ], FactionInfo[ID][fHQextX], FactionInfo[ID][fHQextY], FactionInfo[ID][fHQextZ], FactionInfo[ID][fHQVW], FactionInfo[ID][fHQint], FactionInfo[ID][fCreated], FactionInfo[ID][fID]);
    db_query(survival, Query);
    print(Query);
    format(string, sizeof(string), "Faction ID %d saved successfully", ID);
    print(string);
    return 1;
    }
Reply
#6

Try this:

pawn Код:
stock SaveFaction(ID)
{
    new Query[600], string[100];
    format(Query, sizeof(Query), "UPDATE `FACTIONS` SET `NAME` = '%s', `INTX` = '%.4f', `INTY` = '%.4f', `INTZ` = '%.4f', `EXTX` = '%.4f', `EXTY` = '%.4f', `EXTZ` = '%.4f', `VW` = '%d', `INT` = '%d', `CREATED` = '%d' WHERE `ID` = %d", FactionInfo[ID][fName], FactionInfo[ID][fHQintX],    FactionInfo[ID][fHQintY], FactionInfo[ID][fHQintZ], FactionInfo[ID][fHQextX], FactionInfo[ID][fHQextY], FactionInfo[ID][fHQextZ], FactionInfo[ID][fHQVW], FactionInfo[ID][fHQint], FactionInfo[ID][fCreated], FactionInfo[ID][fID]);
    db_query(survival, Query);
    print(Query);
    format(string, sizeof(string), "Faction ID %d saved successfully", ID);
    print(string);
    return 1;
}
Reply
#7

thanks!
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)