SQLite help
#1

pawn Код:
db_query(Server,
    "CREATE TABLE IF NOT EXISTS `HOUSES`(`ID`, `NAME`, `OWNER`, `ENTRYX`, `ENTRYY`, `ENTRYZ`, `TYPE`, `LOCK`, `VALUE`, `MONEYINSIDE`) "
    );

pawn Код:
stock CreateHouse(name[], owner[], Float:eX, Float:eY, Float:eZ, type, value)
{
    new str[500], hid = house_count;
    format(str, 200, "SELECT * FROM `HOUSES` WHERE `ID` = '%d' ", hid);
    new DBResult:res;
    res = db_query(Server, str);
    if(!db_num_rows(res))
    {
        format(H[hid][Owner], 24, "%s", owner);
        format(H[hid][Name], 80, "%s", name);
        H[hid][Entry][0] = eX;
        H[hid][Entry][1] = eY;
        H[hid][Entry][2] = eZ;
        H[hid][Type] = type;
        H[hid][Value] = value;
        format(str, 120, "House ID %d\nOwned by %s\nValue %d\nHouse type: %s", hid, H[hid][Owner], H[hid][Value], GetTypeName(type) );
        H[hid][Info] = Create3DTextLabel(str, LIGHTBLUE, eX, eY, eZ, 25.0, 0, 1);
        H[hid][Pickup] = CreatePickup( GetPickupModel(hid), 1, eX, eY, eZ, -1);
        format(str, 500,
        "INSERT INTO `HOUSES`(`ID`, `NAME`, `OWNER`, `ENTRYX`, `ENTRYY`, `ENTRYZ`, `TYPE`, `LOCK`, `VALUE`, `MONEYINSIDE`) \
        VALUES ('%d', '%s', '%s', '%f', '%f, '%f', '%d', '0', '%d', '0')"
,
        hid, H[hid][Name], H[hid][Owner], H[hid][Entry][0], H[hid][Entry][1], H[hid][Entry][2], H[hid][Type], H[hid][Value]);
        db_query(Server, str);
        house_count++;
    }
    else
    {
        db_get_field_assoc(res, "NAME", H[hid][Name], 80);
        db_get_field_assoc(res, "OWNER", H[hid][Owner], 24);
        db_get_field_assoc(res, "ENTRYX", str, 20);
        H[hid][Entry][0] = floatstr(str);
        db_get_field_assoc(res, "ENTRYY", str, 20);
        H[hid][Entry][1] = floatstr(str);
        db_get_field_assoc(res, "ENTRYZ", str, 20);
        H[hid][Entry][2] = floatstr(str);
        db_get_field_assoc(res, "TYPE", str, 20);
        H[hid][Type] = strval(str);
        db_get_field_assoc(res, "LOCK", str, 5);
        H[hid][Lock] = strval(str);
        db_get_field_assoc(res, "VALUE", str, 20);
        H[hid][Value] = strval(str);
        db_get_field_assoc(res, "MONEYINSIDE", str, 20);
        H[hid][MoneyInside] = strval(str);
        format(str, 120, "House ID %d\nOwned by %s\nValue %d\nHouse type: %s", hid, H[hid][Owner], H[hid][Value], GetTypeName(H[hid][Type]) );
        H[hid][Info] = Create3DTextLabel(str, LIGHTBLUE, eX, eY, eZ, 25.0, 0, 1);
        H[hid][Pickup] = CreatePickup(GetPickupModel(hid), 1, eX, eY, eZ, -1);
        house_count++;
    }
    db_free_result(res);
    return 1;
}

Line used to create test house -

pawn Код:
CreateHouse("Gangs's pro house", "Gangs", 207.7694,-62.1330,1.8452, HOUSE_BIG, 200000);
House define's -
pawn Код:
#define HOUSE_SMALL 0
#define HOUSE_MEDIUM 1
#define HOUSE_BIG 2
#define HOUSE_HUGE 3

Problem is that there's no entry's created in the 'HOUSES' table in the Server.db in scriptfiles.
The house is created perfectly ingame
Any help?
Reply


Messages In This Thread
SQLite help - by CreativityLacker - 18.04.2013, 08:18
Re: SQLite help - by Ryan_Obeles - 18.04.2013, 08:27
Re: SQLite help - by CreativityLacker - 18.04.2013, 08:33

Forum Jump:


Users browsing this thread: 1 Guest(s)