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
#2

Uhhhm first of all your script does not have a interior or where you will place the interior...I will answer your question after i finish studying sqlite :P i am studying it right now
Reply
#3

Quote:
Originally Posted by Ryan_Obeles
Посмотреть сообщение
Uhhhm first of all your script does not have a interior or where you will place the interior...I will answer your question after i finish studying sqlite :P i am studying it right now
If you meant interior as in the house's itnerior

My house system works differently

pawn Код:
stock GetHouseExit(houseid, &Float:X, &Float:Y, &Float:Z, &interior)
{
    new type = H[houseid][Type];
    switch(type)
    {
        case HOUSE_SMALL:
        {
            interior = 15;
            X = 295.138977;
            Y = 1474.469971;
            Z = 1080.519897;
        }
        case HOUSE_MEDIUM:
        {
            interior = 2;
            X = 225.756989;
            Y = 1240.000000;
            Z = 1082.149902;
        }
        case HOUSE_BIG:
        {
            interior = 3;
            X = 235.508994;
            Y = 1189.169897;
            Z = 1080.339966;
        }
        case HOUSE_HUGE:
        {
            interior = 5;
            X = 1299.14;
            Y = -794.77;
            Z = 1084.00;
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)