• 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 Working /report talkaction. [0.3+]

Guitar Freak

_LüA_n☺b_
Joined
Dec 27, 2008
Messages
831
Reaction score
13
Location
Caracas, Venezuela
First of all, credits to Shawak for the base script, to Colandus for his broadcast script (which I mixed and used as a reference for most stuff on this one) and myself for the minor modifications.

Second, it was tested and its working in 0.3+, including 0.3.5.

This talkaction will allow players to report bugs or w/e in-game and these reports will be sent to your /data/logs folder and will be written in a file called Reports.txt, which will be automatically updated every new report made.

They show the date sent, and the name, level and vocation of the sender. But you can change that by just removing some lines.

Well here it is.

First, go to folder data > lib and open function.lua and add this at the beginning:

Lua:
function setExhaust(cid, storage)
    setPlayerStorageValue(cid, storage, os.time())
end

function isExhausted(cid, storage, exhaust)
    local exhaustTime = getPlayerStorageValue(cid, storage)
    if exhaustTime == -1 then
        return FALSE
    end
    local isExhausted = os.time() - exhaustTime < exhaust
    return isExhausted and TRUE or FALSE
end

Now in talkactions.xml:

PHP:
	<talkaction log="no" words="/report" filter="quotation" event="script" value="textreports.lua"/>

In textreports.lua:

Lua:
	-- Credits --
	-- References: Shawak & Colandus.
	-- Modifications: Guitar Freak.
	
	local level = 8				-- Minimum level to send a report.
	local minimum = 3 			-- Minimum characters per report.
	local maximum = 85			-- Maximum characters per report.

	local useExhaust = true		-- True if you want to use exhaustion, false if not.
	local storageValue = 8000	-- Needed for exhaustion to work. Set to any unused value you wish.
	local exhaustTime = 15		-- Exhaust time between each report (15 = 15 seconds).
	
	local getVoc = getPlayerVocationName(cid)
	local position = getCreaturePosition(cid)

function onSay(cid, words, param, channel)

	if getPlayerLevel(cid) < level then
			doPlayerSendTextMessage(cid,20,"Report Manager:")
			doPlayerSendTextMessage(cid,18,"You need to be at least level "..level.." to send a report.")

		elseif (useExhaust and isExhausted(cid, storageValue, exhaustTime) == TRUE) then
			doPlayerSendTextMessage(cid,20,"Report Manager:")
			doPlayerSendTextMessage(cid,18,"Sorry, you need to wait "..exhaustTime.." seconds before sending another report.")

		elseif param:len() < minimum then
			doPlayerSendTextMessage(cid,20,"Report Manager:")
			doPlayerSendTextMessage(cid,18,"Sorry, you need to enter atleast " .. minimum .. " characters to send in a report.")

		elseif param:len() > maximum then
			doPlayerSendTextMessage(cid,20,"Report Manager:")
			doPlayerSendTextMessage(cid,18,"Sorry, you can only write max. " .. maximum .. " characters per report.")

		else
			Log = io.open(getDataDir().."logs/Reports.txt", "a+")
			Log:write("Sent: "..os.date("%A %I:%M:%S %p.").."\n")
			Log:write("From position: X = "..position.x.." | Y = "..position.y.." | Z = "..position.z.."\n")
			Log:write(""..getPlayerName(cid).." ["..getPlayerLevel(cid).."] ("..getVoc.."): "..param.."\n\n")
			Log:close()
				doPlayerSendTextMessage(cid,20,"Report Manager:")
				doPlayerSendTextMessage(cid,27,"You have successfully sent your report. Thanks for your support.")
				setExhaust(cid, storageValue)
		end
		return TRUE
end

If you didnt understand what it does, here is an example:

Player1 says:
03:27 Player1 [30]: /report "Hi there is a map bug in temple, please fix..

After doing so, this message will appear to him in his log:
03:27 Report Manager:
03:27 You have successfully sent your report. Thanks for your support.

And in the file Reports.txt (go to your folder data, then logs) you will see this:

Sent: Saturday 03:27:10 PM.
From position: X = 158 | Y = 51 | Z = 7
Player1 [30] (Knight): Hi there is a map bug in temple, please fix..

And every new report will appear there in the same format, 2 lines below the previous one, and so on.

Btw, if you want it to be /report Text, instead of /report "Text, just remove this:

Code:
filter="quotation"

From the line in talkactions.xml and it will work the same but without the ". Also, if you'd like them in .lua format instead of .txt, just change it on the script normally and will also work.

For an alternative and more complex version of this script for 0.3.5, check this one:
Version for 0.3.5 - Full credits to Shawak! :thumbup:

Enjoy.

PS: Notice that I use this script from before 0.3.5 appeared, so I dont know if 0.3.5 now has an easier way to do this.
 
Last edited:
OMG I RELEASED THIS SCRIPT, TOOOO :(:(:(:(

All Steals my script ideas ??????? :mad::mad::mad:

It's like JDB's Anni Chest Script :mad:

PS: Ofcourse good work and rep++.
 
OMG I RELEASED THIS SCRIPT, TOOOO :(:(:(:(

All Steals my script ideas ??????? :mad::mad::mad:

It's like JDB's Anni Chest Script :mad:

PS: Ofcourse good work and rep++.

That was sarcastic? lol.. if not, read the first paragraph of my post mate..

First of all, credits to Shawak for the base script, to Colandus for his broadcast script (which I mixed and used as a reference for most stuff on this one) and myself for the minor modifications.

I refered you in the credits because you gave me the base script a while ago :) If you already had it posted on a thread then sorry, I looked up before posting but didnt see any thats why I posted it.

Thanks for repping :)
 
I know, but I finished a release to and was going to post it, but now i see yours <_<.
 
I know, but I finished a release to and was going to post it, but now i see yours <_<.

Oh.. xD

Well you can post a working one for 0.3.5 since Im testing it now there and it doesnt work. Or post it here in a post and Ill refer to your post from the first post for those people that want it for 0.3.5, with the respective credit of course ;)

Edit: Works now for 0.3.5 but still referenced you.
 
Last edited:
For TFS 0.3.5, tested.

data/talkactions/talkactions.xml
HTML:
	<talkaction words="!report" event="script" value="sendReport.lua"/>
data/talkactions/scripts/sendReport.lua
Lua:
function onSay(cid, words, param, channel)
	if getPlayerStorageValue(cid, getConfigValue("reportStorage")) == -1 or os.time() >= (getPlayerStorageValue(cid, getConfigValue("reportStorage")) + getConfigValue("reportExhausted")) then
		local pos = getCreaturePosition(cid)
		doPlayerSendTextMessage(cid, 18, "Report have been send.")
		setPlayerStorageValue(cid, getConfigValue("reportStorage"), os.time())
		return db.executeQuery("INSERT INTO `server_reports` ( `id` , `world_id` , `player_id` , `posx` , `posy` , `posz` , `timestamp` , `report` ) VALUES (NULL , "..getConfigValue("worldId")..", "..getPlayerGUID(cid)..", "..pos.x..", "..pos.y..", "..pos.z..", "..os.time()..", '"..param.."');") and TRUE
	else
		local dif = os.time() - getPlayerStorageValue(cid, getConfigValue("reportStorage"))
		local left = getConfigValue("reportExhausted") - dif
		local h, m, s = 0, 0, 0
		while left >= 3600 do
			left = left - 3600
			h = h + 1
		end
		while left >= 60 do
			left = left - 60
			m = m + 1
		end
		while left >= 1 do
			left = left - 1
			s = s+1
		end
		doPlayerSendTextMessage(cid, 18, "You have to wait "..h.." hourers, "..m.." minutes and "..s.." seconds before reporting again.") and FALSE
	end
	return TRUE
end

Add in config.lua:
Lua:
	reportExhausted = 1 * 60 * 60   -- exhaustet in seconds (default = 1 * 60 * 60)

Now you can easy use /reports with a CM.
I hope it's useful :thumbup:.

Regards,
Shawak
 
Thanks :) I found out why it wasnt working for 0.3.5 and posted it aswell but referenced to yours too as an alternative/more complex version ;)

Mine looks n00b now lol xD
 
Nice release Guitar & Shawak. :thumbup:
 
Why you're adding exhaustion functions? There's already exhaustion library in ./data/lib/exhaustion.lua
 
Why you're adding exhaustion functions? There's already exhaustion library in ./data/lib/exhaustion.lua

True but I dont know how to work with those, Im just using Colandus's one which works aswell :p

But if you can optimize the script with that feel free to, Im always in the mood to learn more :thumbup:
 
thank you thank you!! work perfectly I really needed this.
I have recently found some bugs in server and Its really hard and time consuming to answer every PM. Now I can just go check the log :)
 
well, just as idea(like i done this in my servers), why not to write characters position to .txt too? it will be much easier to find where are map bugs reported ;)
 
well, just as idea(like i done this in my servers), why not to write characters position to .txt too? it will be much easier to find where are map bugs reported ;)

omg yes, sometimes its hard for people to explain exact location of bug..that would be insane.
 
well, just as idea(like i done this in my servers), why not to write characters position to .txt too? it will be much easier to find where are map bugs reported ;)

omg yes, sometimes its hard for people to explain exact location of bug..that would be insane.

That would indeed be great :) People /report and say bug and where he said it reports his position.

So he should only report bugs at the bug.. :p
 
well, just as idea(like i done this in my servers), why not to write characters position to .txt too? it will be much easier to find where are map bugs reported ;)

Great idea Fare, Ill get to it when I get home in a few hours.

Everyone else thanks! Glad it helped you :)
 
Last edited:
Character's position has been added to the script, replace old script with the one on the main post.

If anyone has more ideas that can be implemented to the script, feel free to share them! :thumbup:
 
Back
Top