29.09.2016, 13:57
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
PHP код:
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);
//mysql_store_result();
//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,
houseQuery[200],
deleteQuery[200];
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);
resultcounter++;
reloadHouses();
break;
}
}
}
}
new str[144];
format(str, sizeof(str), "Cleaning completed %d houses cleared", resultcounter);
SendClientMessage(playerid, 0x00FFFFFF, str);
return 1;
}