• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Gesior ACC] Show houses of owners who didn't login for X weeks

klekSu

Stroke my ego.
Joined
Nov 4, 2008
Messages
1,285
Reaction score
18
Hello otlanders!

I've just started my adventure with php and here's a first script made 100% by me (thank to little "how to" from polish board buddies).

This script is showing houses of owners who didn't login for X weeks (you can set the time in config). I thought it would be useful so here you are.

Screenshot:
housesd.png


Config:
PHP:
/////////////////////////////////////config/////////////////////////////////////
$level = 1000; //house of owners above this level won't be shown
$days = 28; //how many days player must be offline to show his house
$weeks = $days/7; //days/7 = weeks
$towns = array('No Town', 'Town 1', 'Town 2', 'Town 3');
//////////////////////////////////end of config/////////////////////////////////

Code of cleanhouses.php:
PHP:
<?PHP
////////////////////////////////////////////////////////////////////////////////
//Houses that owners didn't login for x days should be cleaned by a Gamemaster//
///////////////////////////////////by klekSu////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////config/////////////////////////////////////
$level = 1000; //house of owners above this level won't be shown
$days = 28; //how many days player must be offline to show his house
$weeks = $days/7; //days/7 = weeks
$towns = array('No Town', 'Town 1', 'Town 2', 'Town 3');
//////////////////////////////////end of config/////////////////////////////////

//////////////////////////////////////query/////////////////////////////////////
$qe = $SQL->query('SELECT `players`.`account_id`,`players`.`id`,`players`.`name` as `name`,`players`.`level` as `level`, `players`.`lastlogin` AS `lastlogin`, `houses`.`owner`,`houses`.`id` AS `hid`, `houses`.`name` AS `hname`, `houses`.`town` AS `htown`, `accounts`.`id` FROM `players`,`houses`,`accounts` WHERE `accounts`.`id` = `players`.`account_id` AND `houses`.`owner` = `players`.`id` AND `players`.`level` < '.(int) $level.' AND `players`.`lastlogin` < UNIX_TIMESTAMP() - '.(int) $days.'*24*60*60 ORDER BY `htown` ASC, `lastlogin`;');
//////////////////////////////////end of query//////////////////////////////////

$main_content .= '
<H2>
	<CENTER>
		House owners on '.$config['site']['worlds'][(int) $_GET['world']].' which have not logged in for '.(int) $weeks.' weeks +
	</CENTER>
</H2>';

$main_content .= '
<CENTER>
<TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%>
	<TR bgcolor="'.$config['site']['vdarkborder'].'">
		<TD><FONT COLOR="white"><B>Character Name</B></FONT></TD>
		<TD ALIGN="center"><FONT COLOR="white"><B>Last Login</B></FONT></TD>
		<TD ALIGN="center"><FONT COLOR="white"><B>House</B></FONT></TD>
		<TD ALIGN="right"><FONT COLOR="white"><B>Town</B></FONT></TD>
';

foreach( $qe as $k )
{
	if(is_int($number_of_rows / 2))
	{
		$bgcolor = $config['site']['darkborder'];
	}
	else
	{
		$bgcolor = $config['site']['lightborder'];
	}
	$number_of_rows++;

$main_content .= '
	<TR BGCOLOR="'.$bgcolor.'">
		<TD><A HREF="?subtopic=characters&name='.$k['name'].'">'.$k['name'].'</A> (Level: '.$k['level'].')</TD>
		<TD ALIGN="center">'.date("j F Y", $k['lastlogin']).'</TD>';
	if(!empty($k['hname']))
	{
		$main_content .= '
		<TD ALIGN="center">'.$k['hname'].'</TD>
		';
	}
	else
	{
		$main_content .= '
		<TD ALIGN="center">No Name</TD>
		';
	}
		$main_content .= '
		<TD ALIGN="right">'.$towns[$k['htown']].'</TD>
	</TR>';
}

$main_content .= '
</TABLE>
</CENTER>
';

?>

Add to index.php
PHP:
	case "cleanhouses";
		$topic = "Clean Houses";
		$subtopic = "cleanhouses";
		include("cleanhouses.php");
	break;
 
Last edited:
Nice, would be cool if you could made a function on site that removes hes house + writing something like [House Removed] after he's name

Anyways, nice rep++
 
House can't be cleaned on the website when ot's running. But I might provide you with a script that does it in-game.
 
Thanks everyone :) I'll keep up the work and make something more usefull soon :D
 
In your php script is a syntax error.

PHP:
´$towns = array('No Town', 'Town 1', 'Town 2', 'Town 3';

change to

PHP:
$towns = array('No Town', 'Town 1', 'Town 2', 'Town 3');

Anyway nice script :)
 
I have mystic spirit 0.2.9 and I have problem

Fatal error: Call to a member function query() on a non-object in D:\xampp\htdocs\cleanhouses.php on line 15
 
Back
Top