1268995
Member
- Joined
- Sep 9, 2010
- Messages
- 422
- Reaction score
- 13
Check out the bug:
Rep system in talkactions:
004-database.lua:
When i use the comand /installRep , in god, appear the error:
attempt to call field 'executeQuery' (a nil value).
Rep system in talkactions:
Code:
--[[
Name: Reputation Sytem
Author: Kimoszin
Version: v0.1
Site: www.phenomy.com.br
]]--
local config = {
groupInstall = 5, -- Grupo necessario para instalar o sistema
groupSetRep = 0, -- Grupo necessario para dar REP's
groupMyRep = 0, -- Grupo necessario para saber seus REP's
groupRemRep = 5, -- Grupo necessario para remover os REP's
maxPlayersList = 10, -- Número maximo que vai mostrar os players no rank
}
function onSay(cid, words, param, channel)
local str = string.explode(param, ",")
local player = str[1]
local Rep = str[2]
if words == "!helpRep" then
doShowTextDialog(cid, 1304, "!myRep -- Serve para você saber quanto de reputação tem.\n\n !setRep -- Serve para você doar reputação.\n\n !remRep -- Serve para você adicionar reputação em uma outra pessoa")
elseif words == "/installRep" then
if getPlayerGroupId(cid) >= config.groupInstall then
if db.executeQuery("ALTER TABLE `players` ADD rep INT(15) NOT NULL DEFAULT 0;") then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Parabéns, foi instalado o Reputation System em seu sevidor!.")
return true
end
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Não foi possivel instalar ou já está instalado o Reputation System em seu sevidor!.")
return true
else
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Desculpe, mais você não pode usar esse comando")
return true
end
elseif words == "!myRep" then
if getPlayerGroupId(cid) > config.groupMyRep then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Você possui "..getMyReputation(cid).." pontos de reputação.")
else
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Desculpe, mais você não pode usar esse comando")
return true
end
elseif words == "!setRep" then
if getPlayerGroupId(cid) > config.groupSetRep then
if(param == '') then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
return true
end
local pid = getPlayerByNameWildcard(player)
if (player ~= getCreatureName(cid) and Rep ~= nil) then
if (pid ~= nil) then
if (getMyReputation(cid) >= tonumber(Rep)) then
setReputation(getPlayerAccountId(pid), Rep)
removeReputation(getPlayerAccountId(cid), Rep)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Você acabou de dar "..Rep.." de reputação para o player "..player..".")
doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, "Você acaba de receber "..Rep.." pontos de reputação do player "..getCreatureName(cid)..".")
doSendAnimatedText(getCreaturePosition(pid), "+ "..Rep.." REP", 30)
else
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Você não possui reputação suficiente")
end
else
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "O player deve estar online!")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Ocorreu um erro.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Desculpe, mais você não pode usar esse comando")
return true
end
elseif words == "!remRep" then
if getPlayerGroupId(cid) > config.groupRemRep then
if(param == '') then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
return true
end
local pid = getPlayerByNameWildcard(player)
if (player ~= getCreatureName(cid) and Rep ~= nil) then
if (pid ~= nil) then
if (getMyReputation(cid) >= tonumber(Rep)) then
removeReputation(getPlayerAccountId(pid), Rep)
removeReputation(getPlayerAccountId(cid), Rep)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Você acabou de tirar "..Rep.." de reputação do player "..player..".")
doPlayerSendTextMessage(pid, 21, "Você acaba de perder "..Rep.." pontos de reputação, retirados por "..getCreatureName(cid)..".")
doSendAnimatedText(getCreaturePosition(pid), "- "..Rep.." REP", 180)
else
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Você não possui reputação suficiente")
end
else
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "O player deve estar online!")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Ocorreu um erro.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Desculpe, mais você não pode usar esse comando")
return true
end
elseif words == "!rankRep" then
local text = "*~ RANK REPUTATION SYSTEM *~\n"
local q = db.getResult("SELECT `rep`, `name` FROM `players` ORDER BY `rep` DESC;")
if (q:getID() ~= -1) then k = 1 repeat if k > config.maxPlayersList then break end
text = text .. "\n " .. k .. ". "..q:getDataString("name").." [" .. q:getDataInt("rep") .. "]"
k = k + 1 until not q:next() end
doShowTextDialog(cid, 2493, text)
end
end
004-database.lua:
Code:
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
When i use the comand /installRep , in god, appear the error:
attempt to call field 'executeQuery' (a nil value).