Esempio n. 1
0
        public void ecc(Client player)
        {
            var     vehicles  = NAPI.Pools.GetAllVehicles();
            Vector3 playerpos = player.Position;
            Vehicle closest   = null;
            float   distance  = 999999f;


            foreach (var v in vehicles)
            {
                float cardist = v.Position.DistanceTo(playerpos);
                if (cardist < distance)
                {
                    distance = cardist;
                    closest  = v;
                }
            }

            if (closest != null)
            {
                var driver = NAPI.Vehicle.GetVehicleDriver(closest);
                if (driver != null)
                {
                    player.SendChatMessage("Someone else is driving the closest vehicle.");
                    return;
                }
                NAPI.Player.SetPlayerIntoVehicle(player, closest, -1);
            }
            else
            {
                NAPI.Chat.SendChatMessageToPlayer(player, "No car");
            }
        }
Esempio n. 2
0
 public static CVehicleExtend GetExtension(this GTANetworkAPI.Vehicle vehicle)
 {
     if (!vehicle.HasData("extension"))
     {
         vehicle.AddExtension();
     }
     return(vehicle.GetData("extension"));
 }
 public void OnPlayerEnterVehicle(Client player, GTANetworkAPI.Vehicle vehicle, sbyte seatId)
 {
     if (vehicle.GetVehicleEntity() is VehicleEntity vehicleEntity)
     {
         PlayerEnterVehicleEventArgs eventArgs = new PlayerEnterVehicleEventArgs(vehicleEntity, seatId);
         vehicleEntity.InvokePlayerEnterVehicle(player.GetAccountEntity().CharacterEntity, eventArgs);
         player.TriggerEvent(RemoteEvents.OnPlayerEnterVehicle, vehicle, seatId);
     }
 }
Esempio n. 4
0
        public void Event_ExitVehicleAttempt(Client player, Vehicle veh)
        {
            NAPI.ClientEvent.TriggerClientEvent(player, "client.vegicle.mileage.forceRequest");
            NAPI.ClientEvent.TriggerClientEvent(player, "client.vehicle-speedometer.toggle", false);
            NAPI.ClientEvent.TriggerClientEvent(player, "client.vehicle-speedometer.toggle", false);
            NAPI.ClientEvent.TriggerClientEvent(player, "client.vehicle.mileage.remove");
            Character charData = Account.GetPlayerData(player);

            charData.VehicleTimer.Dispose();
        }
Esempio n. 5
0
 public void CmdFixMyCar(Client player)
 {
     if (player.IsInVehicle)
     {
         Vehicle veh = player.Vehicle;
         veh.Health = 100.0f;
         veh.Repair();
         player.SendChatMessage("Your vehicle has been fixed.");
     }
 }
Esempio n. 6
0
 public static bool Save(this GTANetworkAPI.Vehicle vehicle)
 {
     if (vehicle.IsType(EVehicleType.PRIVATE))
     {
         if (vehicle.UID() != null)
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 7
0
        public bool Destroy(Vehicle vehicle, bool clearing = false)
        {
            if (vehicle == null)
            {
                return(false);
            }

            EVehicleType type = vehicle.GetVehicleType();

            vehicles[type].Remove(vehicle);

            switch (type)
            {
            case EVehicleType.UNKNOWN:

                break;

            case EVehicleType.PRIVATE:
                vehicle.Save();
                break;

            case EVehicleType.FRACTION:

                break;

            case EVehicleType.WORK:

                break;

            case EVehicleType.PUBLIC:
                //Globals.Systems.publicVehicles.RemovePublicVehicle(vehicle, clearing);
                break;

            case EVehicleType.EXAM:

                break;

            case EVehicleType.SALON:

                break;

            case EVehicleType.EVENT:

                break;
            }

            if (vehicle != null)
            {
                NAPI.Entity.DeleteEntity(vehicle);
            }

            return(true);
        }
Esempio n. 8
0
        void spawnveh(Client player, uint vid)
        {
            Vehicle veh = Globals.Managers.vehicle.SpawnPrivateVehicle(vid, player.GetPositionAtFront(5), new Vector3(0, 0, 0));

            if (veh != null)
            {
                player.SendChatMessage("stworzono pojazd {0} vid {1}", veh, veh.UID());
            }
            else
            {
                player.SendChatMessage("nie udało się stworzyć pojazdu");
            }
        }
        public void ToggleIndicatorRightHandler(Client player, params object[] arguments)
        {
            GTANetworkAPI.Vehicle veh = NAPI.Player.GetPlayerVehicle(player);
            int     indicator         = 0;
            Vector3 pos = NAPI.Entity.GetEntityPosition(player);

            if (NAPI.Data.HasEntitySharedData(veh, "indicator_right") && NAPI.Data.GetEntitySharedData(veh, "indicator_right") == true)
            {
                NAPI.Data.ResetEntitySharedData(veh, "indicator_right");
                NAPI.Native.SendNativeToPlayersInRange(pos, 500f, 0xB5D45264751B7DF0, veh, indicator, false);
            }
            else
            {
                NAPI.Data.SetEntitySharedData(veh, "indicator_right", true);
                NAPI.Native.SendNativeToPlayersInRange(pos, 500f, 0xB5D45264751B7DF0, veh, indicator, true);
            }
        }
Esempio n. 10
0
        public void EventVehicleDamage(Vehicle veh, float bodyHealthLoss, float engineHealthLoss)
        {
            Database.Models.Vehicle vehData = Library.GetVehicleData(veh);
            if (vehData == null)
            {
                return;
            }

            vehData.Health = veh.Health;

            Character driver = Library.GetDriver(veh);

            if (driver != null)
            {
                Player.SendFormattedChatMessage(driver.PlayerHandle,
                                                $"Uszkodziłeś pojazd (body: {bodyHealthLoss:F2} engine: {engineHealthLoss:F2})");
            }
        }
Esempio n. 11
0
        public Vehicle Create(EVehicleType type, VehicleHash vehicleHash, Vector3 pos, Vector3 rot)
        {
            Vehicle vehicle = NAPI.Vehicle.CreateVehicle(vehicleHash, pos, rot, new Color(255, 255, 255).ToInt32(), new Color(255, 255, 255).ToInt32());

            vehicle.AddExtension();
            vehicle.SetVehicleType(type);
            vehicle.SetSharedData("type", type);
            vehicles[type].Add(vehicle);
            switch (type)
            {
            case EVehicleType.UNKNOWN:

                break;

            case EVehicleType.PRIVATE:

                break;

            case EVehicleType.FRACTION:

                break;

            case EVehicleType.WORK:

                break;

            case EVehicleType.PUBLIC:

                break;

            case EVehicleType.EXAM:

                break;

            case EVehicleType.SALON:

                break;

            case EVehicleType.EVENT:

                break;
            }
            return(vehicle);
        }
Esempio n. 12
0
        public void Event_ExitVehicle(Client player, Vehicle veh)
        {
            Database.Models.Vehicle vehData = Library.GetVehicleData(veh);
            if (vehData == null)
            {
                return;
            }

            foreach (Client entry in NAPI.Pools.GetAllPlayers())
            {
                NAPI.ClientEvent.TriggerClientEvent(entry, "client.vehicle.engine", vehData.VehicleHandle.Value,
                                                    vehData.Engine);
            }

            vehData.Health = vehData.VehicleHandle.Health;
            vehData.Save();

            // TODO: Log
        }
Esempio n. 13
0
        public void Event_EnterVehicleAttempt(Client player, Vehicle veh, sbyte seatId)
        {
            Database.Models.Vehicle vehData = Library.GetVehicleData(veh);
            if (vehData == null)
            {
                return;
            }
            Character charData = Account.GetPlayerData(player);

            if (charData == null)
            {
                return;
            }

            foreach (Client entry in NAPI.Pools.GetAllPlayers())
            {
                NAPI.ClientEvent.TriggerClientEvent(entry, "client.vehicle.engine", vehData.VehicleHandle.Value,
                                                    vehData.Engine);
            }
        }
Esempio n. 14
0
        public void OnPlayerEnterVehicle(Client player, Vehicle vehicle, sbyte seatID)
        {
            EVehicleType type = vehicle.GetVehicleType();

            switch (type)
            {
            case EVehicleType.UNKNOWN:

                break;

            case EVehicleType.PRIVATE:

                break;

            case EVehicleType.FRACTION:

                break;

            case EVehicleType.WORK:

                break;

            case EVehicleType.PUBLIC:
                //Globals.Systems.publicVehicles.OnPlayerEnterPublicVehicle(player, vehicle, seatID);
                break;

            case EVehicleType.EXAM:

                break;

            case EVehicleType.SALON:

                break;

            case EVehicleType.EVENT:

                break;
            }
        }
Esempio n. 15
0
        private void VehicleDeath(GTANetworkAPI.Vehicle vehicle)
        {
            var    model  = vehicle.Model;
            Client client = vehicle.GetSharedData("IsOwnedBy");

            Log($"Vehicle died {model}, belonging to {client.Name}");

            var driver = Drivers?.FirstOrDefault(x => x.Client == client);

            if (driver != null)
            {
                driver.DeleteVehicle(vehicle);
                SpawnCar(client, model, client.Position);
            }
            else
            {
                Log($"No driver found, removing vehicle no respawn");
                if (!vehicle.IsNull)
                {
                    vehicle.Delete();
                }
            }
        }
Esempio n. 16
0
        public void Veh(Client player, string vehicleName = "")
        {
            if (player.HasData("PERSONAL_VEHICLE"))
            {
                Entity veh = player.GetData("PERSONAL_VEHICLE");
                veh.Delete();
                player.ResetData("PERSONAL_VEHICLE");
            }

            VehicleHash vehHash = NAPI.Util.VehicleNameToModel(vehicleName);

            if (vehHash.ToString().Equals("0"))
            {
                return;
            }
            Vehicle v = NAPI.Vehicle.CreateVehicle(vehHash, player.Position.Around(5), 0f, 0, 0);

            v.NumberPlate      = "STATIQUE";
            v.WindowTint       = 5;
            v.NumberPlateStyle = 2;
            player.SetData("PERSONAL_VEHICLE", v);
            NAPI.Chat.SendChatMessageToPlayer(player, "Spawned a " + vehicleName + ".");
        }
Esempio n. 17
0
        public void Event_EnterVehicle(Client player, Vehicle veh, sbyte seatId)
        {
            Database.Models.Vehicle vehData = Library.GetVehicleData(veh);
            if (vehData == null)
            {
                return;
            }

            if (seatId == -1)
            {
                Character charData = Account.GetPlayerData(player);
                if (charData == null)
                {
                    player.Kick("No login.");
                    return;
                }

                if (!Library.DoesPlayerHasVehiclePerm(charData, vehData.Id))
                {
                    Ui.ShowWarning(player, "Nie posiadasz uprawnień do prowadzenia tego pojazdu.");
                    return;
                }

                // TODO: penalty
                NAPI.ClientEvent.TriggerClientEvent(player, "client.vehicle.mileage.add", (float)vehData.Mileage);
                NAPI.ClientEvent.TriggerClientEvent(player, "client.vehicle-speedometer.toggle", true);
                charData.VehicleTimer          = new System.Timers.Timer(500);
                charData.VehicleTimer.Elapsed += (sender, args) =>
                {
                    NAPI.ClientEvent.TriggerClientEvent(player, "client.vehicle-speedometer.refresh",
                                                        (float)(vehData.Fuel / vehData.MaxFuel) * 100);
                };
                charData.VehicleTimer.Start();
                // TODO: log
            }
        }
Esempio n. 18
0
 public static Client Owner(this GTANetworkAPI.Vehicle vehicle)
 {
     return(vehicle.GetExtension().Owner());
 }
Esempio n. 19
0
 public static uint OwnerPID(this GTANetworkAPI.Vehicle vehicle)
 {
     return(vehicle.GetExtension().OwnerPID());
 }
Esempio n. 20
0
 public static void SetOwner(this GTANetworkAPI.Vehicle vehicle, Client player)
 {
     vehicle.GetExtension().SetOwner(player);
 }
Esempio n. 21
0
 public void OnPlayerEnterVehicle(Client player, Vehicle vehicle, sbyte seatID)
 {
     Globals.Managers.vehicle.OnPlayerEnterVehicle(player, vehicle, seatID);
 }
Esempio n. 22
0
 public static void SetOwner(this GTANetworkAPI.Vehicle vehicle, uint pid)
 {
     vehicle.GetExtension().SetOwner(pid);
 }
Esempio n. 23
0
 public CVehicleExtend(GTANetworkAPI.Vehicle vehicle)
 {
     this.vehicle = vehicle;
 }
Esempio n. 24
0
 public static bool IsType(this GTANetworkAPI.Vehicle vehicle, EVehicleType eType)
 {
     return(vehicle.GetVehicleType() == eType);
 }
Esempio n. 25
0
        public static void AddExtension(this GTANetworkAPI.Vehicle vehicle)
        {
            CVehicleExtend extension = new CVehicleExtend(vehicle);

            vehicle.SetData("extension", extension);
        }
Esempio n. 26
0
 public static void SafeDelete(this GTANetworkAPI.Vehicle vehicle)
 {
     Globals.Managers.vehicle.Destroy(vehicle);
 }
Esempio n. 27
0
 public static EVehicleType GetVehicleType(this GTANetworkAPI.Vehicle vehicle)
 {
     return(vehicle.GetExtension().GetVehicleType());
 }
Esempio n. 28
0
 public static void SetVehicleType(this GTANetworkAPI.Vehicle vehicle, EVehicleType newType)
 {
     vehicle.GetExtension().SetVehicleType(newType);
 }