Need help with house system [SQLite]
#1

The problem with following is that house ID keeps being same even if I create multiple houses...
it'll stay as ID 1, even tho in database it increases like 1 2 3 4 5...

pawn Код:
CMD:createhouse(playerid,params[])
{
    new Float:EX, Float:EY, Float:EZ, Float:IX, Float:IY, Float:IZ, Cast, Int, Word, name[21], owna[12];
    if(sscanf(params, "fffddds[21]s[21]", IX, IY, IZ, Cast, Int, Word, name, owna)) return SendClientMessage(playerid, RED, "/createhouse IX, IY, IZ, Cost, InteriorID, WorldID, name, owner");
    new Query[280], DBResult:result;
    GetPlayerPos(playerid, EX, EY, EZ);
    format(Query, sizeof(Query), "INSERT INTO houses (name, owner, enterx, entery, enterz, interx, intery, interz, cost, interior, world) VALUES ('%s', '%s', '%f', '%f', '%f', '%f', '%f', '%f', %d, %d, %d)", name, owna, EX, EY, EZ, IX, IY, IZ, Cast, Int, Word);
    result = db_query(BFU, Query);
    if(result) SendClientMessage(playerid, 0x00FF00AA, "House created.");
    else if(!result) SendClientMessage(playerid, 0xFF0000AA, "House failed.");
   
    new DBResult:Result, hid;
    Result = db_query(BFU, "SELECT * FROM houses");
    if(db_num_rows(Result))
    {
        new Field[190];
        db_get_field_assoc(Result, "id", Field, 9); hid = strval(Field);
        db_get_field_assoc(Result, "name", Field, 21); format(HouseInfo[hid][Name], 21, "%s", Field);
        db_get_field_assoc(Result, "owner", Field, 21); format(HouseInfo[hid][Owner], 21, "%s", Field);
        db_get_field_assoc(Result, "enterx", Field, 20); HouseInfo[hid][Enter][0] = floatstr(Field);
        db_get_field_assoc(Result, "entery", Field, 20); HouseInfo[hid][Enter][1] = floatstr(Field);
        db_get_field_assoc(Result, "enterz", Field, 20); HouseInfo[hid][Enter][2] = floatstr(Field);
        db_get_field_assoc(Result, "interx", Field, 20); HouseInfo[hid][Inter][0] = floatstr(Field);
        db_get_field_assoc(Result, "intery", Field, 20); HouseInfo[hid][Inter][1] = floatstr(Field);
        db_get_field_assoc(Result, "interz", Field, 20); HouseInfo[hid][Inter][2] = floatstr(Field);
        db_get_field_assoc(Result, "cost", Field, 8); HouseInfo[hid][Cost] = strval(Field);
        db_get_field_assoc(Result, "interior", Field, 5); HouseInfo[hid][Interior] = strval(Field);
        db_get_field_assoc(Result, "world", Field, 5); HouseInfo[hid][World] = strval(Field);
        if(Result) SendClientMessage(playerid, 0x00FF00AA, "House loaded.");
        else if(!Result) SendClientMessage(playerid, 0xFF0000AA, "House not loaded.");
    }
    db_free_result(Result);
    HouseInfo[hid][EnPickup] = CreatePickup(1273, 1, EX, EY, EZ, 0);
    HouseInfo[hid][ExPickup] = CreatePickup(1273, 1, IX, IY, IZ, 0);
    new str[128];
    format(str,sizeof(str), "created house id %d", hid);
    SendClientMessage(playerid, 0xFF0000AA, str);
    return 1;
}
Reply


Messages In This Thread
Need help with house system [SQLite] - Konstantinos, Pottus - by LocMax - 27.06.2014, 11:09
Re: Need help with house system [SQLite] - by Noliax8 - 27.06.2014, 11:19
Re: Need help with house system [SQLite] - by LocMax - 27.06.2014, 11:42
Re: Need help with house system [SQLite] - by Konstantinos - 27.06.2014, 12:06
Re: Need help with house system [SQLite] - by LocMax - 27.06.2014, 12:31
Re: Need help with house system [SQLite] - by Konstantinos - 27.06.2014, 12:39
Re: Need help with house system [SQLite] - by LocMax - 27.06.2014, 13:22
Re : Need help with house system [SQLite] - by Noliax8 - 27.06.2014, 13:32
Re: Need help with house system [SQLite] - by Pottus - 27.06.2014, 13:41
Re: Need help with house system [SQLite] - by LocMax - 27.06.2014, 13:42

Forum Jump:


Users browsing this thread: 1 Guest(s)