Is it posible to create text editor script?
I am using texter script so if I write ! it shows that text file in pm.
Is it posipble to change it with script?
If I write !edit it change text file and save it.
If I write !delete script deletes text file.
If I write !create script create text file.
And those text files should be edited or created in folder text\
If you can help me, please do it.
P.S. Sorry about my english!
:)
Is it posible that only masters can do it?
here is some code that can do almost half of what you request, you just need to edit it to your needs
-- save string
function DataArrival(curUser,data)
if strsub(data,1,1) == "<" then
local _,_,cmd,filename = strfind(data,"^%b<>%s+(%S+)%s+(%a+)")
if cmd == "+save" then
local _,_,sdata = strfind(data,"^%b<>%s+%S+%s+%a+%s+(.*)|$")
if sdata then
SaveFile(filename,sdata)
curUser:SendData("Saved to: "..filename)
end
elseif cmd == "+load" then
local sdata = LoadFile(filename)
curUser:SendData(filename,sdata)
end
end
end
function SaveFile(filename,sdata)
local handle = openfile(filename,"w")
write(handle,sdata)
closefile(handle)
end
function LoadFile(filename)
local handle = openfile(filename,"r")
local line,sdata = read(handle),""
while line do
sdata = sdata..line.."\n"
line = read(handle)
end
return sdata
end
But how can I write it in text folder?
QuoteOriginally posted by Janhouse
But how can I write it in text folder?
done.
+save filename text
e.g. +save txt/textfile.txt text
+load filename
+del filename
also corrected a mistake in the previous code
-- save string
aprof = 0 -- for only masters
function DataArrival(curUser,data)
if (strsub(data,1,1) == "<") and (curUser.iProfile == aprof) then
local _,_,cmd,filename = strfind(data,"^%b<>%s+(%S+)%s+([^|^ ]+)")
if cmd == "+save" then
local _,_,sdata = strfind(data,"^%b<>%s+%S+%s+%S+%s+(.*)|$")
if sdata then
SaveFile(filename,sdata)
curUser:SendData("Saved to: "..filename)
end
elseif cmd == "+load" then
local sdata = LoadFile(filename)
curUser:SendData(filename,sdata)
elseif cmd == "+del" then
DelFile(filename)
curUser:SendData("Deleted: "..filename)
end
end
end
function SaveFile(filename,sdata)
local handle = openfile(filename,"w")
write(handle,sdata)
closefile(handle)
end
function LoadFile(filename)
local handle = openfile(filename,"r")
local sdata = ""
if handle then
sdata = read(handle,"*a")
closefile(handle)
end
return sdata
end
function DelFile(filename)
remove(filename)
end
Thanx! It works fine and I can load and edit scripts too with that script. :D
It works fine, but when I load file it opens in main chat and like this:
! !tophubbers - paraada onlaineru topu ! ! ??! !topkickers - paraada izmeteeju topu ! ! ??! !topchatter - paraada catotaju topu ! ! ??! !topbanner - paraada banneru topu ! ! ??! ! ! ??! PannaBot eedaaja komandas: ! ! ??! !est.cepums - iedod vistas stilbinu ! ! ??! !est.gulet - iemidzina edaju ! ! ??!
But it should be shown like this:
! !ungag - lauj lietotajam atkal catot galvenaja cata ! !
! !restart - restarte hubu ! !
! !restartscripts - restarte huba skriptus ! !
! !reloadtxt - parlade teksta failus ! !
! !addreguser - pieregistre lietotaju ar noteikto profilu ! !
! !delreguser - iznem registretu lietotaju no registreto lietotaju saraksta ! !
! !stat - parada huba statistiku ! !
! !topic - uzstada jaunu virsrakstu ! !
! !topic off - nonem virsrakstu ! !
! !ipinfo - parada on/offline lietotajus ar doto IP adresi ! !
! !iprangeinfo - parada on/offline lietotajus ar doto iprange ! !
! !userinfo - parada visus lietotaja apmeklejuma laikus ! !
Can you fix this and make that it shows it in PM?
And can you add one option? If you type !showdir \ script shows all files and folders in scripts directory in PM. And if I write !showdir \text script shows all files in subdirectory in my PM.
Thanx before... :D
QuoteOriginally posted by Janhouse
It works fine, but when I load file it opens in main chat and like this:
! !tophubbers - paraada onlaineru topu ! ! ??! !topkickers - paraada izmeteeju topu ! ! ??! !topchatter - paraada catotaju topu ! ! ??! !topbanner - paraada banneru topu ! ! ??! ! ! ??! PannaBot eedaaja komandas: ! ! ??! !est.cepums - iedod vistas stilbinu ! ! ??! !est.gulet - iemidzina edaju ! ! ??!
But it should be shown like this:
! !ungag - lauj lietotajam atkal catot galvenaja cata ! !
! !restart - restarte hubu ! !
! !restartscripts - restarte huba skriptus ! !
! !reloadtxt - parlade teksta failus ! !
! !addreguser - pieregistre lietotaju ar noteikto profilu ! !
! !delreguser - iznem registretu lietotaju no registreto lietotaju saraksta ! !
! !stat - parada huba statistiku ! !
! !topic - uzstada jaunu virsrakstu ! !
! !topic off - nonem virsrakstu ! !
! !ipinfo - parada on/offline lietotajus ar doto IP adresi ! !
! !iprangeinfo - parada on/offline lietotajus ar doto iprange ! !
! !userinfo - parada visus lietotaja apmeklejuma laikus ! !
Can you fix this and make that it shows it in PM?
And can you add one option? If you type !showdir \ script shows all files and folders in scripts directory in PM. And if I write !showdir \text script shows all files in subdirectory in my PM.
Thanx before... :D
hehe, I think you tried with curUser.SendPM, but couldn't get it, but its simple, all you need is to
gsub "\n" with "\r\n" then it works as in the following code.
So now you can also list dir simply type
+list / or dir, or
+list txt list the txt folder
and it comes in PM
-- save string
-- by chill
aprof = 0 -- for only masters
function DataArrival(curUser,data)
if (strsub(data,1,1) == "<") and (curUser.iProfile == aprof) then
local _,_,cmd,fileordir = strfind(data,"^%b<>%s+(%S+)%s+([^|^ ]+)")
if cmd == "+save" then
local _,_,sdata = strfind(data,"^%b<>%s+%S+%s+%S+%s+(.*)|$")
if sdata then
SaveFile(fileordir,sdata)
SendPM(curUser,"Saved data to: "..fileordir)
end
return 1
elseif cmd == "+load" then
local sdata = LoadFile(fileordir)
SendPM(curUser,"File: "..fileordir..",\r\n"..sdata)
return 1
elseif cmd == "+del" then
DelFile(fileordir)
SendPM(curUser,"Deleted: "..fileordir)
return 1
elseif cmd == "+list" then
local dir = ListDir(fileordir)
SendPM(curUser,dir)
return 1
end
end
end
function SendPM(curUser,data)
curUser:SendPM(curUser.sName,data)
end
function SaveFile(filename,sdata)
local handle = openfile(filename,"w")
write(handle,sdata)
closefile(handle)
end
function LoadFile(filename)
local handle = openfile(filename,"r")
local sdata = ""
if handle then
sdata = read(handle,"*a")
sdata = gsub(sdata,"|",strchar(166))
sdata = gsub(sdata,"\n","\r\n")
closefile(handle)
end
return sdata
end
function DelFile(filename)
remove(filename)
end
function ListDir(dir)
if (dir == "/") or (dir == "dir") then
dir = ""
end
--execute("dir \""..dir.."\" /a-d /b > dirlist.txt")
--execute("dir \""..dir.."\" /b > dirlist.txt")
--execute("dir \""..dir.."\" /a-d > dirlist.txt")
execute("dir \""..dir.."\" > dirlist.txt")
local sdata = LoadFile("dirlist.txt")
DelFile("dirlist.txt")
return("\r\n"..sdata)
end
When I write !list txt it shows this:
<[Master]Janhouse>
Volume in drive D is LIELAIS
Volume Serial Number is 217B-07D3
Directory of D:\Documents and Settings\Arturs\Desktop\PtokaX\scripts
Bit it doesn't shows files or folders in it.
Can you fix it? ?(
And now that script doesn't work at all. It doesn't hawe errors, but it doesn't work. It can't load or save any files.
QuoteOriginally posted by Janhouse
And now that script doesn't work at all. It doesn't hawe errors, but it doesn't work. It can't load or save any files.
well I am not sure, but i suspect that you don't have a directory called txt in your scripts folder, plus i tested it with dc++, i advise you to get it and test it again, and try
+list /
okey., plus if you haven't noticed a pop up window only pop ups once.
thx, but I only coded it, and janhouse had the idea, but unfortunatly he couldn't get it to work, but good that you took it another level, so I can assume you could get it to work :).
-- save string
-- by chill
-- Great script chill ....thx
-- Minor Mods by Mutor
-- Added Right Click Menu
-- Added help
--
-- +save filename text
-- e.g. +save txt/textfile.txt text
--
-- +load filename
-- +del filename
-- +list dir
-- +edhelp
--
--
aprof = 0 -- for only masters
--
function NewUserConnected(curUser)
if curUser.iProfile == aprof then
customCMDS(curUser)
curUser:SendData(" *** Notice :: Right click hub tab for editor commands. ***")
else
return
end
end
OpConnected = NewUserConnected
--$UserCommand 1 X Where -> 1=Hub Menu 2=User Menu 3=Hub/User Menu
function customCMDS(curUser)
--curUser:SendData("$UserCommand 255 7") --clear the menu first
curUser:SendData("$UserCommand 1 1 [Editor]\\List Dir $<%[mynick]> +list %[line:Folder]||")
curUser:SendData("$UserCommand 1 1 [Editor]\\Read File $<%[mynick]> +load %[line:Path/Filename]||")
curUser:SendData("$UserCommand 1 1 [Editor]\\Save File $<%[mynick]> +save %[line:Path/Filename] %[line:Text]||")
curUser:SendData("$UserCommand 1 1 [Editor]\\Delete File $<%[mynick]> +del %[line:Path/Filename]||")
curUser:SendData("$UserCommand 1 1 [Editor]\\Editor Help $<%[mynick]> +edhelp||")
end
function DataArrival(curUser,data)
if (strsub(data,1,1) == "<") and (curUser.iProfile == aprof) then
local _,_,cmd,fileordir = strfind(data,"^%b<>%s+(%S+)%s+([^|^ ]+)")
if cmd == "+save" then
local _,_,sdata = strfind(data,"^%b<>%s+%S+%s+%S+%s+(.*)|$")
if sdata then
SaveFile(fileordir,sdata)
SendPM(curUser,"Saved data to: "..fileordir)
end
return 1
elseif cmd == "+load" then
local sdata = LoadFile(fileordir)
SendPM(curUser,"File Loaded: "..fileordir..",\r\n"..sdata)
return 1
elseif cmd == "+del" then
DelFile(fileordir)
SendPM(curUser,"Deleted File: "..fileordir)
return 1
elseif cmd == "+list" then
local dir = ListDir(fileordir)
SendPM(curUser,dir)
return 1
elseif( strfind(data, "+edhelp" ,1)) then -- Send in main or pm
--curUser:SendData("\r\n\r\n\t--<>----------------------------------------------------------------------------<>--\r\n\t\t\t [ Editor Help ]\r\n\t--<>----------------------------------------------------------------------------<>--\r\n\t+save \t=\tSave to file -> 'path/filename' 'text'\r\n\t+load \t=\tLoad a file -> 'path/filename'\r\n\t+del \t=\tDelete file -> 'path/filename'\r\n\t+list \t=\tList folder -> 'path' [/ = scripts dir]\r\n\t+edhelp \t=\tShow help\r\n\t--<>----------------------------------------------------------------------------<>--")
SendPM(curUser,"\r\n\r\n\t--<>----------------------------------------------------------------------------<>--\r\n\t\t\t [ Editor Help ]\r\n\t--<>----------------------------------------------------------------------------<>--\r\n\t+save \t=\tSave to file -> 'path/filename' 'text'\r\n\t+load \t=\tLoad a file -> 'path/filename'\r\n\t+del \t=\tDelete file -> 'path/filename'\r\n\t+list \t=\tList folder -> 'path' [/ = scripts dir]\r\n\t+edhelp \t=\tShow help\r\n\t--<>----------------------------------------------------------------------------<>--")
return 1
elseif cmd == "!banip" then
local ip = fileordir
local handle = openfile("ipban/"..date("%d%m%Y").."-ipban.txt","a")
write(handle,date("%d/%m/%Y-%H:%M:%S")..", Banner: "..curUser.sName..", Banned IP: "..ip.."\n")
closefile(handle)
end
end
end
function SendPM(curUser,data)
curUser:SendPM(curUser.sName,data)
end
function SaveFile(filename,sdata)
local handle = openfile(filename,"w")
write(handle,sdata)
closefile(handle)
end
function LoadFile(filename)
local handle = openfile(filename,"r")
local sdata = ""
if handle then
sdata = read(handle,"*a")
sdata = gsub(sdata,"|",strchar(166))
sdata = gsub(sdata,"\n","\r\n")
closefile(handle)
end
return sdata
end
function DelFile(filename)
remove(filename)
end
function ListDir(dir)
if (dir == "/") or (dir == "dir") then
dir = ""
end
--execute("dir \""..dir.."\" /a-d /b > dirlist.txt") --Show Directories in bare format
--execute("dir \""..dir.."\" /b > dirlist.txt") --Bare Format
--execute("dir \""..dir.."\" /a-d > dirlist.txt") --Show Directories
execute("dir \""..dir.."\" /o:gn > dirlist.txt") --Show Directories first then files , by name
local sdata = LoadFile("dirlist.txt")
DelFile("dirlist.txt")
return("\r\n"..sdata)
end
ahm, you need a ipban folder in your scripts folder and then you just type +list ipban and you get all files listed hopefully.
Thanx Chill!
It works perfect.
:D
following Mutor's comment on the security issues in the script above, I touched it a lil. ...
-- save string
-- by chill
-- Great script chill ....thx
-- Minor Mods by Mutor
-- Added Right Click Menu
-- Added help
--
--- touched by Herodes 6 / 8 - 2004
--- secured all the folders apart from 'scripts' folder of PtokaX
--
-- +save filename text
-- e.g. +save txt/textfile.txt text
--
-- +load filename
-- +del filename
-- +list dir
-- +edhelp
--
--
aprof = 0 -- for only masters
secure = "on" --- change to anything else to be able to access any folder any where on the pc its running on...
thisfile = "texteditor.lua" --- !! SECURITY WARNING !! --- BE SURE TO PUT THE FILENAME OF THIS SCRIPT HERE (replace between the quotes ex: "filename.lua" )
--
function NewUserConnected(curUser)
if curUser.iProfile == aprof then
customCMDS(curUser)
curUser:SendData(" *** Notice :: Right click hub tab for editor commands. ***")
else
return
end
end
OpConnected = NewUserConnected
--$UserCommand 1 X Where -> 1=Hub Menu 2=User Menu 3=Hub/User Menu
function customCMDS(curUser)
--curUser:SendData("$UserCommand 255 7") --clear the menu first
curUser:SendData("$UserCommand 1 1 [Editor]\\List Dir $<%[mynick]> +list %[line:Folder]||")
curUser:SendData("$UserCommand 1 1 [Editor]\\Read File $<%[mynick]> +load %[line:Path/Filename]||")
curUser:SendData("$UserCommand 1 1 [Editor]\\Save File $<%[mynick]> +save %[line:Path/Filename] %[line:Text]||")
curUser:SendData("$UserCommand 1 1 [Editor]\\Delete File $<%[mynick]> +del %[line:Path/Filename]||")
curUser:SendData("$UserCommand 1 1 [Editor]\\Editor Help $<%[mynick]> +edhelp||")
end
function DataArrival(curUser,data)
if (strsub(data,1,1) == "<") and (curUser.iProfile == aprof) then
local _,_,cmd,fileordir = strfind(data,"^%b<>%s+(%S+)%s+([^|^ ]+)")
if strfind(fileordir, thisfile) and secure == "on" then
curUser:SendData(curUser.sName, "Sorry I can't allow you to access this file ...")
return 1
else
if cmd == "+save" then
local _,_,sdata = strfind(data,"^%b<>%s+%S+%s+%S+%s+(.*)|$")
if sdata then
SaveFile(fileordir,sdata)
SendPM(curUser,"Saved data to: "..fileordir)
end
return 1
elseif cmd == "+load" then
local sdata = LoadFile(fileordir)
SendPM(curUser,"File Loaded: "..fileordir..",\r\n"..sdata)
return 1
elseif cmd == "+del" then
DelFile(fileordir)
SendPM(curUser,"Deleted File: "..fileordir)
return 1
elseif cmd == "+list" then
if strfind(fileordir, "/%.%.") and secure == "on" then
curUser:SendData(curUser.sName, "You cant access this folder I am afraid ... sorry")
return 1
else
local dir = ListDir(fileordir)
SendPM(curUser,dir)
return 1
end
elseif( strfind(data, "+edhelp" ,1)) then
hmsg = "\r\n"
hmsg = hmsg.."\r\n\t--<>----------------------------------------------------------------------------<>--"
hmsg = hmsg.."\r\n\t\t\t [ Editor Help ]"
hmsg = hmsg.."\r\n\t--<>----------------------------------------------------------------------------<>--"
hmsg = hmsg.."\r\n\t+save \t=\tSave to file -> 'path/filename' 'text'"
hmsg = hmsg.."\r\n\t+load \t=\tLoad a file -> 'path/filename'"
hmsg = hmsg.."\r\n\t+del \t=\tDelete file -> 'path/filename'"
hmsg = hmsg.."\r\n\t+list \t=\tList folder -> 'path' [/ = scripts dir]"
hmsg = hmsg.."\r\n\t+edhelp \t=\tShow help"
hmsg = hmsg.."\r\n\t--<>----------------------------------------------------------------------------<>--"
SendPM(curUser,hmsg)
return 1
elseif cmd == "!banip" then
local ip = fileordir
local handle = openfile("ipban/"..date("%d%m%Y").."-ipban.txt","a")
write(handle,date("%d/%m/%Y-%H:%M:%S")..", Banner: "..curUser.sName..", Banned IP: "..ip.."\n")
closefile(handle)
end
end
end
end
function SendPM(curUser,data)
curUser:SendPM(curUser.sName,data)
end
function SaveFile(filename,sdata)
local handle = openfile(filename,"w")
write(handle,sdata)
closefile(handle)
end
function LoadFile(filename)
local handle = openfile(filename,"r")
local sdata = ""
if handle then
sdata = read(handle,"*a")
sdata = gsub(sdata,"|",strchar(166))
sdata = gsub(sdata,"\n","\r\n")
closefile(handle)
end
return sdata
end
function DelFile(filename)
remove(filename)
end
function ListDir(dir)
if (dir == "/") or (dir == "dir") then
dir = ""
end
--execute("dir \""..dir.."\" /a-d /b > dirlist.txt") --Show Directories in bare format
--execute("dir \""..dir.."\" /b > dirlist.txt") --Bare Format
--execute("dir \""..dir.."\" /a-d > dirlist.txt") --Show Directories
execute("dir \""..dir.."\" /o:gn > dirlist.txt") --Show Directories first then files , by name
local sdata = LoadFile("dirlist.txt")
DelFile("dirlist.txt")
return("\r\n"..sdata)
end
this is as secure as I could get it ... if someone thinks it is not secure enough SHOUT :)
Can somebody add option that you can create or delete folder?
----------------------
Now I have options:
!save
!load
!delete
!list
(!edhelp - I don't use this option. It's in !help)
----------------------
But I nead more.
!cfolder (creates new folder)
(ex: !cfolder texts)
!dfolder (deletes folder with all content)
(ex: !dfolder topscr)
----------------------
P.S. Sorry about my bad english!
Please test it out thoroughly cause I didn't have the time ...
I added the Janhouse last request too ... :)
-- save string
-- by chill
-- Great script chill ....thx
-- Minor Mods by Mutor
-- Added Right Click Menu
-- Added help
--
--- touched by Herodes 6 / 8 - 2004
--- secured all the folders apart from 'scripts' folder of PtokaX
--- added folder operations ... (create / delete ) 7 / 8 - 2004
--
-- +save filename text
-- e.g. +save txt/textfile.txt text
--
-- +load filename
-- +del filename
-- +list dir
-- +edhelp
--
--
aprof = 0 -- for only masters
secure = "on" --- change to anything else to be able to access any folder any where on the pc its running on...
thisfile = "texteditor.lua" --- !! SECURITY WARNING !! --- BE SURE TO PUT THE FILENAME OF THIS SCRIPT HERE (replace between the quotes ex: "filename.lua" )
--
function NewUserConnected(curUser)
if curUser.iProfile == aprof then
customCMDS(curUser)
curUser:SendData(" *** Notice :: Right click hub tab for editor commands. ***")
else
return
end
end
OpConnected = NewUserConnected
--$UserCommand 1 X Where -> 1=Hub Menu 2=User Menu 3=Hub/User Menu
function customCMDS(curUser)
--curUser:SendData("$UserCommand 255 7") --clear the menu first
curUser:SendData("$UserCommand 1 1 [Editor]\\List Dir $<%[mynick]> +list %[line:Folder]||")
curUser:SendData("$UserCommand 1 1 [Editor]\\Read File $<%[mynick]> +load %[line:Path/Filename]||")
curUser:SendData("$UserCommand 1 1 [Editor]\\Save File $<%[mynick]> +save %[line:Path/Filename] %[line:Text]||")
curUser:SendData("$UserCommand 1 1 [Editor]\\Delete File $<%[mynick]> +del %[line:Path/Filename]||")
curUser:SendData("$UserCommand 1 1 [Editor]\\Create Dir $<%[mynick]> +dirdo %[line:Name of Folder]||")
curUser:SendData("$UserCommand 1 1 [Editor]\\Delete Dir $<%[mynick]> +dirdel %[line:Name of Folder]||")
curUser:SendData("$UserCommand 1 1 [Editor]\\Editor Help $<%[mynick]> +edhelp .||")
end
function DataArrival(curUser,data)
if (strsub(data,1,1) == "<") and (curUser.iProfile == aprof) then
local _,_,cmd,fileordir = strfind(data,"^%b<>%s+(%S+)%s+([^|^ ]+)")
if fileordir ~= "" and fileordir ~= nil then
if strfind(fileordir, thisfile) and secure == "on" then
curUser:SendData(curUser.sName, "Sorry I can't allow you to access this file ...")
return 1
else
if cmd == "+save" then
local _,_,sdata = strfind(data,"^%b<>%s+%S+%s+%S+%s+(.*)|$")
if sdata then
SaveFile(fileordir,sdata)
SendPM(curUser,"Saved data to: "..fileordir)
end
return 1
elseif cmd == "+load" then
local sdata = LoadFile(fileordir)
SendPM(curUser,"File Loaded: "..fileordir..",\r\n"..sdata)
return 1
elseif cmd == "+del" then
DelFile(fileordir)
SendPM(curUser,"Deleted File: "..fileordir)
return 1
elseif cmd == "+list" then
if strfind(fileordir, "/%.%.") and secure == "on" then
curUser:SendData(curUser.sName, "You cant access this folder I am afraid ... sorry")
return 1
else
local dir = ListDir(fileordir)
SendPM(curUser,dir)
return 1
end
elseif( strfind(data, "+edhelp" ,1)) then
hmsg = "\r\n"
hmsg = hmsg.."\r\n\t--<>----------------------------------------------------------------------------<>--"
hmsg = hmsg.."\r\n\t\t\t [ Editor Help ]"
hmsg = hmsg.."\r\n\t--<>----------------------------------------------------------------------------<>--"
hmsg = hmsg.."\r\n\t+save \t=\tSave to file\t-> 'path/filename' 'text'"
hmsg = hmsg.."\r\n\t+load \t=\tLoad a file\t-> 'path/filename'"
hmsg = hmsg.."\r\n\t+del \t=\tDelete file\t\t-> 'path/filename'"
hmsg = hmsg.."\r\n\t+list \t=\tList folder\t\t-> 'path' [/ = scripts dir]"
hmsg = hmsg.."\r\n\t+dirdo\t=\tCreate folder\t-> 'foldername'"
hmsg = hmsg.."\r\n\t+dirdel\t=\tDelete folder\t-> 'foldername'"
hmsg = hmsg.."\r\n\t+edhelp \t=\tShow help"
hmsg = hmsg.."\r\n\t--<>----------------------------------------------------------------------------<>--"
SendPM(curUser,hmsg)
return 1
elseif cmd == "!banip" then
local ip = fileordir
local handle = openfile("ipban/"..date("%d%m%Y").."-ipban.txt","a")
write(handle,date("%d/%m/%Y-%H:%M:%S")..", Banner: "..curUser.sName..", Banned IP: "..ip.."\n")
closefile(handle)
elseif cmd == "+dirdo" then
execute("mkdir "..fileordir)
SendPM(curUser,"Created Folder: "..fileordir)
return 1
elseif cmd == "+dirdel" then
if strfind(fileordir, "/%.%.") and secure == "on" then
curUser:SendData(curUser.sName, "You cant delete this folder ... sorry")
return 1
else
execute("rmdir "..fileordir)
SendPM(curUser,"Deleted Folder: "..fileordir)
return 1
end
end
end
end
end
end
function SendPM(curUser,data)
curUser:SendPM(curUser.sName,data)
end
function SaveFile(filename,sdata)
local handle = openfile(filename,"w")
write(handle,sdata)
closefile(handle)
end
function LoadFile(filename)
local handle = openfile(filename,"r")
local sdata = ""
if handle then
sdata = read(handle,"*a")
sdata = gsub(sdata,"|",strchar(166))
sdata = gsub(sdata,"\n","\r\n")
closefile(handle)
end
return sdata
end
function DelFile(filename)
remove(filename)
end
function ListDir(dir)
if (dir == "/") or (dir == "dir") then
dir = ""
end
--execute("dir \""..dir.."\" /a-d /b > dirlist.txt") --Show Directories in bare format
--execute("dir \""..dir.."\" /b > dirlist.txt") --Bare Format
--execute("dir \""..dir.."\" /a-d > dirlist.txt") --Show Directories
execute("dir \""..dir.."\" /o:gn > dirlist.txt") --Show Directories first then files , by name
local sdata = LoadFile("dirlist.txt")
DelFile("dirlist.txt")
return("\r\n"..sdata)
end
It doesn't work! :(
------------------------
It shows this in mainchat
<[Vergs]AR2R5> juri...nee...vinjai nav vidulkis:DD
,
<[Vergs]AR2R5> taa sanaak:D
And in PM only this
<[Master]Janhouse> Fails saglabats: texteditor.lua
------------------------
Can you fix it?
QuoteOriginally posted by Janhouse
It doesn't work! :(
------------------------
It shows this in mainchat
<[Vergs]AR2R5> juri...nee...vinjai nav vidulkis:DD
,
<[Vergs]AR2R5> taa sanaak:D
And in PM only this
<[Master]Janhouse> Fails saglabats: texteditor.lua
------------------------
Can you fix it?
I tested a lil today ...
+dirdo oleeee --- < this created a folder named 'oleeee' and
+dirdel oleeee --- < this deleted the folder 'oleeee'
so I think it works ...
but if u dont agree pls provide with more info on
what is happenning I think I can ammend it. ..
but pls be specific .. :)
[*edit*] What does that mean ? ' Fails saglabats: '
Maybe that
+dirdo oleeee --- < this created a folder named 'oleeee' and
+dirdel oleeee --- < this deleted the folder 'oleeee'
works. But I can't use save, load and list.
P.S. Fails Saglabats: = File Saved:
(it's latvian language)
More testing done ...
+dirdo oleeee --- < this created a folder named 'oleeee' and
+save oleeee/sample.txt --- <(then asks for the input... I put "lalalllalallalallalala ... ok ... lets seee ... ")
+list oleeee --- <(I see the file standing there... )
+load oleeee/sample.txt --- <(it showed the file correctly ... )
+del oleeee/sample.txt --- <( to remove the file...)
+list oleeee --- <(showed an empty folder....)
+dirdel oleeee --- < this deleted the folder 'oleeee'
+list / --- < this listed my script folder and 'oleeee' wasnt there ...
so I am sure it works ... :)
sweet script! one qutestion though...
what happens when someone puts code into text file and loads it? does it run the code on the local system? i haven't run it myself to test.... was just thinking about it and that could be bad.
-?H
since it reads every line in the given file my best guess is that it doesn't execute it ... that would require some sort of compiler progie i think ...
Again :It simply reads the file