SA-MP Forums Archive
How could I go about this? - 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: How could I go about this? (/showthread.php?tid=616668)



How could I go about this? - danielpalade - 08.09.2016

I'm trying to make a system which detects every monday which houses / bussinesses are not used anymore.
So if a player has less than 15 hours played in the last month, it would grab the id of his biz / house from the database, and insert it into the "auctions" category in the database. The "check" needs to look through every single player in the database to detect if he has less hours than 15. How could I do this?


Re: How could I go about this? - SickAttack - 08.09.2016

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.


Re: How could I go about this? - danielpalade - 08.09.2016

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
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.
This is what I have right now. Without the monday part.

Код:
[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;
}
Would this work?


Re: How could I go about this? - SickAttack - 08.09.2016

Have you at least tried it?


Re: How could I go about this? - danielpalade - 08.09.2016

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Have you at least tried it?
No, as I haven't finished it. I'm just asking if this could work.