• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Error: [Result:getDataInt] Result not set! (in rep system)

1268995

Member
Joined
Sep 9, 2010
Messages
422
Reaction score
13
Got this error on console:

Code:
[11:20:12.380] [Error - MoveEvents Interface]
[11:20:12.380] data/movements/scripts/rep.lua:onStepIn
[11:20:12.380] Description:
[11:20:12.380] data/lib/004-database.lua:66: [Result:getDataInt] Result not set!
[11:20:12.380] stack traceback:
[11:20:12.380]  [C]: in function 'error'
[11:20:12.380]  data/lib/004-database.lua:66: in function <data/lib/004-database.lua:64>
[11:20:12.380]  (tail call): ?
[11:20:12.380]  (tail call): ?
[11:20:12.380]  data/movements/scripts/rep.lua:2: in function <data/movements/scripts/rep.lua:1>

004-database.lua:

Code:
db.updateQueryLimitOperator = db.updateLimiter
db.stringComparisonOperator = db.stringComparer
db.stringComparison = db.stringComparer
db.executeQuery = db.query
db.quote = db.escapeString

if(result == nil) then
    print("> WARNING: Couldn't load database lib.")
    return
end

Result = createClass(nil)
Result:setAttributes({
    id = -1,
    query = ""
})

function Result:getID()
    return self.id
end

function Result:setID(_id)
    self.id = _id
end

function Result:getQuery()
    return self.query
end

function Result:setQuery(_query)
    self.query = _query
end

function Result:create(_query)
    self:setQuery(_query)
    local _id = db.storeQuery(self:getQuery())
    if(_id) then
        self:setID(_id)
    end

    return self:getID()
end

function Result:getRows(free)
    local free = free or false
    if(self:getID() == -1) then
        error("[Result:getRows] Result not set!")
    end

    local c = 0
    repeat
        c = c + 1
    until not self:next()

    local _query = self:getQuery()
    self:free()
    if(not free) then
        self:create(_query)
    end

    return c
end

function Result:getDataInt(s)
    if(self:getID() == -1) then
        error("[Result:getDataInt] Result not set!")
    end

    return result.getDataInt(self:getID(), s)
end

function Result:getDataLong(s)
    if(self:getID() == -1) then
        error("[Result:getDataLong] Result not set!")
    end

    return result.getDataLong(self:getID(), s)
end

function Result:getDataString(s)
    if(self:getID() == -1) then
        error("[Result:getDataString] Result not set!")
    end

    return result.getDataString(self:getID(), s)
end

function Result:getDataStream(s)
    if(self:getID() == -1) then
        error("[Result:getDataStream] Result not set!")
    end

    return result.getDataStream(self:getID(), s)
end

function Result:next()
    if(self:getID() == -1) then
        error("[Result:next] Result not set!")
    end

    return result.next(self:getID())
end

function Result:free()
    if(self:getID() == -1) then
        error("[Result:free] Result not set!")
    end

    self:setQuery("")
    local ret = result.free(self:getID())
    self:setID(-1)
    return ret
end

Result.numRows = Result.getRows
function db.getResult(query)
    if(type(query) ~= 'string') then
        return nil
    end

    local ret = Result:new()
    ret:create(query)
    return ret
end

rep.lua

Code:
function onStepIn(cid, item, position, fromPosition)
        if getMyReputation(cid) <= 0 then
               doTeleportThing(cid, fromPosition, false)
               doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
               doPlayerSendTextMessage(cid, 22, "Desculpe, mais você precisa de reputação para passar.Diga !helpRep e Ganhe Bonus e Promotion")
        end
        return TRUE
end
 
post the lib, script or the function that defines getMyReputation

Code:
--[[
Name: Reputation Sytem
Author: Kimoszin
Version: v0.1
Site: www.phenomy.com.br
]]--
function setReputation(id, point)
        local reps = db.getResult("SELECT `rep` FROM `players` WHERE `id` = "..id..";")
        local p = reps:getDataInt("rep") + point
        if db.query("UPDATE `players` SET `rep` = "..p.." WHERE `id` = "..id..";") then
        return TRUE
    end
        return FALSE
end
function removeReputation(id, point)
        local reps = db.getResult("SELECT `rep` FROM `players` WHERE `id` = "..id..";")
        local p = reps:getDataInt("rep") - point
        if db.query("UPDATE `players` SET `rep` = "..p.." WHERE `id` = "..id..";") then
        return TRUE
    end
        return FALSE
end
function getMyReputation(cid)
        return getReputation(getPlayerAccountId(cid))
end
function getReputation(id)
        local reps = db.getResult("SELECT `rep` FROM `players` WHERE `id` = "..id..";")
        return reps:getDataInt("rep")
end
 
Spontaneously it looks a bit weird that you attempt to get id from players, where id is an account id.

Try to change the first like in the getMyReputation function:
Code:
return getReputation(getPlayerAccountId(cid))

... and change it to:
Code:
return getReputation(getPlayerId(cid))

(Presuming there is a getPlayerId function)

Ignazio
 
Spontaneously it looks a bit weird that you attempt to get id from players, where id is an account id.

Try to change the first like in the getMyReputation function:
Code:
return getReputation(getPlayerAccountId(cid))

... and change it to:
Code:
return getReputation(getPlayerId(cid))

(Presuming there is a getPlayerId function)

Ignazio
To get the player id you can use: getPlayerGUID(cid)

Make sure you have to column rep aswell.
Code:
ALTER TABLE `players` ADD `rep` INT NOT NULL DEFAULT 0;

https://otland.net/threads/mysql-how-to-run-a-query.177833/

Where should i put the (getPlayerAccountId(cid)) or getPlayerGUID(cid) ?
 
Back
Top