Beispiel #1
0
        public static async Task PocceCompanion()
        {
            int ped;
            int player = API.GetPlayerPed(-1);

            if (API.IsPedInAnyVehicle(player, false))
            {
                var vehicle = API.GetVehiclePedIsIn(player, false);
                if (Vehicles.GetFreeSeat(vehicle, out int seat))
                {
                    var pocce = Config.PocceList[API.GetRandomIntInRange(0, Config.PocceList.Length)];
                    await Common.RequestModel(pocce);

                    ped = API.CreatePedInsideVehicle(vehicle, 26, pocce, seat, true, false);
                }
                else if (API.GetEntitySpeed(vehicle) > 0.1f)
                {
                    Hud.Notification("Player is in a moving vehicle and there are no free seats");
                    return;
                }
                else
                {
                    ped = await Peds.Spawn(Config.PocceList);
                }
            }
            else
            {
                ped = await Peds.Spawn(Config.PocceList);
            }

            Companions.Add(ped);
            await Peds.Arm(ped, Config.WeaponList);

            API.SetEntityAsNoLongerNeeded(ref ped);
        }
Beispiel #2
0
        public static void Attach(int entity1, int entity2, Mode mode = Mode.Normal)
        {
            if (!Permission.CanDo(Ability.RopeOtherPlayer))
            {
                var player = API.GetPlayerPed(-1);
                if ((API.IsEntityAPed(entity1) && API.IsPedAPlayer(entity1) && entity1 != player) ||
                    (API.IsEntityAPed(entity2) && API.IsPedAPlayer(entity2) && entity2 != player))
                {
                    Hud.Notification("You are not allowed to attach rope to another player");
                    return;
                }
            }

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

            if (entity1 == entity2)
            {
                return;
            }

            TriggerServerEvent("PocceMod:AddRope", API.ObjToNet(entity1), API.ObjToNet(entity2), (mode & Mode.Tow) == Mode.Tow);
        }
Beispiel #3
0
        public static async Task PetCompanion()
        {
            int player = API.GetPlayerPed(-1);

            if (API.IsPedInAnyHeli(player))
            {
                Hud.Notification("Don't spawn that poor pet on a heli");
                return;
            }
            else if (API.IsPedInAnyVehicle(player, false))
            {
                var vehicle = API.GetVehiclePedIsIn(player, false);
                if (API.GetVehicleDashboardSpeed(vehicle) > 0.1f)
                {
                    Hud.Notification("Player is in a moving vehicle");
                    return;
                }
            }

            var ped = await Peds.Spawn(Config.PetList, 28);

            Companions.Add(ped);
            await Peds.Arm(ped, null);

            API.SetEntityAsNoLongerNeeded(ref ped);
        }
Beispiel #4
0
        public static async Task Activate()
        {
            var player = API.GetPlayerPed(-1);

            if (!API.IsPedInAnyVehicle(player, false))
            {
                Hud.Notification("Player is not in a vehicle");
            }

            var vehicle = API.GetVehiclePedIsIn(player, false);

            if (API.IsVehicleSeatFree(vehicle, -1))
            {
                await Spawn(vehicle);

                return;
            }

            if (API.GetPedInVehicleSeat(vehicle, -1) != player)
            {
                Hud.Notification("You are not the driver of this vehicle");
                return;
            }

            if (Vehicles.GetFreeSeat(vehicle, out int seat, true))
            {
                var driver = API.GetPedInVehicleSeat(vehicle, -1);
                API.SetPedIntoVehicle(driver, vehicle, seat);

                await Spawn(vehicle);
            }
Beispiel #5
0
        public static Task <int> Spawn(string model)
        {
            var player = API.GetPlayerPed(-1);
            var hash   = (uint)API.GetHashKey(model);

            if (!API.IsModelValid(hash))
            {
                Hud.Notification(string.Format("Invalid model hash: 0x{0:X8} ({1})", hash, model));
                return(Task.FromResult(-1));
            }

            if (_firstSpawn)
            {
                Hud.Notification("First time spawning prop, yay! Try /prop [search] command for filtered props");
                Hud.Notification("Use the arrow keys to correct the position of the prop");
                _firstSpawn = false;
            }

            if (API.IsPedInAnyVehicle(player, false))
            {
                var vehicle = API.GetVehiclePedIsIn(player, false);
                return(SpawnOnEntity(vehicle, hash));
            }
            else
            {
                return(SpawnInFrontOfPed(player, hash));
            }
        }
Beispiel #6
0
        public static async Task <int> Spawn(string model)
        {
            var player = API.GetPlayerPed(-1);
            var pos    = API.GetEntityCoords(player, true);
            var hash   = (uint)API.GetHashKey(model);

            if (!API.IsModelValid(hash))
            {
                Hud.Notification(string.Format("Invalid model hash: 0x{0:X8} ({1})", hash, model));
                return(-1);
            }

            if (API.IsPedInAnyVehicle(API.GetPlayerPed(-1), false))
            {
                Hud.Notification("Player is in a vehicle");
                return(-1);
            }

            await Common.RequestModel(hash);

            var vehicle = API.CreateVehicle(hash, pos.X, pos.Y, pos.Z + 1f, API.GetEntityHeading(player), true, false);

            API.SetPedIntoVehicle(player, vehicle, -1);

            if (API.IsThisModelAHeli(hash) && API.GetEntityHeightAboveGround(vehicle) > 10f)
            {
                API.SetHeliBladesFullSpeed(vehicle);
            }

            return(vehicle);
        }
Beispiel #7
0
 public static void RopeClosest(IEnumerable <int> entities, bool tow = false)
 {
     if (Common.GetClosestEntity(entities, out int closest))
     {
         Ropes.PlayerAttach(closest, tow ? Ropes.Mode.Tow : Ropes.Mode.Normal);
     }
     else
     {
         Hud.Notification("Nothing in range");
     }
 }
Beispiel #8
0
        public static void TeleportToClosestVehicle(bool forcePassenger = false)
        {
            var vehicles = Vehicles.Get();

            if (Common.GetClosestEntity(vehicles, out int vehicle))
            {
                if (Vehicles.GetFreeSeat(vehicle, out int seat, forcePassenger))
                {
                    var player = API.GetPlayerPed(-1);
                    API.SetPedIntoVehicle(player, vehicle, seat);
                }
                else
                {
                    Hud.Notification("Closest vehicle doesn't have a free seat");
                }
            }
Beispiel #9
0
        public static List <string> IdentifyPedModels()
        {
            var coords = API.GetEntityCoords(API.GetPlayerPed(-1), true);
            var peds   = Peds.Get();
            var models = new List <string>();

            foreach (var ped in peds)
            {
                var pos = API.GetEntityCoords(ped, true);
                if (coords.DistanceToSquared(pos) < 4f)
                {
                    var model = string.Format("0x{0:X8}", API.GetEntityModel(ped));
                    models.Add(model);
                    Hud.Notification("ped:" + model);
                }
            }

            return(models);
        }
Beispiel #10
0
        public static async Task <int> SpawnAtCoords(string model, Vector3 coords, Vector3 rotation)
        {
            var hash = (uint)API.GetHashKey(model);

            if (!API.IsModelValid(hash))
            {
                Hud.Notification(string.Format("Invalid model hash: 0x{0:X8} ({1})", hash, model));
                return(-1);
            }

            await Common.RequestModel(hash);

            var prop = API.CreateObject((int)hash, coords.X, coords.Y, coords.Z, true, false, false);

            _props.Add(prop);

            API.SetEntityRotation(prop, rotation.X, rotation.Y, rotation.Z, 0, true);
            API.DecorSetBool(prop, PropDecor, true);
            return(prop);
        }
Beispiel #11
0
        public static async Task PoccePassengers()
        {
            int player = API.GetPlayerPed(-1);

            if (!API.IsPedInAnyVehicle(player, true))
            {
                Hud.Notification("Player is not in a vehicle");
                return;
            }

            var vehicle = API.GetVehiclePedIsIn(player, false);

            while (Vehicles.GetFreeSeat(vehicle, out int seat))
            {
                var pocce = Config.PocceList[API.GetRandomIntInRange(0, Config.PocceList.Length)];
                await Common.RequestModel(pocce);

                var ped = API.CreatePedInsideVehicle(vehicle, 26, pocce, seat, true, false);
                API.SetEntityAsNoLongerNeeded(ref ped);
            }
        }
Beispiel #12
0
            public void Update(ref int entity1, ref int entity2, out bool clearLast)
            {
                clearLast = false;

                var player = GetPlayerEntity();

                if (entity1 != player && entity2 != player)
                {
                    return;
                }

                if (_ropegunFirstUse)
                {
                    Hud.Notification("First time using ropegun, yay! You can connect 2 entities in 2 seconds");
                    _ropegunFirstUse = false;
                }

                var timestamp = DateTime.Now;

                if (_lastRopegunEntity1 != -1 && _lastRopegunEntity2 != -1 && (timestamp - _lastRopegunFire) < TimeSpan.FromSeconds(2f))
                {
                    clearLast = (_lastRopegunEntity1 == player || _lastRopegunEntity2 == player);

                    if (entity1 == player)
                    {
                        entity1 = _lastRopegunEntity2;
                    }
                    else
                    {
                        entity2 = _lastRopegunEntity2;
                    }
                }

                _lastRopegunEntity1 = entity1;
                _lastRopegunEntity2 = entity2;
                _lastRopegunFire    = timestamp;
            }