View Full Version : autoremovehouses

29/09/2016, 01:57 PM
Hello, i am using this code to remove houses whom owners havent connected from past 7 days, but its not working but freezes / crashes the server instead, its SQLITE

COMMAND:autoremovehouses(playerid, params[])
new query[200], pname[24], sweep[4], resultcounter;

for(new i = 0; i < MAX_SCRIPT_HOUSES; i++)
mysql_format(1, query, sizeof(query), "SELECT `sweepCompleted` FROM `playerdata` WHERE `playerName` = '%s'", houseStuff[i][house_owner]);
mysql_query(1, query);
//new rows = mysql_num_rows();
if (cache_num_rows() > 0)
cache_get_field_content(0, "playerName", pname, 1, 129);
cache_get_field_content(0, "sweepCompleted", sweep, 1, 129);

new houseid,
new DBResult:qresult, count = 0;
qresult = db_query(DB: HOUSEDB, houseQuery);
count = db_num_rows(qresult);
new sweepValue = strval(sweep);
if ((getdate() - sweepValue) > 7)
// Find the unique ID for house info
new dbID, value[48];
db_get_field_assoc(qresult, "house_id", value, 48); // House UID
dbID = strval(value);
if(houseStuff[i][house_id] == dbID)

format(deleteQuery, sizeof(deleteQuery), "UPDATE `house_data` SET `house_bought` = '0', `house_owner` = 'None' WHERE `house_id` = '%i'", dbID);
db_query(DB: HOUSEDB, deleteQuery);
new str[144];
format(str, sizeof(str), "Cleaning completed %d houses cleared", resultcounter);
SendClientMessage(playerid, 0x00FFFFFF, str);
return 1;

29/09/2016, 03:59 PM
You cannot get a field "playerName" if you don't select that field.
Why are you even using MySQL functions when it's SQLite?

29/09/2016, 05:10 PM
Why are you even using MySQL functions when it's SQLite?

It seems that he's using a MySQL database and an SQLite one at the same time.
Why he's doing that instead of using one of those two is beyond me.

29/09/2016, 07:37 PM
I am getting playername & his last connect time from mysql, and then trying to remove his house from houses.db SQLITE

30/09/2016, 05:10 AM
I tried to wait and the result of this cmd came after like 15mins of freezing server : 'cleaning completed 0 houses cleared'.