|
Use getdate and check what day it is. Update all the fields in the database that meet the criteria you specified, and update another table which says that the update was done, and to do it next Monday.
|
[forward OnAuctionSearch();
public OnAuctionSearch()
{
new query[256], house, final[256], item, biz, type, pID;
for(new i; i < 999; i++)
{
format(query, sizeof(query), "SELECT * FROM `playeraccounts` WHERE `playerHoursLastMonth` < 60");
new Cache: aucs = mysql_query(handle, query);
for(new x, j = cache_get_row_count(); x != j; ++x)
{
cache_get_field_content(x, "playerHouse", final); house = strval(final);
cache_get_field_content(x, "playerBussines", final); biz = strval(final);
cache_get_field_content(x, "playerID", final); pID = strval(final);
if(biz > 0)
{
format(query, sizeof(query), "INSERT INTO `auctions` (`auctionType`, `auctionItemID`) VALUES ('1', '%d')", biz);
mysql_tquery(handle, query);
format(query, sizeof(query), "UPDATE `playeraccounts` SET `playerBussines` = '0' WHERE `playerID` = '%d'", pID);
mysql_tquery(handle, query);
}
if(house > 0)
{
format(query, sizeof(query), "INSERT INTO `auctions` (`auctionType`, `auctionItemID`) VALUES ('2', '%d')", house);
mysql_tquery(handle, query);
format(query, sizeof(query), "UPDATE `playeraccounts` SET `playerHouse` = '0' WHERE `playerID` = '%d'", pID);
mysql_tquery(handle, query);
}
}
cache_delete(aucs);
}
return 1;
}