• 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 openfile .txt

The beginning is like thist:
I made a .txt file called "words.txt" in the server folder.
Next I used this script to get the lines:
LUA:
local file = "words.txt"
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
for line in io.lines(file) do 
	print(line) 
end
return true
end
taken from: lua wiki

Content of my file "words.txt":
fk85ya.jpg


Server console (I'm not cheating, this works :P )
2dufhgz.jpg


I didn't know myself that this would be possible xD

EDIT:

Aight, I got it.
It needs a lil formating but it works.
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local file = "words.txt"
local str = "Reports made:\n"
local line = 0
for line in io.lines(file) do 
	str = str..""..line.."\n"
end
doPlayerPopupFYI(cid, str)
str = ""
return true
end

proof:
1zq31pw.jpg


Replace this line within your "bug report" script:
LUA:
f:write(""..getPlayerName(cid).." reported a bug at " .. os.date("%d %B %Y - %X.", os.time()) .."\n"..param.." \n[x="..getPlayerPosition(cid).x..", y="..getPlayerPosition(cid).y..", z="..getPlayerPosition(cid).z.."].\n--------------------\n")
This will help to keep a better format at writing the report.

Then use my script above to get it via POPUP.

Hope it helps :P
 
Last edited:
Hmm, it has to be possible, but the downside is... this would require some time to be made.
Let me get this straight:
You want to not only open and read the "bugreport.txt" file, you also want to edit parts like, "Druid" has reported a bug, GM looks into it and erases the bug from the txt file if solved.
In short:
talkaction to few the bugs reported, edit/delete reports, overwrite the edited file.

Did I get this correctly?
 
People use this script to report
LUA:
function onSay(cid, words, param, channel)
local storage = 6707
local delaytime = 120
local a = "data/logs/bugs.txt"
local f = io.open(a, "a+")
	if(param == '') then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
		return true
	end
local exhaust = exhaustion.get(cid, storage)
	if(not exhaust) then
		exhaustion.set(cid, storage, delaytime)
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Please wait patiently for a gamemaster to reply.")
		f:write(""..getPlayerName(cid).." reported a bug at " .. os.date("%d %B %Y - %X.", os.time()) .."\n"..param.." \n[x="..getPlayerPosition(cid).x..", y="..getPlayerPosition(cid).y..", z="..getPlayerPosition(cid).z.."].\n--------------------\n")
		f:close()
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You must wait " .. exhaustion.get(cid, storage) .. " seconds to report again.")
	end
return TRUE
end

And I will see reports with this script
After I solve the bug, I will delete that report only
LUA:
function onSay(cid, words, param, channel)
local file = "data/logs/bugs.txt"
local str = "Reports made:\n"
local line = 0
for line in io.lines(file) do 
	str = str..""..line.."\n"
end
doPlayerPopupFYI(cid, str)
str = ""
return true
end
 
Back
Top