• 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 Script help 1.2

gubbo123

New Member
Joined
Aug 15, 2017
Messages
151
Solutions
1
Reaction score
3
Lua:
    local resultId = db.storeQuery("SELECT `id`, `owner` FROM `houses` WHERE NOT `owner` = 0 AND (SELECT `premdays` FROM `accounts` WHERE (SELECT `account_id` FROM `players` WHERE `id` = `owner`) = `id`) = 0")
    if resultId ~= false then
        repeat
            local house = House(result.getDataInt(resultId, "id"))
            if house then
                house:setOwnerGuid(0)
            end
        until not result.next(resultId)
        result.free(resultId)
    end

I need to make a script like this, but instead of checking if the player is premium or not, to use the house:setOwnerGuid(0) function, the script I need needs to check if the player is deleted 1 in the players column, if he has 1 in the deleted column, will change his house to house:setOwnerGuid(0)
 
Solution
Now you will only find the houses that have owners that do not exist

Lua:
local resultId = db.storeQuery("SELECT `id`, `owner` FROM `houses` WHERE `owner` != 0 AND NOT (EXISTS (SELECT `id` FROM players WHERE `id` = `owner`))")
if resultId then
    repeat
        local house = House(result.getDataInt(resultId, "id"))
        if house then
            house:setOwnerGuid(0)
        end
    until not result.next(resultId)
    result.free(resultId)
end
Now you will only find the houses that have owners that do not exist

Lua:
local resultId = db.storeQuery("SELECT `id`, `owner` FROM `houses` WHERE `owner` != 0 AND NOT (EXISTS (SELECT `id` FROM players WHERE `id` = `owner`))")
if resultId then
    repeat
        local house = House(result.getDataInt(resultId, "id"))
        if house then
            house:setOwnerGuid(0)
        end
    until not result.next(resultId)
    result.free(resultId)
end
 
Solution
Back
Top