Solved Lua Script Error: [GlobalEvent Interface]

Hugofasima

Website: thenosegang.servegame.com
Joined
Jun 24, 2015
Messages
206
Reaction score
22
Anyone can fix this script to me?

Error:
Lua Script Error: [GlobalEvent Interface]
data/globalevents/scripts/others/cleanHouse.lua: onStartup
data/globalevents/scripts/others/cleanHouse.lua:12: attempt to index a nil value

stack traceback:
[C]: in function '__index'
data/globalevents/scripts/others/cleanHouse.lua:12: in function <data/globalevents/scripts/others/cleanHouse.lua:3>

local days = 20 -- days to lose the house

function onStartup()
local resultId = db.storeQuery("SELECT `owner`,`id` FROM `houses`;")

if resultId then
repeat
local aux = db.storeQuery("SELECT `lastlogin` FROM `players` WHERE `id` = ".. result.getDataString(resultId, "owner") .. ";")

if aux then
if result.getDataInt(aux, "lastlogin") < os.time() - (days * 86400) then
House(result.getDataInt(resultId, "id")):setOwnerGuid(-1)
end
end

until not result.next(resultId)
end
saveServer()

return true
end

Thanks OT Land!


@EDIT: TFS 1.0 / Gesior 2012
 
Last edited:

StreamSide

Joseluis Gonzalez
Support Team
Joined
Aug 31, 2007
Messages
3,194
Reaction score
736
Location
Arica - Chile
Anyone can fix this script to me?

Error:
Lua Script Error: [GlobalEvent Interface]
data/globalevents/scripts/others/cleanHouse.lua: onStartup
data/globalevents/scripts/others/cleanHouse.lua:12: attempt to index a nil value

stack traceback:
[C]: in function '__index'
data/globalevents/scripts/others/cleanHouse.lua:12: in function <data/globalevents/scripts/others/cleanHouse.lua:3>

local days = 20 -- days to lose the house

function onStartup()
local resultId = db.storeQuery("SELECT `owner`,`id` FROM `houses`;")

if resultId then
repeat
local aux = db.storeQuery("SELECT `lastlogin` FROM `players` WHERE `id` = ".. result.getDataString(resultId, "owner") .. ";")

if aux then
if result.getDataInt(aux, "lastlogin") < os.time() - (days * 86400) then
House(result.getDataInt(resultId, "id")):setOwnerGuid(-1)
end
end

until not result.next(resultId)
end
saveServer()

return true
end

Thanks OT Land!
can you show me the players sql table :)
 

imkingran

Learning everyday.
Premium User
Joined
Jan 15, 2014
Messages
1,252
Reaction score
378
The only change I made was to check to make sure there was a house. This way at least won't throw an error message. ( I hope :p )
Code:
local days = 20 -- days to lose the house

function onStartup()
local resultId = db.storeQuery("SELECT `owner`,`id` FROM `houses`;")

    if resultId then
    repeat
    local aux = db.storeQuery("SELECT `lastlogin` FROM `players` WHERE `id` = " .. result.getDataString(resultId, "owner") .. ";")

        if aux then
            if result.getDataInt(aux, "lastlogin") < os.time() - (days * 86400) then
                local house = House(result.getDataInt(resultId, "id"))
                    if house then
                        house:setOwnerGuid(-1)
                    end
            end
        end

    until not result.next(resultId)
    end
saveServer()

return true
end
 
OP
Hugofasima

Hugofasima

Website: thenosegang.servegame.com
Joined
Jun 24, 2015
Messages
206
Reaction score
22
The only change I made was to check to make sure there was a house. This way at least won't throw an error message. ( I hope :p )
Code:
local days = 20 -- days to lose the house

function onStartup()
local resultId = db.storeQuery("SELECT `owner`,`id` FROM `houses`;")

    if resultId then
    repeat
    local aux = db.storeQuery("SELECT `lastlogin` FROM `players` WHERE `id` = " .. result.getDataString(resultId, "owner") .. ";")

        if aux then
            if result.getDataInt(aux, "lastlogin") < os.time() - (days * 86400) then
                local house = House(result.getDataInt(resultId, "id"))
                    if house then
                        house:setOwnerGuid(-1)
                    end
            end
        end

    until not result.next(resultId)
    end
saveServer()

return true
end
And you're right !!!

100% SOLVED! THANK YOU!!!
 
Top