Ejemplo n.º 1
0
 private void ReturnVehicle(DeliveryType aDeliveryType)
 {
     SetModelAsNoLongerNeeded((uint)m_delivery_vehicle.Handle);
     m_delivery_vehicle.Delete();
     Screen.ShowNotification(DeliveryData._U["DELIVERY_VEHICLE_RETURNED"]);
     FinishDelivery(aDeliveryType, SafeDepositReturn.YES);
 }
Ejemplo n.º 2
0
        private void ReturnVehicle(DeliveryType aDeliveryType)
        {
            var plate = GetVehicleNumberPlateText(m_delivery_vehicle.Handle);

            TriggerServerEvent("ft_carKeys:delJobKey", plate);
            SetModelAsNoLongerNeeded((uint)m_delivery_vehicle.Handle);
            m_delivery_vehicle.Delete();
            Screen.ShowNotification(DeliveryData._U["DELIVERY_VEHICLE_RETURNED"]);
            FinishDelivery(aDeliveryType, SafeDepositReturn.YES);
        }
Ejemplo n.º 3
0
 public void EndJob()
 {
     currentTowTruck?.Delete();
     currentTowTruck = null;
     currentJobVehicle?.AttachedBlips.ToList().ForEach(o => o.Delete());
     currentJobVehicle = null;
     JobHandler.SetDutyState(false);
     JobHandler.SetPlayerJob(JobType.Civillian);
     RemoveJobVehicle();
 }
Ejemplo n.º 4
0
        private void Update(Client client)
        {
            foreach (var trackedVehicle in this.Tracked.ToList())
            {
                var     vehicleHandle = NetToVeh(trackedVehicle.Item2);
                Vehicle citVeh        = new Vehicle(vehicleHandle);
                Player  player        = new Player(GetNearestPlayerToEntity(citVeh.Handle));

                if (player == client.LocalPlayer || !NetworkIsPlayerConnected(player.Handle))
                {
                    if (!(Vector3.Distance(client.LocalPlayer.Character.Position, citVeh.Position) >
                          VehicleLoadDistance))
                    {
                        continue;
                    }

                    citVeh.Delete();
                    this.Tracked.Remove(trackedVehicle);
                    BaseScript.TriggerServerEvent("igi:car:unclaim", trackedVehicle.Item2);
                }
                else
                {
                    var netId = NetworkGetNetworkIdFromEntity(citVeh.Handle);
                    //Debug.WriteLine($"Vehicle: {vehicleHandle} NetId: {netId} - {citVeh.Position}");

                    Car car = citVeh;
                    car.NetId = netId;

                    // Transfer the vehicle to the closest client
                    //Client.Log($"Removing Vehicle from tracked: {car.Handle}");
                    //this.Tracked.Remove(car.Handle ?? 0);

                    Client.Log($"Transfering vehicle to player: {player.ServerId}  -  {car.Handle}");
                    BaseScript.TriggerServerEvent(
                        "igi:car:transfer",
                        JsonConvert.SerializeObject(car),
                        player.ServerId);
                }
            }
        }
Ejemplo n.º 5
0
        private void Update()
        {
            foreach (Tuple <Type, int> trackedVehicle in this.Tracked.ToList())
            {
                int vehicleHandle = API.NetToVeh(trackedVehicle.Item2);
                var citVeh        = new CitizenFX.Core.Vehicle(vehicleHandle);
                var closestPlayer = new CitizenFX.Core.Player(API.GetNearestPlayerToEntity(citVeh.Handle));

                if (closestPlayer == Game.Player || !API.NetworkIsPlayerConnected(closestPlayer.Handle))
                {
                    if (!(Vector3.Distance(Game.Player.Character.Position, citVeh.Position) > VehicleLoadDistance))
                    {
                        continue;
                    }

                    citVeh.Delete();
                    this.Tracked.Remove(trackedVehicle);
                    Server.Event(RpcEvents.CarUnclaim)
                    .Attach(trackedVehicle.Item2)
                    .Trigger();
                }
                else
                {
                    int netId = API.NetworkGetNetworkIdFromEntity(citVeh.Handle);

                    Car car = (Car)citVeh;
                    car.NetId = netId;

                    Client.Log($"Transfering vehicle to player: {closestPlayer.ServerId}  -  {car.Handle}");
                    Server.Event(RpcEvents.CarTransfer)
                    .Attach(car)
                    .Attach(closestPlayer.ServerId)
                    .Trigger();
                }
            }
        }
Ejemplo n.º 6
0
        public static void SellVehicle(CitizenFX.Core.Vehicle veh)
        {
            if (Weather.Hour < 22 && Weather.Hour > 4)
            {
                Notification.SendWithTime("~r~Доступно только с 22 до 4 утра");
                return;
            }

            if (User.Data.sell_car_time > 0)
            {
                Notification.SendWithTime("~r~Вы не можете сейчас сбыть транспорт");
                Debug.WriteLine("sell_car_time: " + User.Data.sell_car_time);
                return;
            }

            int money = 100;

            if (Client.Sync.Data.HasLocally(User.GetServerId(), "sellCarTaskName"))
            {
                if ((string)Client.Sync.Data.GetLocally(User.GetServerId(), "sellCarTaskName") == veh.DisplayName)
                {
                    Client.Sync.Data.ResetLocally(User.GetServerId(), "sellCarTaskHash");
                    Client.Sync.Data.ResetLocally(User.GetServerId(), "sellCarTaskName");

                    money += 250;

                    switch (VehInfo.GetClassName(veh.Model.Hash))
                    {
                    case "Sports Classics":
                        money += 450;
                        break;

                    case "Sports":
                        money += 320;
                        break;

                    case "Super":
                        money += 280;
                        break;

                    case "SUVs":
                    case "Muscle":
                    case "Off-Road":
                        money += 250;
                        break;
                    }

                    veh.Delete();

                    User.AddCashMoney(money);
                    Notification.SendWithTime("~g~Вы заработали: $" + money);

                    User.Data.sell_car_time = 15;
                    Client.Sync.Data.Set(User.GetServerId(), "sell_car_time", User.Data.sell_car_time);
                    return;
                }
            }

            switch (VehInfo.GetClassName(veh.Model.Hash))
            {
            case "Emergency":
            case "Boats":
            case "Helicopters":
            case "Planes":
                Notification.SendWithTime("~r~Мы такое не принимаем");
                return;

            case "Sports Classics":
                money += 250;
                break;

            case "Sports":
                money += 220;
                break;

            case "Super":
                money += 180;
                break;

            case "SUVs":
            case "Muscle":
            case "Off-Road":
                money += 150;
                break;
            }

            veh.Delete();

            User.AddCashMoney(money);
            Notification.SendWithTime("~g~Вы заработали: $" + money);

            var pPos = GetEntityCoords(GetPlayerPed(-1), true);

            Main.SaveLog("Grab", $"[GRAB_CAR] {User.Data.rp_name} | {pPos.X} {pPos.Y} {pPos.Z} | ${money} | {VehInfo.GetDisplayName(veh.Model.Hash)} | {VehInfo.GetClassName(veh.Model.Hash)}");

            User.Data.sell_car_time = 30;
            Client.Sync.Data.Set(User.GetServerId(), "sell_car_time", User.Data.sell_car_time);
        }