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

Empty unused homes

Nightimarez

New Member
Joined
Jul 24, 2008
Messages
287
Reaction score
2
Alright so I have this script for Crying Damnson, but I need it converted to Mystic Spirit.

PHP:
--Adam 2008

--Goosio OT

local safelist = {}

function onSay(cid, words, param)
if getPlayerGroupId(cid) > 2 then
    pdelete = "Inactive Players With Houses:\n\n"
    days = 10*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                    
                        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

This is the error I'm getting.
PHP:
attempt to index global 'db' (a nil value)
 
i found this a while ago for 0.3.6 i dont know 0.2 functions but maybe it will work

Code:
local function getLastLoginDiff(name)
local res = db.getResult("SELECT `lastlogin` FROM `players` WHERE `name` = '"..name.."';")
    if res:getID() ~= -1 then
        return os.time()-res:getDataInt('lastlogin')
    end
end

local config = {
timeInDays = 30,
delay = 10,
delayStorage = 1210
}

function onSay(cid, words, param, channel)
    local pos,s,dir = getPlayerPosition(cid),getPlayerPosition(cid),getCreatureLookDirection(cid)
    if config.delay ~= 0 and getPlayerStorageValue(cid,config.delayStorage) >= os.time() then
        return doSendMagicEffect(pos,2) and doPlayerSendCancel(cid,"You can only use this command every " .. config.delay .. " seconds. You have to wait " .. getPlayerStorageValue(cid,config.delayStorage)-os.time() .. " more seconds.")
    end
    pos.x = dir == 1 and pos.x+1 or dir == 3 and pos.x-1 or pos.x
    pos.y = dir == 0 and pos.y-1 or dir == 2 and pos.y+1 or pos.y
    local abuse = config.delay ~= 0 and setPlayerStorageValue(cid,config.delayStorage,os.time()+config.delay)
    
    local house = getHouseFromPos(pos)
    if house == false then
        return doSendMagicEffect(s,2) and doPlayerSendCancel(cid,"This ain't a house tile.")
    end
    
    if getHouseOwner(house) == 0 then
        return doSendMagicEffect(s,2) and doPlayerSendCancel(cid,"This house has no owner. You can buy it the normal way using alana res.")
    end
    
    local owner = getPlayerNameByGUID(getHouseOwner(house))
    if not(getLastLoginDiff(owner) >= config.timeInDays*24*60*60) then
        return doSendMagicEffect(s,2) and doPlayerSendCancel(cid,owner.." is not inactive.")
    end
    
    if doPlayerRemoveMoney(cid,getHousePrice(house)) and not getHouseByPlayerGUID(getPlayerGUID(cid)) then
        return doSendMagicEffect(s,13) and setHouseOwner(house, getPlayerGUID(cid)) and doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,owner .. " has been inactive for more than " .. config.timeInDays .. " days.\nYou bought " .. getHouseName(house) .. " for " .. getHousePrice(house) .. ".")
    else
        return doSendMagicEffect(s,2) and doPlayerSendCancel(cid,"You need "..getHousePrice(house).." gold coins to buy " .. getHouseName(house) .. " or you already own a house.")
    end
end
 
why dont just set the time period of the rent to be weekly, so if the player does not play anymore they will lose his house automaticaly and all items will go to the depot
 
Soul4soul, I got this error. Thanks tho.

PHP:
[06/05/2011 02:55:00] data/talkactions/scripts/empty.lua:15: attempt to call global 'getCreatureLookDirection' (a nil value)
[06/05/2011 02:55:00] stack traceback:
[06/05/2011 02:55:00] 	[C]: in function 'getCreatureLookDirection'
[06/05/2011 02:55:00] 	data/talkactions/scripts/empty.lua:15: in function <data/talkactions/scripts/empty.lua:14

Evil Puncker, I have that, but players could stack their depot with lots of money and it will take a lot longer for them to lose their house.
 
Soul4soul, I got this error. Thanks tho.

PHP:
[06/05/2011 02:55:00] data/talkactions/scripts/empty.lua:15: attempt to call global 'getCreatureLookDirection' (a nil value)
[06/05/2011 02:55:00] stack traceback:
[06/05/2011 02:55:00] 	[C]: in function 'getCreatureLookDirection'
[06/05/2011 02:55:00] 	data/talkactions/scripts/empty.lua:15: in function <data/talkactions/scripts/empty.lua:14
Even if fixed, 0.2 still doesn't have getHouseFromPos
 
Back
Top