autoremovehouses - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: autoremovehouses (
/showthread.php?tid=617990)
autoremovehouses - iLearner - 29.09.2016
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;
}
Re: autoremovehouses -
Vince - 29.09.2016
- You cannot get a field "playerName" if you don't select that field.
- Why are you even using MySQL functions when it's SQLite?
Re: autoremovehouses -
Stinged - 29.09.2016
Quote:
Originally Posted by Vince
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.
Re: autoremovehouses - iLearner - 29.09.2016
I am getting playername & his last connect time from mysql, and then trying to remove his house from houses.db SQLITE
Re: autoremovehouses - iLearner - 30.09.2016
I tried to wait and the result of this cmd came after like 15mins of freezing server : 'cleaning completed 0 houses cleared'.