Ok mhm, you can do this in 2 ways:
1- Cron jobs (Maybe hard?)
2- A check every start server and pay day (if you have, else we will see.)
Cron jobs: Every 7 days run a PHP script which checks the last join of the owner and if he have a house remove his ownership
PHP код:
//
// [...] Connection lines
//
$stmt = $mysqli->prepare ("SELECT last_join, houseid FROM users WHERE nickname = ?");
$stmt->bind_param ("s", $nickname);
$stmt->bind_result ($last_join, $houseid);
$stmt->execute();
$stmt->fetch();
$stmt->close();
if ( (time() + (7 * 24 * 60 * 60)) > $last_join ) {
// You can do
// $mysqli->query ("UPDATE etc.");
// too
// but..
$stmt = $mysqli->prepare("UPDATE owner = 0 FROM houses WHERE id = ?");
$stmt->bind_param ("i", $houseid);
$stmt->execute();
$stmt->close();
}
Ook, i keep the code above because can help you if you want to create a user panel (to understand better mysqli) but while i write the code i get an idea, do the check when the player connects
Pro:
No cron jobs
against:
If the player no joins anymore the house will never losed.
Ok i think is not the better way to do this.. now the second way:
You have a pay day? If you have a pay day you can run a query to do this check but i think this code should not be managed by the gamemode if you have the mysql and a web site.
If you cant host a .php file you can do something like this:
Код:
mysql_query ("SELECT houseid FROM users WHERE last_join > (UNIX_TIMESTAMP() + (7 * 24 * 60 * 60)) AND houseid > 0");
I'm not sure if (UNIX_TIMESTAMP() + (7 * 24 * 60 * 60)) is corrent, should exists much better functions in MySQL to do this, if you want to do this you can use ******.
Ok, if i should choose i prefer to do with PHP script.. maybe someone with more experience in this area can say a better solution.