• 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!

Delete house if player is inactive!

Samme

.::EmmaS-SammE::.
Senator
Joined
Mar 4, 2008
Messages
2,398
Reaction score
50
Location
/poland
Hello Otlanders.

Today I would like to present you my next script that delete houses of players that doesnt not login with x days (config) their levels is lower than value in config and doesnt have pacc!

I wont explain how to install that, its script for admins who know anything about PHP, so kids that make OTS only for $$ and doesnt have brain, please dont touch this code.

So, here is the code:

PHP:
<?PHP
if($logged)
{
    if($group_id_of_acc_logged >= $config['site']['access_admin_panel'])
    {
//config//
$level = 1000; //Player with highter than this value wont be touched.
$days_ago = 15; //Clean house if player doesnt not login with days ago value+
//config-end//

$players_clean = $SQL->query('SELECT `players`.`account_id`,`players`.`id`,`players`.`name`,`players`.`level`,`houses`.`owner`,`houses`.`id`,`accounts`.`premdays`,`accounts`.`id` FROM `players`,`houses`,`accounts` WHERE `accounts`.`premdays` = 0 AND `accounts`.`id` = `players`.`account_id` AND `houses`.`owner` = `players`.`id` AND `players`.`level` < '.(int) $level.' AND `players`.`lastlogin` < UNIX_TIMESTAMP() - '.(int) $days_ago.'*24*60*60;');
$number_of_players_clean = 0;
foreach($players_clean as $player) {
$do_clean = $SQL->query('UPDATE houses SET owner=0, lastwarning=0 WHERE owner='.(int) $player['owner'].'');
$number_of_players_clean++;

	if(is_int($number_of_players_clean / 2))
		$bgcolor = $config['site']['darkborder'];
	else
		$bgcolor = $config['site']['lightborder'];

	$players_rows .= '<TR BGCOLOR='.$bgcolor.'><TD WIDTH=57%><A HREF="?subtopic=characters&name='.urlencode($player['name']).'">'.$player['name'].'</A></TD><TD WIDTH=10%>'.$player['level'].'</TD></TR>';
}

if(empty($player))
$main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD CLASS=white><B>Status</B></TD></TR><TR BGCOLOR='.$config['site']['darkborder'].'><TD><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=1><TR><TD>There is nothing to delete!</b></TD></TR></TABLE></TD></TR></TABLE>';
else
$main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD CLASS=white><B>Status</B></TD></TR><TR BGCOLOR='.$config['site']['darkborder'].'><TD><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=1><TR><TD>Deletion Succesfull!</b></TD></TR></TABLE></TD></TR></TABLE><BR><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD CLASS=white><B>Houses of those players has been deleted!</B></TD></TR></TABLE><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD><A HREF="?subtopic=whoisonline&order=name" CLASS=white>Name</A></TD><TD><A HREF="?subtopic=whoisonline&order=level" CLASS=white>Level</A></TD></TR>'.$players_rows.'</TABLE>';
	}
else
{
    $main_content .= '<center><i>You dont have access to browse this page!</i></center>';
}
}
else
{
    $main_content .= 'Please enter your account number and your password.<br/><a href="?subtopic=createaccount" >Create an account</a> if you do not have one yet.<br/><br/><form action="?subtopic=clean" method="post" ><div class="TableContainer" >  <table class="Table1" cellpadding="0" cellspacing="0" >    <div class="CaptionContainer" >      <div class="CaptionInnerContainer" >        <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <div class="Text" >Account Login</div>        <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>      </div>    </div>    <tr>      <td>        <div class="InnerTableContainer" >          <table style="width:100%;" ><tr><td class="LabelV" ><span >Account Number:</span></td><td style="width:100%;" ><input type="password" name="account_login" SIZE="10" maxlength="10" ></td></tr><tr><td class="LabelV" ><span >Password:</span></td><td><input type="password" name="password_login" size="30" maxlength="29" ></td></tr>          </table>        </div>  </table></div></td></tr><br/><table width="100%" ><tr align="center" ><td><table border="0" cellspacing="0" cellpadding="0" ><tr><td style="border:0px;" ><div class="BigButton" style="background-image:url('.$layout_name.'/images/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Submit" alt="Submit" src="'.$layout_name.'/images/buttons/_sbutton_submit.gif" ></div></div></td><tr></form></table></td><td><table border="0" cellspacing="0" cellpadding="0" ><form action="?subtopic=lostaccount" method="post" ><tr><td style="border:0px;" ><div class="BigButton" style="background-image:url('.$layout_name.'/images/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Account lost?" alt="Account lost?" src="'.$layout_name.'/images/buttons/_sbutton_accountlost.gif" ></div></div></td></tr></form></table></td></tr></table>';
}  
?>

Hope that you like it, also I would mind a reputation point from you. ^_^
 
Last edited:
Lol i like it, thanks. Reputation goes to you. Too bad it does not clean the houses from items.
__________________
klekSu.png

You are welcome on kleksoria.com!
Please visit new open tibia forum with it's own ots list. otservers.net!
 
Last edited:
Lol i like it, thanks. Reputation goes to you. Too bad it does not clean the houses from items.

Yeah, but if any player will buy this house again, items got cleaned auto I think.

//Updated a script a lil' bit (protection against unwanted intruders :p)
 
Last edited:
Well lol, i cleaned around 50 houses but owners keep being owners in game (on site houses were empty). I thought restart is needed but when global save with shutdown came owners are owners again and no free house(either on site, every house is taken by the old owner), if you know what i mean :D

It has been implemented few days ago to the TFS ;<

Cpp or lua?
__________________
klekSu.png

You are welcome on kleksoria.com!
Please visit new open tibia forum with it's own ots list. otservers.net!
 
Last edited:
Nice, but i don't know where i must past this code :/
Who can help me (please).
Yours GarQet
 
Well lol, i cleaned around 50 houses but owners keep being owners in game (on site houses were empty). I thought restart is needed but when global save with shutdown came owners are owners again and no free house(either on site, every house is taken by the old owner), if you know what i mean :D



Cpp or lua?

You should clean houses while server is closed ;> then after restart run it again.

Nice, but i don't know where i must past this code :/
Who can help me (please).
Yours GarQet

Read first posts (its for admins who knows ANYTHING about PHP)!
 
Add a second query that cleans the houses also. Else players can buy the houses with items:p

Also I think a lua code would be better, since its automated then:p. Now you still need to do a part manually.
 
Even if you did, that the purified cottages with items that would be nice!
 
So the script isn't usefull cause i never turn my server off not including global save which takes 1 minute to restart. And then i'm always sleeping.
__________________
klekSu.png

You are welcome on kleksoria.com!
Please visit new open tibia forum with it's own ots list. otservers.net!
 
Last edited:
I am glad this has been implemented into TFS...
This situtation always occurs.

Manually resetting houses, especially with tons of items in them sux!
 
Add a second query that cleans the houses also. Else players can buy the houses with items:p

Also I think a lua code would be better, since its automated then:p. Now you still need to do a part manually.

Nah, when players buy house it automatically get cleaned.
But I think people see items in the house they dont check owner xD:) So they dont know if it's 'Nobody'.
 
On which tfs does it work ? i got tfs 0.2.5 , where gonna i post the code?
 
Back
Top