Hey, I was read a post and agreed with Syranide that most if not all file reading and writing E2 functions only really work client side. So I took his suggestion and made Client -> Server data streaming functions.
Function List
Code:
fileLoad(File(S))
fileLoaded(File(S))
fileRead(File(S))
fileWrite(File Name(S),File Data(S))
fileAppend(File Name(S),File Data(S))
fileRemove(File Name(S))
runOnFile(Activate(N))
fileClk(File Name(S))
fileClk()
fileLoad(S) loads the file from the client and sends it to server (you must wait at least 10 seconds before uploading to server and the file has to be under 100 kb)
fileLoaded(S) returns whether or not the file has been loaded onto the server
fileRead(S) returns the string data from a given file (has to be loaded onto server)
fileWrite(S,S) writes a file to your data folder (automatically uploads to server)
fileAppend(S,S) adds to the end of a file on your client, and if the file is on the server it adds to that file as well.
fileRemove(S) removes a file from the server so you can upload another file.
runOnFile(N) makes is run your expression when a file finishes uploading to server
fileClk(S) returns whether the execution was run because a file finished uploading and was that file of a specific file name
fileClk() returns whether the execution was run because a file finished uploading
ALL FILES HAVE TO END IN .txt!!!!!
All files being loaded MUST be in the data folder!
Code:
@name File Loader
@inputs
@outputs S:string
@persist
@trigger all
if(first())
{
fileLoad("im_a_file_in_datafolder.txt")
S = ""
runOnFile(1)
}
if(fileClk("im_a_file_in_datafolder.txt"))
{
S = fileRead("im_a_file_in_datafolder.txt")
} Extract to addons.
UPDATE
Players must wait 10 seconds between uploads. Players have a max of 100 uploads and a max of 100kb per upload.
When a player leaves it now deletes their uploaded file cache.
About fileReadLine and fileWriteLine, I don't see the point in doing them mainly because you can do the same thing with arrays and the glon functions. Adding lines would overcomplicate this addon.
Bookmarks