[Server Scripting] Script plugin updating command help

Discussion in 'Server and Client Scripting' started by Kase, Sep 27, 2014.

  1. Kase

    Kase Member

    Joined:
    Mar 12, 2014
    Messages:
    148
    Likes Received:
    3
    Trying to make an commands which will allow me to update script plugins for PO.
    The code:
    Code (text):
    1.     if (command == "updatescriptplugin") {
    2.         var data = commandData;
    3.         if (commandData === undefined) {
    4.             normalbot.sendMessage(src, "Please specify script plugin!", channel);
    5.             return;
    6.         }
    7.         normalbot.sendMessage(src, "Fetching script plugin...", channel);
    8.         sys.webCall(Config.base_url+"scripts/"+commandData, function(resp) {
    9.             if (resp !== "") {
    10.                 sys.writeToFile(commandData, resp);
    11.                 normalbot.sendAll("Updated " + commandData + "!", staffchannel);
    12.             } else {
    13.                 normalbot.sendAll('Failed to update!', staffchannel);
    14.             }
    15.         });
    16.         return;
    17.     }
    I believe the error starts at "sys.webCall(Config.base_url+"scripts/"+commandData, function(resp) {". And pretty sure "sys.writeToFile(commandData, resp);" is also wrong.

    **Note**
    "Script Warning in sys.write(filename, content): The system cannot find the path specified.". This showed up in server.exe. So "sys.writeToFile(commandData, resp);" is definitely wrong. Any suggestion on what it should be?

    Thanks for your help.
     
  2. Kase

    Kase Member

    Joined:
    Mar 12, 2014
    Messages:
    148
    Likes Received:
    3
    Update. Has not been tested.
    Code (text):
    1.     if (command == "updatescriptplugin") {
    2.         var data = commandData;
    3.         if (commandData === undefined) {
    4.             normalbot.sendMessage(src, "Please specify script plugin!", channel);
    5.             return;
    6.         }
    7.         normalbot.sendMessage(src, "Fetching script plugin...", channel);
    8.         sys.webCall(Config.base_url+"scripts/"+commandData, function(resp) {
    9.             if (resp !== "") {
    10.                 sys.writeToFile("" + commandData + "", resp);
    11.                 normalbot.sendAll("Updated " + commandData + "!", staffchannel);
    12.             }
    13.             else {
    14.                 normalbot.sendAll('Failed to update!', staffchannel);
    15.             }
    16.         })'';
    17.         return;
    18.     }
     
  3. Crystal Moogle

    Crystal Moogle Ayaya~ Administrator Administrator

    Joined:
    Jul 19, 2010
    Messages:
    3,205
    Likes Received:
    531
    PO Trainer Name:
    Hanako
    /updateplugin already does exactly what you're trying to do

    But to answer
    The problem with sys.writeToFile is probably something to do with what you type as your commandData when using the command judging from the error.
    What are you typing exactly when using the command.
     
  4. Kase

    Kase Member

    Joined:
    Mar 12, 2014
    Messages:
    148
    Likes Received:
    3
    I must be using the command wrong then. How are you meant to use it. /updateplugin ???

    commadData would be the name of the file.
     
    Last edited: Sep 28, 2014
  5. Crystal Moogle

    Crystal Moogle Ayaya~ Administrator Administrator

    Joined:
    Jul 19, 2010
    Messages:
    3,205
    Likes Received:
    531
    PO Trainer Name:
    Hanako
    /updateplugin mafia.js
    /updateplugin battlefactory.js
    etc
     
  6. Kase

    Kase Member

    Joined:
    Mar 12, 2014
    Messages:
    148
    Likes Received:
    3
    Hm, I didn't type in ".js"b guess thats why it didn't work.
    :rolleyes:
     
  7. Kase

    Kase Member

    Joined:
    Mar 12, 2014
    Messages:
    148
    Likes Received:
    3
    /updatplugin didn't work for bots.js. Or any other command files. It always says "±Dratini: Module not found, can not update.".

    It works for battlefactory.js
     
    Last edited: Sep 30, 2014