Pokemon Online Script Failure

Discussion in 'Server and Client Scripting' started by bournemouth, Jul 19, 2011.

Thread Status:
Not open for further replies.
  1. bournemouth

    bournemouth New Member

    Joined:
    Jul 19, 2011
    Messages:
    5
    Likes Received:
    0
    So I'm trying to set up a server, and these are the errors I get. I have safe scripts off and have copied the script char for char from http://pokemon-online.eu/scripts.js

    Script Warning in sys.getFileContent(filename): error when opening mafia_stats.json: No such file or directory
    Script Warning in sys.getFileContent(filename): error when opening suspectvoting.json: No such file or directory
    Script Check: OK
    Script Warning in sys.getFileContent(filename): error when opening channelData.json: No such file or directory
    Could not read channelData.
    Error: SyntaxError: Unable to parse JSON string
    Script Warning in sys.getFileContent(filename): error when opening mutes.txt: No such file or directory
    Script Warning in sys.getFileContent(filename): error when opening mbans.txt: No such file or directory
    Script Warning in sys.getFileContent(filename): error when opening smutes.txt: No such file or directory
    Script Warning in sys.getFileContent(filename): error when opening rangebans.txt: No such file or directory
    Script Warning in sys.getFileContent(filename): error when opening nameBans.json: No such file or directory
    Script Warning in sys.getFileContent(filename): error when opening pastebin_api_key: No such file or directory
    Script Error line 2878: ReferenceError: Can't find variable: staffchannel
    Connecting to registry...
    Connected to registry! Sending server info...
    The registry acknowledged the server.
    Received pending connection on slot 1 from 192.168.1.1
    Player 1 set name to user
    Script Error line 3210: ReferenceError: Can't find variable: trollchannel
    user joined channel Main.
    Script Error line 3323: ReferenceError: Can't find variable: maxPlayersOnline
    Script Error line 5508: TypeError: Result of expression 'SESSION.users(src).expired' [undefined] is not a function.
    [#Main] user: !commands
    Script Error line 5765: ReferenceError: Can't find variable: lineCount
    Script Warning in sys.getFileContent(filename): error when opening mafia_stats.json: No such file or directory
    Script Warning in sys.getFileContent(filename): error when opening suspectvoting.json: No such file or directory
    Fatal Script Error line 2626: ReferenceError: Can't find variable: mafiachan
     
  2. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    Get new server (version 1.0.23)
     
  3. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    PO Scripts need something like this:
    Code (javascript):
    1.  
    2. function createFile(file) {
    3. if(sys.getFileContent(file) == undefined) {
    4. sys.writeToFile(file,"");
    5. }
    6. }
    7.  
     
  4. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    That would give a warning too on the first run . PO still needs a function to check if a file can be read / written.
     
  5. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    Code (javascript):
    1.  
    2. function createFile(file,type) {
    3. sys.appendToFile(file+"."+type,"");
    4. }
    5.  
    Tested.. and works. It writes nothing to a file, but creates the file in the mean time if it doesnt exist. type can be removed.
     
  6. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    Still hack, albeit, best one to date :P
     
  7. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    Code (javascript):
    1.  
    2.  
    3. function createFile(file,type,replacement) {
    4. type = type.toLowerCase()
    5. switch(type) {
    6. case 'json':
    7. case 'hashfile':
    8. type = ".json";
    9. break;
    10. case 'txt':
    11. case 'text':
    12. case 'normal':
    13. case 'file':
    14. // Etc etc //
    15. type = ".txt";
    16. break;
    17. case 'javascript':
    18. case 'qscript':
    19. case 'script':
    20. case 'js':
    21. type = ".js";
    22. break;
    23. default:
    24. print("Type "+type+" not found, might be time to update createFile() ?");
    25. type = ""
    26. break;
    27. }
    28. sys.appendToFile(file+type,"");
    29. if(sys.getFileContent(file+type) == "") {
    30. sys.writeToFile(file+type,replacement);
    31. }
    32. }
    33.  
    Better version for json and stuff.
     
    Last edited: Jul 20, 2011
  8. bournemouth

    bournemouth New Member

    Joined:
    Jul 19, 2011
    Messages:
    5
    Likes Received:
    0
    I placed some dummy files in place of the missing files. Not sure what the syntax is for channeldata, and every time someone speaks, there is the linecount error.

    Script Check: OK
    Could not read channelData.
    Error: SyntaxError: Unable to parse JSON string
    Script Warning in sys.getFileContent(filename): error when opening pastebin_api_key: No such file or directory
    Script Error line 2909: ReferenceError: Can't find variable: staffchannel
    Connecting to registry...
    Connected to registry! Sending server info...
    The registry acknowledged the server.
    Received pending connection on slot 1 from 192.168.1.1
    Player 1 set name to Lumberjack Luke
    Script Error line 3241: ReferenceError: Can't find variable: trollchannel
    Lumberjack Luke joined channel Main.
    Script Error line 3354: ReferenceError: Can't find variable: maxPlayersOnline
    Script Error line 5539: TypeError: Result of expression 'SESSION.users(src).expired' [undefined] is not a function.
    [#Main] Lumberjack Luke: test
    Script Error line 5796: ReferenceError: Can't find variable: lineCount
     
  9. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    Like I said. Upgrade to 1.0.23 >_>
     
  10. bournemouth

    bournemouth New Member

    Joined:
    Jul 19, 2011
    Messages:
    5
    Likes Received:
    0
    Okay I just had to update the script, now the only errors are these:
    Fatal Script Error line 2683: TypeError: Result of expression 'SESSION.channels(id)' [undefined] is not an object.
    Could not read channelData.
    Error: SyntaxError: Unable to parse JSON string

    Also, I can't use any commands. Upon connecting all I get is:
    (19:09:44) Connected to Server!
    Welcome Message: The updates are available at pokemon-online.eu. Report any bugs on the forum.


    no /rules or !commands info

    Also I had the updated version of the server the whole time, I first downloaded the server last night.
     
  11. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    What is near the SESSION.channels(id) line error?
     
  12. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    It fails if scripts are loaded for the first time (and not by changing script). I'll fix it.
     
  13. Thequickster

    Thequickster New Member

    Joined:
    Jun 9, 2011
    Messages:
    17
    Likes Received:
    0
    I have the same
    problem. :(
     
  14. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    Just wait 'till Lamperi fixes it..
     
  15. bournemouth

    bournemouth New Member

    Joined:
    Jul 19, 2011
    Messages:
    5
    Likes Received:
    0
    Lamperi can you post here again after you've fixed it? Thanks.
     
  16. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    I won't create the files for nothing. There will be the error unless you create them yourselves... It doesn't do anything bad though, you can leave it, there's safe failback.
     
  17. bournemouth

    bournemouth New Member

    Joined:
    Jul 19, 2011
    Messages:
    5
    Likes Received:
    0
    Still, whenever anyone tries to say something, this error happens.

    Script Error line 5951: ReferenceError: Can't find variable: lineCount

    Because of this, no commands work.
     
  18. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    try removing that, i think its something like this:
    Code (text):
    1.  
    2. lineCount += 1;
    3.  
    Not sure tho :P
     
  19. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    Newest scripts work for me when you load it.

    What errors they give when you load them? They work for me, must be some missing file.
     
  20. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    Well... heres isFile():
    It returns false on existing empty files however.

    Code (javascript):
    1.  
    2. function isFile(filename) {
    3. sys.appendToFile(filename,"");
    4. if(sys.getFileContent(filename) == "") {
    5. sys.deleteFile(filename);
    6. return false;
    7. }
    8. return true;
    9. }
    10.  
     
    Last edited: Jul 25, 2011
  21. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    It creates the file.
     
  22. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    Oops, forgot to call sys.deleteFile(). Fixed :/
     
  23. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    It now deletes empty files. You can't make it with the current API.
     
  24. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    (?_?) getFileContent() is supposed to give a warning when there is no file to read. Nothing bad about it, move along. Also, calling fileExists() like command and opening it later causes potential race condition, as file might be deleted before your program read it.
     
  25. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    Mystra ^
    The problem is that all the people who use PO scripts complain about numerous warnings scripts give them :-) because of unexistant files
     
  26. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    Maybe it should be renamed to, say, notice? (O.o)
     
  27. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    maybe appendToFile should be called at the beginning of the scripts to avoid all warnings.
     
  28. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    Why would you do redundant things…
     
  29. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    Code (javascript):
    1. function isFile(filename) {
    2. sys.appendToFile(filename,"");
    3. if(sys.getFileContent(filename) == "") {
    4. sys.writeToFile(filename,"Bla bla, just to make sure theres something in it :/");
    5. sys.deleteFile(filename);
    6. return false;
    7. }
    8. return true;
    9. }
    10.  
    Has to work? It first writes before deletion
     
    Last edited: Jul 26, 2011
  30. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    I'm locking this thread since it gets nowhere.
     
Thread Status:
Not open for further replies.