+ Reply to Thread
Page 1 of 19 12311 ... LastLast
Results 1 to 10 of 181

Thread: File Functions (Client -> Server)

  1. #1
    ◕␣◕ McLovin's Avatar
    Join Date
    Sep 2008
    Location
    Batman, Turkey
    Posts
    2,346
    Blog Entries
    3

    Default File Functions (Client -> Server)

    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.
    Attached Files Attached Files
    Last edited by McLovin; 09-01-2009 at 03:17 PM.
    Anticept - HP you are terrible at trolling. Always have been. Leave it up to the pros like Jat.
    Black Phoenix - Actually cunt goes into bullshit. Bullshit does not fit in cunt.
    Drunkie - Logically, Jat Goodwin must be a fist pumping guido.

  2. #2
    Expressionism 2.0 Syranide's Avatar
    Join Date
    Mar 2007
    Location
    Sweden
    Posts
    4,573

    Default re: File Functions (Client -> Server)

    I would recommend making it event-based (runOnChat()), so that instead of continually polling and keeping track of if one has already read the file etc, that the gate executes when the file is available and that one can check it using some command (chatClk()).

    Otherwise, it's an interesting thought to only have read support, it will provide quite a lot of possibilities with only that.

    EDIT: also, no need to transfer files multiple times really? (it also makes it harder as one has to keep track of it in E2 now, otherwise there will be massive "overhead" if one doesn't consider it)

  3. #3
    ◕␣◕ McLovin's Avatar
    Join Date
    Sep 2008
    Location
    Batman, Turkey
    Posts
    2,346
    Blog Entries
    3

    Default re: File Functions (Client -> Server)

    I was thinking if the fileWrite() function gets implemented then you may want to reload a file. Or maybe putting a timer on it.
    Anticept - HP you are terrible at trolling. Always have been. Leave it up to the pros like Jat.
    Black Phoenix - Actually cunt goes into bullshit. Bullshit does not fit in cunt.
    Drunkie - Logically, Jat Goodwin must be a fist pumping guido.

  4. #4
    Wire Sofaking SatansSimon's Avatar
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    513

    Default re: File Functions (Client -> Server)

    I would really welcome a fileWrite() function because it would create the possibility of creating protocols via E2.

  5. #5
    Expressionism 2.0 Syranide's Avatar
    Join Date
    Mar 2007
    Location
    Sweden
    Posts
    4,573

    Default re: File Functions (Client -> Server)

    Quote Originally Posted by IamMcLovin View Post
    I was thinking if the fileWrite() function gets implemented then you may want to reload a file. Or maybe putting a timer on it.
    Well, I would say that if one uses fileWrite, that the new content of the file is already available on the server (and also sent to the client), thus no need to reload the file.

    Quote Originally Posted by SatansSimon View Post
    I would really welcome a fileWrite() function because it would create the possibility of creating protocols via E2.
    What?
    You can't (or rather, definately should NOT) use this to communicate within gmod.

  6. #6
    ◕␣◕ McLovin's Avatar
    Join Date
    Sep 2008
    Location
    Batman, Turkey
    Posts
    2,346
    Blog Entries
    3

    Default re: File Functions (Client -> Server)

    Let me know if I should change anything Syranide.
    Anticept - HP you are terrible at trolling. Always have been. Leave it up to the pros like Jat.
    Black Phoenix - Actually cunt goes into bullshit. Bullshit does not fit in cunt.
    Drunkie - Logically, Jat Goodwin must be a fist pumping guido.

  7. #7
    Expressionism 2.0 Syranide's Avatar
    Join Date
    Mar 2007
    Location
    Sweden
    Posts
    4,573

    Default re: File Functions (Client -> Server)

    Quote Originally Posted by IamMcLovin View Post
    Let me know if I should change anything Syranide.
    loadClk() => fileClk()
    runOnLoad => runOnFile()

    To keep the naming convention going, and perhaps also a fileClk(S) to determine a specific file.

    There also needs to be some limit to the amount of information read/written so it can't be as abused. And also some limit to how often a file is sent (and loaded), so writing every execution doesn't cause it to send the file every execution. One solution could be to simply limit reading and writing to 10KB/s or so (aka, reading a 100KB file is "instant", but the next file won't be loaded until 10sec later). So reads and writes are queues.

    Something like along those lines needs to exist.

  8. #8
    ◕␣◕ McLovin's Avatar
    Join Date
    Sep 2008
    Location
    Batman, Turkey
    Posts
    2,346
    Blog Entries
    3

    Default re: File Functions (Client -> Server)

    yea max is 100 Kb Ill try to rename and have the timers on later today.
    Anticept - HP you are terrible at trolling. Always have been. Leave it up to the pros like Jat.
    Black Phoenix - Actually cunt goes into bullshit. Bullshit does not fit in cunt.
    Drunkie - Logically, Jat Goodwin must be a fist pumping guido.

  9. #9
    Expressionism 2.0 Syranide's Avatar
    Join Date
    Mar 2007
    Location
    Sweden
    Posts
    4,573

    Default re: File Functions (Client -> Server)

    Quote Originally Posted by IamMcLovin View Post
    yea max is 100 Kb Ill try to rename and have the timers on later today.
    Sounds great

    Just so you know, if you don't agree with my suggestions/requirements, then simply say so. I'm not perfect, and there might be better solutions than the one I proposed (as Jimlad has pointed out many times ^_^). I'll happily explain my reasons or keep a discussion going.

  10. #10
    Wire Sofaking Solece's Avatar
    Join Date
    Jul 2008
    Location
    Pittsburgh, PA
    Posts
    673

    Default re: File Functions (Client -> Server)

    Any chance of this becoming official? I'm looking forward to making a learning AI

+ Reply to Thread
Page 1 of 19 12311 ... LastLast

LinkBacks (?)

  1. 06-08-2010, 02:50 PM
  2. 03-14-2010, 11:47 AM

Similar Threads

  1. File management functions
    By turck3 in forum Expression 2 Discussion & Help
    Replies: 33
    Last Post: 07-03-2009, 02:08 PM
  2. [E2] File Functions
    By Asphid in forum Wiremod Addons & Coding
    Replies: 7
    Last Post: 06-20-2009, 07:17 PM
  3. Running server Lua functions from client
    By Matte in forum Wiremod Addons & Coding
    Replies: 3
    Last Post: 06-09-2009, 02:53 AM
  4. Wire mod problems client and server
    By benjojo in forum Installation and Malfunctions Support
    Replies: 5
    Last Post: 02-23-2009, 12:41 PM
  5. SVN Client Server refusal
    By Mesys in forum Wiremod Website Chat
    Replies: 9
    Last Post: 05-22-2008, 02:57 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots