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

I need !report command on server..

Sir Shutter

Learning LUA
Joined
Nov 17, 2008
Messages
1,437
Reaction score
10
Location
Egypt
Hey.. i want the script for !report command when they say !report and type something here

it gets sent to report.txt file in my server logs i suppose

can someone help me how to do that? just tell me what to add to talkactions.xml and the script

I give rep++

thanks!! :thumbup:
 
1. Create data/logs/server/reports.txt
2. Create data/talkactions/scripts/report.lua and insert into it:
PHP:
local saveFile = {folder = getDataDir() .. "logs/server/", filename = "reports.txt", saveLog = true, linesMax = 2000}

function fileExists(filename)
    file = io.open(filename, "r")
    return (file == nil and FALSE) or (file:close() and TRUE)
end

function onSay(cid, words, param)
local file = saveFile.folder .. saveFile.filename
	if fileExists (file) == FALSE then
		return print(">> Report Function Error :: ".. file .." does not exist") and FALSE
	end
	if tostring(param) == "" then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Please type message with a issue!") and TRUE
	end
	if (saveFile.saveLog == true) then
		local lines = 0
		for _ in io.lines(file) do
			lines = lines + 1
		end
		local file = io.open(saveFile.folder .. saveFile.filename, (lines < saveFile.linesMax-1 and "a") or "w")
		file:write("[".. os.date("%Y-%m-%d %H:%M:%S") .."] ".. getCreatureName(cid) ..": ".. param .."\n")
		file:close()
	end
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Thanks for the report!")
	return TRUE
end

3. Add to talkactions.xml:
PHP:
<talkaction words="!report" event="script" value="report.lua"/>
 
Back
Top