• 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 /reports command

Dekon

Zerenia.net Owner
Joined
Feb 4, 2008
Messages
235
Reaction score
3
Location
Sweden
Anyone know why the cmd /reports doesnt work on tfs 0.3 beta 2 ?
i cant read the reports that are sent
if anyone know please leave a msg
/Danne
 
The bug reports, or rule violation reports?
In my TFS 0.2.22, I can see rule violation reports at the "Rule Violation" channel.
 
18:52 /reports
18:52 GOD Elwahear: /reports


[10/01/2009 18:52:10] Lua Script Error: [TalkAction Interface]
[10/01/2009 18:52:10] data/talkactions/scripts/reports.lua:eek:nSay

[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>
Same error here... :/
(TFS 0.3b2)
 
Aaaaaaaaaaaaaaaaaaa...
I know what's up !
When you update to new database schema, TFS won't add table server_reports !

Execute this code in phpmyadmin:
PHP:
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;
Say goodbye to all errors, and maybe give me some reput ?
 
There's already a 'server_reports' table in my database... But i created it again and nothing... same error again.

[10/01/2009 20:54:32] Lua Script Error: [TalkAction Interface]
[10/01/2009 20:54:32] data/talkactions/scripts/reports.lua:eek:nSay

[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>

The reports.lua:
Code:
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

The 17th line:
local list = db.getResult("SELECT `id`, `player_id` FROM `server_reports` WHERE `reads` < " .. config.tonumber(param))
 
I executed:

PHP:
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;
 
Btw... I'm trying to say '/reports', not '/reports 1' or '/reports 2'...

I think ther's something wrong with 'param', maybe this line:
if (isNumber(param) == TRUE) then

It's always true... with or without param.
 
My working script:
PHP:
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
 
haha

they only thing i cant do is someone said u can say /Reports and list all reports doesnt work i can say /reports 1
and it works bit not list em
/Danne
thx Don anyway
 
Back
Top