1. I was wondering if anyone could give me some sample code to create cargo planes in JavaScript. I am not good with Lua at all and trying to convert the code from other plugins to JavaScript myself just gives a bunch of errors. I can't get the GameManager object to do what it's supposed to and I can't seem to get the UnityEngine to respond at all. Also how cancelling events work if possible. Any help would be appreciated. And yes, I am aware that I am just terrible at this and that's why I can't get it to work.
     
    Last edited by a moderator: Jan 31, 2015
  2. What do you mean by cancelling events? Timer?
    Code:
    var RepeatTimer = timer.Repeat(1, 5, function () {
            var random = new System.Random();
            print("Random cs number: " + random.Next(0, 10));
            print("Random js number: " + Math.random());
        }, null); // interval, repetitions, callback, plugin
    RepeatTimer.Destroy(); // kill timer if not needed anymore
    Create an entity should work as follows:
    Code:
    var global = importNamespace("");
    var UnityEngine = importNamespace("UnityEngine");
    var destination = new UnityEngine.Vector3(0, 500, 0); // or UnityEngine.Vector3.zero
    var quaternion = new UnityEngine.Quaternion(0, 0, 0, 0);
    var Supply_Drop = global.GameManager.server.CreateEntity("items/supply_drop", destination, quaternion);
    Supply_Drop.Spawn(true);
     
  3. I thought I had tried everything. Thank you so much. But what I mean by the events: I am moving over from Bukkit plugin development so I am used to easily being able to cancel events like players picking stuff up and what not and was wondering how I would cancel the hooks that get called if that's possible? So like, for example, how to cancel the OnGather hook if that's possible? Sorry if the answers to my questions are really obvious.
     
  4. Wulf

    Wulf Community Admin

    Basically any hook you can just have it return false and it will stop it, but any plugins that get loaded before your plugin will run before your plugin, unless you rename your plugin's filename so that they load first.
     
  5. Awesome, thanks a lot!