28.07.2013, 01:05
I've had some problems with a business system with SQLite
I've created the table using:
I've set once the bizid field with the code:
And I'm trying to update stats with this:
In Game it works, the pickup appears, and when I press enter my coords will be set to 0.0, 0.0, 0.0 (the default exit coords of biz)
But nothing changed in the database...
For loading I'm using:
some help please?
I've created the table using:
Код:
strcat(dbstring, "CREATE TABLE IF NOT EXISTS bizs('bizid' INTEGER PRIMARYKEY DEFAULT 0, 'owner' VARCHAR(24) DEFAULT 'Nessuno' COLLATE NOCASE, 'owned' INTEGER DEFAULT 0,'entratax' REAL DEFAULT 0.0 NOT NULL, 'entratau' REAL DEFAULT 0.0 NOT NULL, 'entrataz' REAL DEFAULT 0.0 NOT NULL, 'uscitax' REAL DEFAULT 0.0 NOT NULL, 'uscitay' REAL DEFAULT 0.0 NOT NULL, 'uscitaz' REAL DEFAULT 0.0 NOT NULL"); strcat(dbstring, ",'locked' INTEGER DEFAULT 0, 'entrance' INTEGER DEFAULT 0, 'interior' INTEGER DEFAULT 0, 'world' INTEGER DEFAULT 0, 'buyprice' INTEGER DEFAULT 999999, 'nome' VARCHAR(60) DEFAULT 'Biz In Vendita', 'cassa' INTEGER DEFAULT 0, 'insint' INTEGER DEFAULT 0, 'insworld' INTEGER DEFAULT 0, 'tipo' INTEGER DEFAULT 0)"); db_query( Database, dbstring);
Код:
forward SetBiz(); public SetBiz() { for(new i=0; i < MAX_BIZ; i++) { new Query[128]; format(Query, sizeof(Query), "INSERT INTO 'bizs' (bizid) VALUES (%d)", i); db_query(Database, Query); } printf("Set Biz finito!"); }
Код:
CMD:createbiz(playerid, params[]) { if(PlayerInfo[playerid][pAdmin] >= 4) { new bizid, price; if(sscanf(params, "dd", bizid, price)) return SCM(playerid, 0xFF0000FF, "USE: /createbiz <bizid> <prezzo>"); else { new Float:X, Float:Y, Float:Z; GetPlayerPos(playerid, X, Y, Z); new query[512]; format(query, sizeof(query), "UPDATE `bizs` SET 'entratax' = '%f', 'entratau' = '%f', 'entrataz' = '%f' `buyprice` = '%d' WHERE `bizid` = '%d'", X, Y, Z, price, bizid); db_query( Database, query); db_free_result(db_query(Database, query)); BizInfo[bizid][bID] = bizid; BizInfo[bizid][bEX] = X; BizInfo[bizid][bEY] = Y; BizInfo[bizid][bEZ] = Z; BizInfo[bizid][bBuyPrice] = price; if(BizInfo[bizid][bIcon]) { DestroyDynamicPickup(BizInfo[bizid][bIcon]); } BizInfo[bizid][bIcon] = CreateDynamicPickup(1239, 1, X, Y, Z); new string[128]; format(string, sizeof(string), "%s created biz id %d. price %d", RUS(playerid), bizid, price); SCM(playerid, COLOR_RED, string); //SaveBiz(); } } return 1; }
But nothing changed in the database...
For loading I'm using:
Код:
stock LoadBiz() { new DBResult:result; new query[128], field[64]; for (new i = 0; i < MAX_BIZ; i++) { format(query, sizeof(query), "SELECT * FROM `bizs` WHERE bizid = '%d'", i); result = db_query(BizDB, query); if (db_num_rows(result)) { new owned, Float:x, Float:y, Float:z, Float:xx, Float:yy, Float:zz, locked, entrance, interior, buyprice, insideinterior, insideworld, world, type; db_get_field_assoc(result, "owned", field, sizeof(field)); owned = strval(field); db_get_field_assoc(result, "owner", BizInfo[i][bOwner], 24); db_get_field_assoc(result, "entratax", field, sizeof(field)); x = strval(field); db_get_field_assoc(result, "entratau", field, sizeof(field)); y = strval(field); db_get_field_assoc(result, "entrataz", field, sizeof(field)); z = strval(field); db_get_field_assoc(result, "uscitax", field, sizeof(field)); xx = strval(field); db_get_field_assoc(result, "uscitay", field, sizeof(field)); yy = strval(field); db_get_field_assoc(result, "uscitaz", field, sizeof(field)); zz = strval(field); db_get_field_assoc(result, "locked", field, sizeof(field)); locked = strval(field); db_get_field_assoc(result, "entrance", field, sizeof(field)); entrance = strval(field); db_get_field_assoc(result, "interior", field, sizeof(field)); interior = strval(field); db_get_field_assoc(result, "buyprice", field, sizeof(field)); buyprice = strval(field); db_get_field_assoc(result, "insint", field, sizeof(field)); insideinterior = strval(field); db_get_field_assoc(result, "insworld", field, sizeof(field)); insideworld = strval(field); db_get_field_assoc(result, "world", field, sizeof(field)); world = strval(field); db_get_field_assoc(result, "tipo", field, sizeof(field)); type = strval(field); db_get_field_assoc(result, "nome", BizInfo[i][bNome], 60); BizInfo[i][bOwned] = owned; BizInfo[i][bEX] = x; BizInfo[i][bEY] = y; BizInfo[i][bEZ] = z; BizInfo[i][bUX] = xx; BizInfo[i][bUY] = yy; BizInfo[i][bUZ] = zz; BizInfo[i][bLocked] = locked; BizInfo[i][bEntrance] = entrance; BizInfo[i][bInterior] = interior; BizInfo[i][bBuyPrice] = buyprice; BizInfo[i][bInsideInterior] = insideinterior; BizInfo[i][bWorld] = world; BizInfo[i][bType] = type; BizInfo[i][bInsideWorld] = insideworld; BizInfo[i][bIcon] = CreateDynamicPickup(1239, 1, BizInfo[i][bEX], BizInfo[i][bEY], BizInfo[i][bEZ]); } db_free_result(result); } return 1; }