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