1. Hi!
    I have question: what about airdrop to player? If I add spec code for target in your example:
    Code:
    var player = global.BasePlayer.FindByID("myID");
    var destination =  player.transform.position.normalized;
    var quaternion = new UnityEngine.Quaternion(0, 0, 0, 0);
    global.GameManager.server.CreateEntity("events/cargo_plane", destination, quaternion).Spawn(true);
    its not work... supply not dropps on me( maybe problem in quaternion? what is it?
    can you help me, guys?
    p.s. sorry for my english.
     
    Last edited by a moderator: Apr 28, 2015
  2. The vector specified when the entity (in this case cargoplane) is spawned is the spawn location, at that point a destination is calculated and the crate will drop in the center of those locations so you will need to add more logic to it that modifies the destination to get to a set location.
     
  3. I've got it. Thanks! This pluhin http://oxidemod.org/plugins/airdrop-controller.804/ can drop supply from cargoplane right on the player... but it wrote on C# and I don't know how to convert written in javascript... (
    I tried a lot, but my knowledge is clearly not enough.. okay, thanks, I will torment code on))
    [DOUBLEPOST=1430198344,1430129704][/DOUBLEPOST]I have a new question: when I try to subtract one vector from another (in JS), I get an error.
    Code:
    var UnityEngine = importNamespace("UnityEngine");
            var targetPos = player.transform.position;
            var centerPos = UnityEngine.Vector3(0,0,0);
            var directionFromCenter = (targetPos - centerPos).normalized;
            var directionAngles = UnityEngine.Quaternion.LookRotation(directionFromCenter);
            var toRight = directionAngles * UnityEngine.Vector3.right;
            var toLeft = directionAngles * UnityEngine.Vector3.left;
            startpos = targetPos;
    Error:
    Code:
    Failed to call hook 'life' on plugin 'lifestat' (InvalidOperationException: No matching indexer found.)
    8:21 AM [Debug]   at Jint.Runtime.Descriptors.Specialized.IndexDescriptor..ctor (Jint.Engine engine, System.Type targetType, System.String key, System.Object item) [0x00000] in <filename unknown>:0
      at Jint.Runtime.Descriptors.Specialized.IndexDescriptor..ctor (Jint.Engine engine, System.String key, System.Object item) [0x00000] in <filename unknown>:0
      at Jint.Runtime.Interop.ObjectWrapper.GetOwnProperty (System.String propertyName) [0x00000] in <filename unknown>:0
      at Jint.Native.Object.ObjectInstance.GetProperty (System.String propertyName) [0x00000] in <filename unknown>:0
      at Jint.Native.Object.ObjectInstance.Get (System.String propertyName) [0x00000] in <filename unknown>:0
      at Jint.Native.Object.ObjectInstance.DefaultValue (Types hint) [0x00000] in <filename unknown>:0
      at Jint.Runtime.TypeConverter.ToPrimitive (JsValue input, Types preferredType) [0x00000] in <filename unknown>:0
      at Jint.Runtime.TypeConverter.ToNumber (JsValue o) [0x00000] in <filename unknown>:0
      at Jint.Runtime.ExpressionInterpreter.EvaluateBinaryExpression (Jint.Parser.Ast.BinaryExpression expression) [0x00000] in <filename unknown>:0
      at Jint.Engine.EvaluateExpression (Jint.Parser.Ast.Expression expression) [0x00000] in <filename unknown>:0
      at Jint.Runtime.ExpressionInterpreter.EvaluateExpression (Jint.Parser.Ast.Expression expression) [0x00000] in <filename unknown>:0
      at Jint.Runtime.ExpressionInterpreter.EvaluateMemberExpression (Jint.Parser.Ast.MemberExpression memberExpression) [0x00000] in <filename unknown>:0
      at Jint.Engine.EvaluateExpression (Jint.Parser.Ast.Expression expression) [0x00000] in <filename unknown>:0
      at Jint.Runtime.StatementInterpreter.ExecuteVariableDeclaration (Jint.Parser.Ast.VariableDeclaration statement) [0x00000] in <filename unknown>:0
      at Jint.Engine.ExecuteStatement (Jint.Parser.Ast.Statement statement) [0x00000] in <filename unknown>:0
      at Jint.Runtime.StatementInterpreter.ExecuteStatement (Jint.Parser.Ast.Statement statement) [0x00000] in <filename unknown>:0
      at Jint.Runtime.StatementInterpreter.ExecuteStatementList (IEnumerable`1 statementList) [0x00000] in <filename unknown>:0
      at Jint.Runtime.StatementInterpreter.ExecuteBlockStatement (Jint.Parser.Ast.BlockStatement blockStatement) [0x00000] in <filename unknown>:0
      at Jint.Engine.ExecuteStatement (Jint.Parser.Ast.Statement statement) [0x00000] in <filename unknown>:0
      at Jint.Native.Function.ScriptFunctionInstance.Call (JsValue thisArg, Jint.Native.JsValue[] arguments) [0x00000] in <filename unknown>:0
      at Oxide.Ext.JavaScript.Plugins.JavaScriptPlugin.CallFunction (System.String name, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Ext.JavaScript.Plugins.JavaScriptPlugin.OnCallHook (System.String hookname, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.Plugin.CallHook (System.String hookname, System.Object[] args) [0x00000] in <filename unknown>:0
    
    can be in javascript vectors are deducted differently?
    [DOUBLEPOST=1430198492][/DOUBLEPOST]For understanding I am trying to alter this function to javascript =)
    Code:
    void FindStartAndEndPos(Vector3 target, out Vector3 startpos, out Vector3 endpos, out float distance)
            {
                var directionFromCenter = (target - centerPos).normalized;
                var directionAngles = Quaternion.LookRotation( directionFromCenter );
                var toRight = directionAngles * Vector3.right;
                var toLeft = directionAngles * Vector3.left;
                startpos = target;
                var multiplier = 1000f;
                var i = 0f;
                for(int o=0;o<50;o++)
                {
                    var temPos = startpos + toRight * i * multiplier;
                    if (((float)Math.Abs(temPos.x + multiplier) > (World.Size / 2)) || ((float)Math.Abs(temPos.x - multiplier) > (World.Size / 2)) || ((float)Math.Abs(temPos.z - multiplier) > (World.Size / 2)) || ((float)Math.Abs(temPos.z + multiplier) > (World.Size / 2)))
                    {
                        multiplier = multiplier / 10f;
                        i = 0f;
                    }
                    else
                    {
                        temPos.y = startpos.y;
                        startpos = temPos;
                        i = i + 1f;
                    }
                    if (multiplier < 1f)
                    {
                        break;
                    }
                }
                distance = Vector3.Distance(startpos, target);
                endpos = target - toRight * distance;
            }
     
  4. In C# you can subtract them normally by using "MyFirstVector - MySecondVector" as Vector3 has different operator methods available, I can't really say for sure for JavaScript, but for lua I had to actually call that method so I'm guessing it will be something similar for JS, I'm just afraid I can't tell you which as I have not used JavaScript to write plugins before.
     
  5. Thank you for trying to help me! I got rid of the error, if subtract like this, but I'm not sure that this method gives me the correct result =)
    Code:
    var directionFromCenter = UnityEngine.Vector3(centerPos.x-targetPos.x, centerPos.y-targetPos.y, centerPos.z-targetPos.z).normalized;