/reports will list all reports.
It works.
Same error here... :/[10/01/2009 18:52:10] Lua Script Error: [TalkAction Interface]
[10/01/2009 18:52:10] data/talkactions/scripts/reports.luanSay
[10/01/2009 18:52:10] data/talkactions/scripts/reports.lua:17: attempt to call field 'tonumber' (a nil value)
[10/01/2009 18:52:10] stack traceback:
[10/01/2009 18:52:10] data/talkactions/scripts/reports.lua:17: in function <data/talkactions/scripts/reports.lua:5>
CREATE TABLE `server_reports`
(
`id` INT NOT NULL AUTO_INCREMENT,
`world_id` TINYINT(2) UNSIGNED NOT NULL DEFAULT 0,
`player_id` INT UNSIGNED NOT NULL DEFAULT 0,
`posx` INT NOT NULL DEFAULT 0,
`posy` INT NOT NULL DEFAULT 0,
`posz` INT NOT NULL DEFAULT 0,
`timestamp` BIGINT NOT NULL DEFAULT 0,
`report` TEXT NOT NULL,
`reads` INT NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
KEY (`world_id`), KEY (`reads`)
) ENGINE = InnoDB;
[10/01/2009 20:54:32] Lua Script Error: [TalkAction Interface]
[10/01/2009 20:54:32] data/talkactions/scripts/reports.luanSay
[10/01/2009 20:54:32] data/talkactions/scripts/reports.lua:17: attempt to call field 'tonumber' (a nil value)
[10/01/2009 20:54:32] stack traceback:
[10/01/2009 20:54:32] data/talkactions/scripts/reports.lua:17: in function <data/talkactions/scripts/reports.lua:5>
local config = {
expireReportsAfterReads = getConfigInfo('expireReportsAfterReads')
}
function onSay(cid, words, param)
if(isNumber(param) == TRUE) then
local reportId = tonumber(param)
local report = db.getResult("SELECT * FROM `server_reports` WHERE `id` = " .. reportId)
if(report:getID() ~= -1) then
db.executeQuery("UPDATE `server_reports` SET `reads` = `reads` + 1 WHERE `id` = " .. reportId)
doPlayerPopupFYI(cid, "Report no. " .. reportId .. "\n\nName: " .. getPlayerNameByGUID(report:getDataInt("player_id")) .. "\nPosition: [X: " .. report:getDataInt("posx") .. " | Y: " .. report:getDataInt("posy") .. " | Z: " .. report:getDataInt("posz") .. "]\nDate: " .. os.date("%c", report:getDataInt("timestamp")) .. "\nReport:\n" .. report:getDataString("report"))
report:free()
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Report with no. " .. reportId .. " does not exists.")
end
else
local list = db.getResult("SELECT `id`, `player_id` FROM `server_reports` WHERE `reads` < " .. config.tonumber(param))
if(list:getID() ~= -1) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "New reports:")
while(true) do
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, list:getDataInt("id") .. ", by " .. getPlayerNameByGUID(list:getDataInt("player_id")) .. ".")
if not(list:next()) then
break
end
end
list:free()
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "There are no active reports.")
end
end
return TRUE
end
DROP TABLE `server_reports`;
CREATE TABLE `server_reports`
(
`id` INT NOT NULL AUTO_INCREMENT,
`world_id` TINYINT(2) UNSIGNED NOT NULL DEFAULT 0,
`player_id` INT UNSIGNED NOT NULL DEFAULT 0,
`posx` INT NOT NULL DEFAULT 0,
`posy` INT NOT NULL DEFAULT 0,
`posz` INT NOT NULL DEFAULT 0,
`timestamp` BIGINT NOT NULL DEFAULT 0,
`report` TEXT NOT NULL,
`reads` INT NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
KEY (`world_id`), KEY (`reads`)
) ENGINE = InnoDB;
local config = {
reportReadsToExpire = 1
}
function onSay(cid, words, param)
if(isNumber(param) == TRUE) then
local reportId = tonumber(param)
local report = db.getResult("SELECT * FROM `server_reports` WHERE `id` = " .. reportId)
if(report:getID() ~= -1) then
db.executeQuery("UPDATE `server_reports` SET `reads` = `reads` + 1 WHERE `id` = " .. reportId)
doPlayerPopupFYI(cid, "Report # " .. reportId .. "\n\nName: " .. getPlayerNameByGUID(report:getDataInt("player_id")) .. "\nPosition: [X: " .. report:getDataInt("posx") .. " | Y: " .. report:getDataInt("posy") .. " | Z: " .. report:getDataInt("posz") .. "]\nDate: " .. os.date("%c", report:getDataInt("timestamp")) .. "\nReport:\n" .. report:getDataString("report"))
report:free()
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Report with ID: " .. reportId .. " does not exists.")
end
else
local list = db.getResult("SELECT `id`, `player_id` FROM `server_reports` WHERE `reads` < " .. config.reportReadsToExpire)
if(list:getID() ~= -1) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "New reports:")
while(true) do
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "# " .. list:getDataInt("id") .. ", by " .. getPlayerNameByGUID(list:getDataInt("player_id")) .. ".")
if not(list:next()) then
break
end
end
list:free()
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "There are no active reports.")
end
end
return TRUE
end