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

GlobalEvent 2.0 Database Cleaner - Inactive Players + The Players Child Data (skills, items, etc)

Kool just tested it made a few fixes, thanks for that darkhaos :) credits added.

Be careful with this
Lua:
for i = #childAttributeTables -1, #childAttributeTables do

Accounts tables should be the last two on the config.

Lua:
if config.deleteAccountWithNoPlayer then
			text = ">> [DBCLEANUP] " .. DB_NOW.players .. " inactive players and " .. DB_NOW.accounts .. " empty accounts have been deleted from the database."
		else
			text = ">> [DBCLEANUP] " .. DB_NOW.players .. " inactive players have been deleted from the database."
		end

Can be shortened to
Lua:
text = ">> [DBCLEANUP] " .. DB_NOW.players .. " inactive players" .. (config.deleteAccountWithNoPlayer and " and " .. DB_NOW.accounts .. " empty accounts" or "") .. " have been deleted from the database."
 
Last edited:
Be careful with this

Accounts tables should be the last two on the config.

Can be shortened to

You done this didn't you?
Lua:
for i = #childAttributeTables -1, #childAttributeTables do

and sweet shortened the string format
 
Umm.. I don't know what database you use, but on default TFS 0.3.6 mysql database when you delete account from `accounts` it delete all characters from this account and all skills,items... of these characters.
schema.mysql from 0.3.6pl1 said:
FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON DELETE CASCADE
 
Umm.. I don't know what database you use, but on default TFS 0.3.6 mysql database when you delete account from `accounts` it delete all characters from this account and all skills,items... of these characters.
that's not the point.

inactive players are first removed, and then if their accounts are empty, they're deleted as well.

and it's mysql.sql
 
Umm.. I don't know what database you use, but on default TFS 0.3.6 mysql database when you delete account from `accounts` it delete all characters from this account and all skills,items... of these characters.

It will only delete all the skills, and items etc if the you have added the triggers. It is not default. (I think)
 
Last edited:
Add to this script: Script checks all the houses at server and if owner is not online longer than x days, the script clean items from the house to owner depot and make home free (nobody owns this house)...

english, sorry.
 
Update! Made a major fix to Darkaos part of the script. Accounts were being removed without checking to make sure no players are on the account >.< need more thorough testing next time I think.
 
I highly recommend all those who got this, before this update. Update! Haha.
 
Bad error here... i just copy your file... but my server send me a error.... can you try help me?

Code:
[Error - GlobalEvent Interface]
data/globalevents/scripts/dbcleaner.lua:onStartup
Description:
data/globalevents/scripts/dbcleaner.lua:88: attempt to call field 'executeQuery'(a nil value)
stack traceback:
        data/globalevents/scripts/dbcleaner.lua:88: in function <data/globalevents/scripts/dbcleaner.lua:22>
 
change executeQuery to query

OP should make it compile with both 0.3.6 & 0.4
 
100-compat.lua

add: db.executeQuery = db.query
 
Last edited:
I need that script cleaning the houses too,
look:
03:14 You see a closed door.
It belongs to house 'Heavy Depot House'. owns this house.
ItemID: [6253].

"owns" this house, bugged houses, nobody can buy this house.
i Need tag for clean player house too,

help?
 
local childAttributeTables = {
players = {
[1] = {table = "`player_viplist`", idField = "`player_id`"},
[2] = {table = "`player_storage`", idField = "`player_id`"},
[3] = {table = "`player_spells`", idField = "`player_id`"},
[4] = {table = "`player_skills`", idField = "`player_id`"},
[5] = {table = "`player_namelocks`", idField = "`player_id`"},
[6] = {table = "`player_items`", idField = "`player_id`"},
[7] = {table = "`player_depotitems`", idField = "`player_id`"},
[8] = {table = "`players`", idField = "`id`"} -- Keep this as the last item in the array,
[9] = {table = "`houses`", idField = "`owner`"}


Correct?
 

Code:
	local childAttributeTables = {
		players = {
			[1] = {table = "`player_viplist`", idField = "`player_id`"},
			[2] = {table = "`player_storage`", idField = "`player_id`"},
			[3] = {table = "`player_spells`", idField = "`player_id`"},
			[4] = {table = "`player_skills`", idField = "`player_id`"},
			[5] = {table = "`player_namelocks`", idField = "`player_id`"},
			[6] = {table = "`player_items`", idField = "`player_id`"},
			[7] = {table = "`player_depotitems`", idField = "`player_id`"},
			[8] = {table = "`houses`", idField = "`owner`"},
			[9] = {table = "`house_auctions`", idField = "`player_id`"},
			[10] = {table = "`players`", idField = "`id`"} -- Keep this as the last item in the array
			--Note: `houses` and `bans` are in the DB triggers for TFS so don't worry about them.
			--Also I did not want to put killers, or deaths on here because that is historic data,
			--do so at your ouwn risk.
		},
		accounts = {
			[1] = {table = "`accounts`", idField = "`id`"},
			[2] = {table = "`account_viplist`", idField = "`account_id`"}
		}
	}

Not sure if that's how you want to do it, but it should work.
can add a new script on startup to remove houses that have no owner.name for the ones that have already been deleted.
 
Can you give me the new script to clean the house that gave error?
Thanks!
 
one more question:

Players banned for 30 days will be deleted with this script?

if a player is excluded from the 100 level, with 10 days of inactivity, so if he is banned for 30 days will be deleted?

Or not count when it banned?
 
why do i get these errors?

1y46tf.jpg


lost connection to mysql with this script + error doesnt work, help please
 
Back
Top