• 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!

TalkAction bug report in game using command !bug text

Seminari

Banned User
Joined
Dec 13, 2009
Messages
1,496
Reaction score
34
Location
Poland
You must add to config.lua
avivable_reports_per_day = 120
where_going_reports = "db.executeQuery"

You can choose saving to database or to file bug.txt adding to config.lua


if you set in config.lua where_going_reports = "log" then reports will be saving in bug.txt (file will be create in your logs folder)
but, if you want to saving reports to database paste where_going_reports = "db.Query" or where_going_reports = "db.executeQuery", be sure which function do u have.


talkactions.xml:

Code:
<talkaction words="!bug" event="script" value="bug.lua"/>
go to talkactions and create bug.lua and paste:


Code:
      -- Bug Report to txt or database  --
      -- ~~~~~~~~ By Seminari ~~~~~~ --
      --          //// | \\\\        --
      --         / __     __ \       --
      --         |[*]  |  [*]|       --
      --         |     ^     |       --
      --          \ \_____/ /        --
      --           --\___/--         --
      --           \______/          --
      -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ --
	  -- Skrypt dziala w sposob nastepujacy:

	  --[[
	  PL version:
	  player_name wypowiada komende !bug text
	  text jest dodawany na sam konoc pliku bug.txt (tzn ostatnia linijka)
	  what_date_is_today to jest data   
	  ogolem report wyglada mnojwiecej tak:
	  Wed Aug 31 16:17:30 2011 [Semi]: Cos no dziala w depocie
	  Jest tez opcja czy ma dopisywac pozycje, w configu wpisujemy "no" lub kazda dowolna inna
	  
	  
	  
	  ENG version:
	  Player say !bug text
	  example report:
	  Wed Aug 31 16:19:24 2011 [Semi]: Something doesn't work in depo
	  if check_positions ~= "no" then report will be: 
	   Wed Aug 31 16:42:30 2011 [Semi] [X: 32957 | Y: 32076 | Z: 7] : bug in venore sasa fix that!
	  if you set in config.lua  where_going_reports = "log" then reports will be saving in bug.txt (file will be create in your logs folder)
	  but, if you want to saving reports to database paste   where_going_reports = "db.Query"  or where_going_reports = "db.executeQuery", be sure which function do u have.
	   
	   
	   
	   
	   
	Paste it to database:
	
		CREATE TABLE IF NOT EXISTS `bugs` (
		`id` smallint(5) unsigned NOT NULL auto_increment,
		`data` varchar(255) NOT NULL, 
		`player_name` varchar(255) NOT NULL, 
		`player_position` varchar(255) NOT NULL,
		`report_description` varchar(255) NOT NULL,
		`status` varchar(255) NOT NULL,
		`show_on_web` varchar(255) NOT NULL,
		PRIMARY KEY (`id`)
		)ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
		
	
	   
	   
	---------------------------------------------------->
	   How to configurate?
	   add to config.lua :
	   avivable_reports_per_day = 120  
	   where_going_reports = ""       -- paste here   log/db.Query/db.executeQuery        log = command will create file bug.txt in logs and adding reports 
	   	
	   

	  

	  ]]--



function onSay(cid, words, param, channel)

	if(param == '') then
		return true
	end

local c = {
name_of_database = getConfigInfo('sqlDatabase'),
check_positions = "yes",
max_reports_per_day = 5,
days_reports_storage = 7326,
every_reports_storage = 7329,
}


local DZIEN = "" .. c.days_reports_storage .. "" ..os.date("%d") .. "" .. os.date("%m") ..""

		if getPlayerStorageValue(cid, c.days_reports_storage) == -1 then
			setPlayerStorageValue(cid, c.days_reports_storage, 1)
		end
		if getPlayerStorageValue(cid, c.every_reports_storage) == -1 then
			setPlayerStorageValue(cid, c.every_reports_storage, 1)
		end

		
 local how_many_reports_send_today = getPlayerStorageValue(cid, c.days_reports_storage)
 local every_reports = getPlayerStorageValue(cid, c.every_reports_storage)
 local how_many_reports_can_player_send_per_day = getConfigInfo('avivable_reports_per_day') - how_many_reports_send_today

if how_many_reports_send_today < getConfigInfo('avivable_reports_per_day') then
		if c.check_positions ~= "no" then 
			pos = getPlayerPosition(cid)
			player_position = " [X: "..pos.x.." | Y: "..pos.y.." | Z: "..pos.z.."] "
		else
			player_position = "."
		end
			
		
		local what_date_is_today = os.date("%a %b %d %X %Y")
		if getConfigValue('where_going_reports') == "db.executeQuery" then
        db.executeQuery("INSERT INTO  `" .. c.name_of_database .."`.`bugs`(`data` ,`player_name` ,`player_position` ,`report_description`, `status`, `show_on_web`) VALUES ('" .. what_date_is_today .. "',  '" .. getPlayerName(cid) .. "',  '" .. player_position .. "',  '" .. param .. "', 'waiting', 'no');")    
		how_many_reports_send_todayM = how_many_reports_send_today + 1
		setPlayerStorageValue(cid, c.days_reports_storage, how_many_reports_send_today + 1)
		setPlayerStorageValue(cid, c.every_reports_storage, every_reports + 1)
		
		
		elseif getConfigValue('where_going_reports') == "db.query" then
        db.query("INSERT INTO  `" .. c.name_of_database .."`.`bugs`(`data` ,`player_name` ,`player_position` ,`report_description`, `status`, `show_on_web`) VALUES ('" .. what_date_is_today .. "',  '" .. getPlayerName(cid) .. "',  '" .. player_position .. "',  '" .. param .. "', 'waiting', 'no');")    
		how_many_reports_send_todayM = how_many_reports_send_today + 1
		setPlayerStorageValue(cid, c.days_reports_storage, how_many_reports_send_today + 1)
		setPlayerStorageValue(cid, c.every_reports_storage, every_reports + 1)

       

		elseif getConfigValue('where_going_reports') == "log" then
		f = assert(io.open("./data/logs/bug.txt", "a+"))
		f = io.open("./data/logs/bug.txt", "a+")
		f:write("\n " .. what_date_is_today .." [" .. getPlayerName(cid) .. "]" .. player_position .. ": " .. param .. "")
		f:close()
		
		how_many_reports_send_todayM = how_many_reports_send_today + 1
		setPlayerStorageValue(cid, c.days_reports_storage, how_many_reports_send_today + 1)
		setPlayerStorageValue(cid, c.every_reports_storage, every_reports + 1)
		
		
		end
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Your report has been sent to " .. getConfigValue('serverName') .. ". It's your " .. every_reports  .. ", and you can sent " .. how_many_reports_can_player_send_per_day .." reports this day.")
else
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You can't report more bugs this day")
end
	return true
end


go to your database and create:

Code:
CREATE TABLE IF NOT EXISTS `bugs` (
		`id` smallint(5) unsigned NOT NULL auto_increment,
		`data` varchar(255) NOT NULL, 
		`player_name` varchar(255) NOT NULL, 
		`player_position` varchar(255) NOT NULL,
		`report_description` varchar(255) NOT NULL,
		`status` varchar(255) NOT NULL,
		`show_on_web` varchar(255) NOT NULL,
		PRIMARY KEY (`id`)
		)ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;


Have fun.
 
Last edited:
Lua:
[23:32:47.887] [Error - TalkAction Interface]
[23:32:47.887] data/talkactions/scripts/b.lua:onSay
[23:32:47.887] Description:
[23:32:47.887] data/talkactions/scripts/b.lua:28: attempt to perform arithmetic on a nil value
[23:32:47.887] stack traceback:
[23:32:47.887]  data/talkactions/scripts/b.lua:28: in function <data/talkactions/scripts/b.lua:1>

Lua:
28:  local how_many_reports_can_player_send_per_day = getConfigInfo('Bug_Report_Reporty_Dziennie') - how_many_reports_send_today

ocb?
 
Okey poprawione.

Okey, now i think will be good, you must create again bugs in database.
And add to config.lua

avivable_reports_per_day = 120
where_going_reports = "db.executeQuery"
 
Last edited:
Thx!

Tested, works fine on TFS 0.4 36xx

If you're using "log" in config.lua \/
where_going_reports = "log"

Create file bug.txt in logs and give permission 7777 because for some reason for me the lua script couldn't create bug.txt file :p
But it works good anyhow!
 
Thanks.. This script work perfect!... Remember change CHMOD "logs" folder to 777 if We have error.
 
Back
Top