Ir para conteúdo

Automatico House Clean [Works 100%]


TibiaGame

Posts Recomendados

Olá pessoal, eu sei que ja tem um tópico nessa área sobre esse script de House Clean, porém, não funcionou no meu TFS 0.4.0, aqui eu vou postar um que tem as funções corretamente para limpar as casas em todas as cidades do Servidor.

 

Créditos: nsanee

 

MOD VERSION:

 

<?xml version="1.0" encoding="UTF-8"?>
<mod name="Cleanhouses" version="1.03" author="nsanee" contact="otland.net" enabled="yes">
<globalevent name="cleanhouses" type="start" event="buffer"><![CDATA[


	local config = {
		days = 14,
		log = true,
		file = getDataDir() .. "/logs/cleanhouses.txt",
 onlyNonPremium = true
	}



	local ns_query =[[ SELECT houses.owner, houses.id as hid, houses.name as house_name ,players.name FROM houses
		LEFT JOIN players ON players.id=houses.owner
		LEFT JOIN accounts ON players.account_id=accounts.id
		WHERE players.lastlogin < (UNIX_TIMESTAMP() - ]] ..config.days.. [[*24*60*60)
		]] ..(config.onlyNonPremium and ' AND accounts.premdays=0 ' or '')..[[
		AND players.world_id =]] .. getConfigValue("worldId")

	local house = db.getResult(ns_query)
	local logs = "  Houses cleaned:\n\n"
	if house:getID() ~= -1 then
		repeat
			logs = logs .. house:getDataString('house_name') ..", owned by " .. house:getDataString('name') .. "\n"
			setHouseOwner(house:getDataInt('hid'), 0)
		until not house:next()
		house:free()
	else
		logs = logs .. "There were no houses to clean."
	end
	if config.log then
		doWriteLogFile(config.file, logs)
	end
	addEvent(doSaveServer, 1000)

]]></globalevent>
</mod>

 

 

GLOBALEVENTS (SCRIPTS)

Abra -> globalevents/globalevents.xml

Coloque:

 

<globalevent name="cleanhouses" type="start" event="script" value="cleanhouses.lua"/>

 

Crie um arquivo dentro da pasta scripts:

-> globalevents/scripts/cleanhouses.lua

 

 

local config = {

days = 14,

log = true,

file = getDataDir() .. "/logs/cleanhouses.txt"

}

local ns_query =[[ SELECT houses.owner,houses.id,players.name FROM houses

LEFT JOIN players ON players.id=houses.owner

WHERE players.lastlogin < (UNIX_TIMESTAMP() - ]] ..config.days.. [[*24*60*60)

AND

players.world_id =]] .. getConfigValue("worldId")

 

function onStartup(_time)

 

local house = db.getResult(ns_query)

local logs = " :: Houses cleaned:\n\n"

if house:getID() ~= -1 then

repeat

logs = logs .. getHouseInfo(house:getDataInt('id')).name ..", owned by " .. house:getDataString('name') .. "\n"

setHouseOwner(house:getDataInt('id'), 0)

until not house:next()

house:free()

else

logs = logs .. "There were no houses to clean."

end

if config.log then

doWriteLogFile(config.file, logs)

end

addEvent(doSaveServer, 1000)

end

 

Explicando: Onde está verde, você define os dias que o player tem que tár inativo (ausente) para a house ser limpa.

Para quem não entende um pouco, e tem dúvida, exemplo: "Onde coloco a hora pra limpar" , a resposta é, quando você liga o servidor ele já faz isso automatico!, qualquer outra dúvida só postar aqui!

 

Obrigado a todos!

Editado por TibiaGame
Link para o comentário
Compartilhar em outros sites

  • 3 weeks later...
×
×
  • Criar Novo...