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

Lua House clean

Erikas Kontenis

Excellent OT User
Joined
Jul 3, 2009
Messages
1,938
Reaction score
682
Location
Lithuania
Tfs0.3.5
how to clean house after player buys it?

Like i just said !buyhouse command and house cleans?

thats what i tried but happened nothing...

owner.lua
LUA:
local NO_OWNER_PHRASE = {"none", "nobody", "0"}

function onSay(cid, words, param, channel)
	if(param == '') then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
		return true
	end

	local clean = true
	local t = string.explode(param, ",")
	if(t[2]) then
		clean = getBooleanFromString(t[2])
	end

	local name = tostring(t[1])
	if(not name) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid name specified.")
		return true
	end

	local guid = 0
	if(not table.isStrIn(name:lower(), NO_OWNER_PHRASE)) then
		guid = getPlayerGUIDByName(name)
	end

	if(not guid) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player not found.")
		return true
	end

	local hid = getHouseFromPos(getCreaturePosition(cid))
	if(not hid) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are not in a house.")
		return true
	end

	setHouseOwner(hid, guid, clean)
	local home = getHouseByPlayerGUID(getPlayerGUID(cid))
	doCleanHouse(home)
	return true
end
 
I sreached sources and found usefull how to make it clean after buy, this is that code but i need to know what function i need to add in c++ that confirm as doCleanHouse(home)

Code:
house->setOwnerEx(player->getGUID(), true);

LUA:
  house->setOwnerEx(player->getGUID(), true);
        std::string ret = "You have successfully bought this ";
        if(house->isGuild())
                ret += "hall";
        else
                ret += "house";

        ret += ", remember to leave money at ";
        if(house->isGuild())
                ret += "guild owner ";

        if(g_config.getBool(ConfigManager::BANK_SYSTEM))
                ret += "bank or ";

        ret += "depot of this town for rent.";
        player->sendTextMessage(MSG_INFO_DESCR, ret.c_str());

        g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_WRAPS_BLUE);
        return false;
}
 
i just wanna that when a new player bought a house with a !buyhouse command house cleans, clean is remove all moveable items if it is, becouse i have event wich removing players from houses if they havent logged in for a 2 weeks and thoose players items still in not used house if new player buys that house he buys it with all old items... i'm in think it can be done in lua this is code what i use.

when player says required param and in server is a player wich have not logged in for a 2 weeks he lose his house but in house still is old owner items, if new player bought that house old owner items inside house not deletes, i wanna that old items deletes after buy or after say that param.

LUA:
--Adam 2008
 
--Goosio OT
 
local safelist = {1,2}
 
function onSay(cid, words, param)
if getPlayerGroupId(cid) > 2 then
    pdelete = "Inactive Players With Houses:\n\n"
    days = 15*3600*24
    t=os.date('*t')
    local house = db.getResult("SELECT `owner`,`id` FROM `houses`")
    if(house:getID() ~= -1) then
        while (true) do
        local owner = house:getDataInt("owner")
        local hid = house:getDataInt("id")
            local player = db.getResult("SELECT `id`,`name`,`lastlogin` FROM `players` WHERE `id` = '"..owner.."'  ")
            if(player:getID() ~= -1) then
                local lastlogin = player:getDataInt("lastlogin")
                local pid = player:getDataInt("id")
                local name = player:getDataString("name")
                time=os.time(t) - lastlogin
                offline = time - days
                if offline >= 0 then
                    pdelete = pdelete.."House #"..hid.." owned by "..name.."\n"
                    if isInArray(safelist,hid) == FALSE then     
                        local home = getHouseByPlayerGUID(getPlayerGUID(cid))
	                    doCleanHouse(home)					
                        setHouseOwner(hid, 0)
                    end
                end
            player:free()
            end
            if not(house:next()) then
                break
            end
        end
 
        house:free()    
        doShowTextDialog(cid, 5958, pdelete)
    else
        doPlayerSendCancel(cid, "Error.")
    end
end
return TRUE
end
 
it removes house owner, but i wanna it remove owner house and clean that house also, do you understand fine what i mean? I mean house clean, thats something as map clean.
 
Back
Top