1. how to declare a global variable? can't I declare =(

    P.S: js

    in JS is not working global (for example: global.BasePlayer.activePlayerList.Count)
     
    Last edited by a moderator: Jan 27, 2015
  2. Wulf

    Wulf Community Admin

    I'm not sure, I'll see if I can get an answer for you though.
     
  3. Can you give an example of what you're trying to do?
     
  4. Replicating the error:
    [​IMG]

    Code:
      cmdTest : function(){
           global.ConsoleSystem.Broadcast("chat.add \"" +"ERROR"+ "\" \"" +"global does not work x)"+ "\"");
       },
    
     
  5. for example: global.BasePlayer.activePlayerList.Count
     
  6. when my pull request is merged following will work:
    Code:
    var jstest = {
        Title : "Javascript Test",
        Author : "Nogrod",
        Version : V(1, 0, 0),
        HasConfig : true,
        OnServerInitialized : function () {
            var global = importNamespace("");
            print(global.BasePlayer.activePlayerList.Count);
            webrequests.EnqueueGetHook("http://loripsum.net/generate.php?p=1&l=short", "RequestResult",  this.Plugin);
        },
        RequestResult : function (code, response) {
            print(code+"|----|"+response);
        }
    }
     
  7. not work:
    Code:
    var test = {
        Title : "Javascript Test",
        Author : "Nogrod",
        Version : V(1, 0, 0),
        HasConfig : true,
        Init : function () {
            var global = importNamespace("");
            print(global.BasePlayer.activePlayerList.Count);
        }
    }
    [​IMG]
     
  8. Wulf

    Wulf Community Admin

    Try the latest snapshot to see if it works now. https://github.com/OxideMod/Snapshots/blob/master/Rust/OxideRust.zip?raw=true