Пример #1
0
        /// <summary>
        /// Проверяет, что транспорт брошен
        /// </summary>
        public static bool IsAfk(Vehicle vehicle, int maxAfkMinutes)
        {
            if (!vehicle.hasData(VehicleEventsManager.AFK_KEY))
            {
                return(false);
            }
            var afkPeriod = DateTime.Now - (DateTime)vehicle.getData(VehicleEventsManager.AFK_KEY);

            return(afkPeriod.TotalMinutes >= maxAfkMinutes);
        }
Пример #2
0
        /// <summary>
        /// Восстановить начальную позицию транспорта
        /// </summary>
        public void RestorePosition(Vehicle vehicle)
        {
            var info   = (CommonVehicle)vehicle.getData(VEHICLE_INFO_KEY);
            var driver = API.getVehicleDriver(vehicle);

            if (vehicle.hasData(DONT_RESTORE) || OnRespawnAndCorrect(vehicle, info.SpawnPosition) || driver != null)
            {
                return;
            }
            if (vehicle.hasData(VehicleEventsManager.AFK_KEY) && !IsAfk(vehicle, 20))
            {
                return;
            }
            vehicle.delete();
            CreateVehicle(info);
        }