original post https://otland.net/threads/a-better-way-to-report-bugs.147048/#post-2378435
Credits @president vankk
i made some changes to work "perfectly"
but when reporting does not update the log, i need to do a new report and /reload talkaction
is there any solution?
Credits @president vankk
i made some changes to work "perfectly"
but when reporting does not update the log, i need to do a new report and /reload talkaction
is there any solution?
Code:
local config = {
storage = 6707,
cooldown = 120,
file = "data/logs/bugs.txt"
}
function onSay(player, words, param)
local file = io.open(config.file, "a")
if not file then
print(string.format("Warning: Could not open %s", config.file))
return true
end
local split = param:split(",")
local action = split[1]
if (action == nil) then
return true
end
if player:getStorageValue(config.storage) >= os.time() then
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, string.format('You must wait %d seconds to use this command again', config.cooldown))
return false
end
local position = player:getPosition()
io.output(file)
io.write(os.date(), " Player:" .. player:getName() .. " reported a bug at " .. position.x .. " ,".. position.y .. " ,".. position.z .. " with description: " .. param .. "\n\n----------------------------------------------------------\n")
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Your report has been sent to " .. configManager.getString(configKeys.SERVER_NAME) .. '!')
player:setStorageValue(config.storage, os.time() + config.cooldown)
player:sendCancelMessage("Your report has been received successfully!")
return false
end