15.06.2012, 07:16
Quote:
It's a bit slow at updating queries.
Takes 3secs to run this code. Код:
stock SaveObjectVariables(ObjectId) { KillTimer(oTimerId[ObjectId]); new Query[250], DBResult: Result; oDB = db_open("Objects.db"); format(Query, 250, "SELECT * FROM object_data WHERE Id=%d", ObjectId); Result = db_query(oDB, Query); if(db_num_rows(Result) != 1) { format(Query, 250, "DELETE FROM object_data WHERE Id=%d", ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "INSERT INTO object_data (Id) VALUES (%d)", ObjectId), db_free_result(db_query(oDB, Query)); } db_free_result(Result); format(Query, 250, "UPDATE object_data SET ModelId=%d WHERE Id=%d", oModelId[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET Spawned=%d WHERE Id=%d", oSpawned[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET SpawnWorld=%d WHERE Id=%d", oSpawnWorld[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET SpawnInterior=%d WHERE Id=%d", oSpawnInterior[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET SpawnX=%f WHERE Id=%d", oSpawnX[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET SpawnY=%f WHERE Id=%d", oSpawnY[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET SpawnZ=%f WHERE Id=%d", oSpawnZ[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET SpawnRX=%f WHERE Id=%d", oSpawnRX[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET SpawnRY=%f WHERE Id=%d", oSpawnRY[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET SpawnRZ=%f WHERE Id=%d", oSpawnRZ[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET PosWorld=%d WHERE Id=%d", oPosWorld[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET PosInterior=%d WHERE Id=%d", oPosInterior[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET PosX=%f WHERE Id=%d", oPosX[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET PosY=%f WHERE Id=%d", oPosY[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET PosZ=%f WHERE Id=%d", oPosZ[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET PosRX=%f WHERE Id=%d", oPosRX[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET PosRY=%f WHERE Id=%d", oPosRY[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET PosRZ=%f WHERE Id=%d", oPosRZ[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET Timestamp=%d WHERE Id=%d", oTimestamp[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET IsGate=%d WHERE Id=%d", oIsGate[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET ClosedX=%f WHERE Id=%d", oClosedX[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET ClosedY=%f WHERE Id=%d", oClosedY[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET ClosedZ=%f WHERE Id=%d", oClosedZ[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET ClosedRX=%f WHERE Id=%d", oClosedRX[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET ClosedRY=%f WHERE Id=%d", oClosedRY[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET ClosedRZ=%f WHERE Id=%d", oClosedRZ[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET OpenedX=%f WHERE Id=%d", oOpenedX[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET OpenedY=%f WHERE Id=%d", oOpenedY[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET OpenedZ=%f WHERE Id=%d", oOpenedZ[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET OpenedRX=%f WHERE Id=%d", oOpenedRX[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET OpenedRY=%f WHERE Id=%d", oOpenedRY[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); format(Query, 250, "UPDATE object_data SET OpenedRZ=%f WHERE Id=%d", oOpenedRZ[ObjectId], ObjectId), db_free_result(db_query(oDB, Query)); db_close(oDB); printf("Object %d has saved.", ObjectId); oTimerId[ObjectId] = SetTimerEx("UpdateObject", 500, true, "d", ObjectId); return true; } |