Beispiel #1
0
 public Rope(Player player, int entity1, int entity2, Vector3 offset1, Vector3 offset2, ModeFlag mode)
 {
     Player  = player;
     Entity1 = entity1;
     Entity2 = entity2;
     Offset1 = offset1;
     Offset2 = offset2;
     Mode    = mode;
 }
Beispiel #2
0
        public static void PlayerAttach(int entity, Vector3 offset, ModeFlag mode = ModeFlag.Normal)
        {
            var player = API.GetPlayerPed(-1);

            if (API.IsPedInAnyVehicle(player, false))
            {
                Attach(API.GetVehiclePedIsIn(player, false), entity, Vector3.Zero, offset, mode);
            }
            else
            {
                Attach(player, entity, _skelRootOffset, offset, mode);
            }
        }
Beispiel #3
0
 public SpeedTest(IPAddress ip, int port, int numConnection, int timespan, ModeFlag mode, CancellationToken cancel)
 {
     this.IsServerMode  = false;
     this.ServerIP      = ip;
     this.ServerPort    = port;
     this.Cancel        = cancel;
     this.NumConnection = Math.Max(numConnection, 1);
     this.TimeSpan      = Math.Max(timespan, 1000);
     this.Mode          = mode;
     if (Mode == ModeFlag.Both)
     {
         this.NumConnection = Math.Max(NumConnection, 2);
     }
     this.ClientStartEvent = new AsyncManualResetEvent();
     InitSendData();
 }
Beispiel #4
0
        public static void Attach(int entity1, int entity2, Vector3 offset1, Vector3 offset2, ModeFlag mode = ModeFlag.Normal)
        {
            if (!Permission.CanDo(Ability.RopeOtherPlayer) && (IsOtherPlayerEntity(entity1) || IsOtherPlayerEntity(entity2)))
            {
                Common.Notification("You are not allowed to attach rope to another player");
                return;
            }

            if ((mode & ModeFlag.Tow) == ModeFlag.Tow)
            {
                AdjustOffsetForTowing(entity1, ref offset1, -0.75f);
                AdjustOffsetForTowing(entity2, ref offset2, 0.75f);
            }

            if ((mode & ModeFlag.Ropegun) == ModeFlag.Ropegun)
            {
                _ropegunState.Update(ref entity1, ref entity2, ref offset1, ref offset2, out bool clearLast);
                if (clearLast)
                {
                    ClearLast();
                }
            }
            else
            {
                _ropegunState.Clear();
            }

            if (entity1 == entity2 && entity1 > 0)
            {
                return;
            }

            int ObjToNet(int entity)
            {
                if (entity == 0)
                {
                    return(0);
                }

                return(API.ObjToNet(entity));
            }

            TriggerServerEvent("PocceMod:AddRope", ObjToNet(entity1), ObjToNet(entity2), offset1, offset2, (int)mode);
        }
Beispiel #5
0
 public static void PlayerAttach(int entity, Vector3 offset, ModeFlag mode = ModeFlag.Normal)
 {
     Attach(Common.GetPlayerPedOrVehicle(), entity, Vector3.Zero, offset, mode);
 }
Beispiel #6
0
        public RopeWrapper(int player, int entity1, int entity2, Vector3 offset1, Vector3 offset2, ModeFlag mode) : base(new Player(player), entity1, entity2, offset1, offset2, mode)
        {
            GetWorldCoords(out Vector3 pos1, out Vector3 pos2);
            _length = (pos1 - pos2).Length();

            int unkPtr  = 0;
            var ropePos = pos1;

            _handle = API.AddRope(ropePos.X, ropePos.Y, ropePos.Z, 0f, 0f, 0f, _length, 1, _length, 1f, 0f, false, false, false, 5f, true, ref unkPtr);
            Attach(pos1, pos2);

            if ((Mode & ModeFlag.Grapple) == ModeFlag.Grapple)
            {
                API.StartRopeWinding(_handle);
            }
        }
Beispiel #7
0
        public static int?Attach(int entity1, int entity2, Vector3 offset1, Vector3 offset2, ModeFlag mode = ModeFlag.Normal)
        {
            if (!Permission.CanDo(Ability.RopeOtherPlayer) && (IsOtherPlayerEntity(entity1) || IsOtherPlayerEntity(entity2)))
            {
                Common.Notification("You are not allowed to attach rope to another player");
                return(null);
            }

            if ((mode & ModeFlag.Tow) == ModeFlag.Tow)
            {
                AdjustOffsetForTowing(entity1, ref offset1, -0.75f);
                AdjustOffsetForTowing(entity2, ref offset2, 0.75f);
            }

            if ((mode & ModeFlag.Ropegun) == ModeFlag.Ropegun)
            {
                _ropegunState.Update(ref entity1, ref entity2, ref offset1, ref offset2, out bool clearLast);
                if (clearLast)
                {
                    ClearLast();
                }
            }
            else
            {
                _ropegunState.Clear();
            }

            if (entity1 == entity2 && entity1 > 0)
            {
                return(null);
            }

            int ObjToNet(int entity)
            {
                if (entity == 0)
                {
                    return(0);
                }

                return(API.ObjToNet(entity));
            }

            Vector3 GetPos(int entity, Vector3 offset)
            {
                if (entity == 0)
                {
                    return(offset);
                }

                return(API.GetOffsetFromEntityInWorldCoords(entity, offset.X, offset.Y, offset.Z));
            }

            var id     = ++_nextRopeID;
            var length = (GetPos(entity1, offset1) - GetPos(entity2, offset2)).Length();

            TriggerServerEvent("PocceMod:AddRope", id, ObjToNet(entity1), ObjToNet(entity2), offset1, offset2, length);

            if ((mode & ModeFlag.Ropegun) == ModeFlag.Ropegun)
            {
                _ropegunRopes.Add(id);
            }

            if ((mode & ModeFlag.Grapple) == ModeFlag.Grapple)
            {
                TriggerServerEvent("PocceMod:SetRopeLength", id, 1f);
            }

            if (entity1 == 0 && entity2 == 0)
            {
                _expirations.Add(id, DateTime.Now + TimeSpan.FromMinutes(1));
            }

            return(id);
        }
        public RopeWrapperDelayed(int player, int netEntity1, int netEntity2, int entity1, int entity2, Vector3 offset1, Vector3 offset2, ModeFlag mode) : base(new Player(player), entity1, entity2, offset1, offset2, mode)
        {
            _netEntity1 = netEntity1;
            _netEntity2 = netEntity2;

            _tryResolve1 = _netEntity1 != 0;
            _tryResolve2 = _netEntity2 != 0;

            Retry();
        }
Beispiel #9
0
 public bool Check(ModeFlag flag)
 {
     return((this.st_mode & (UInt32)flag) != 0);
 }
Beispiel #10
0
 public void Toggle(ModeFlag flag)
 {
     this.st_mode ^= (UInt32)flag;
 }
Beispiel #11
0
 public void Clear(ModeFlag flag)
 {
     this.st_mode &= ~(UInt32)flag;
 }
Beispiel #12
0
 public void Set(ModeFlag flag)
 {
     this.st_mode |= (UInt32)flag;
 }