コード例 #1
0
ファイル: Sales.cs プロジェクト: a1exliang/LPX
        public void startSale()
        {
            LIGHT sale = LIGHT.Instance;

            SaleTime    = DateTime.Now;
            salesStart  = true;
            SaleEndTime = SaleTime.AddMinutes(sale.Configuration.Instance.SaleTime);
        }
コード例 #2
0
ファイル: Sales.cs プロジェクト: a1exliang/LPX
        public void checkSale()
        {
            LIGHT sale = LIGHT.Instance;

            if (!salesStart)
            {
                if ((nextSale - DateTime.Now).Seconds <= 60 && (DateTime.Now - lastMsg).Seconds >= 60)
                {
                    UnturnedChat.Say("Sale is starting in 1 minute");
                    lastMsg = DateTime.Now;
                }
                if ((nextSale - DateTime.Now).TotalSeconds <= b && (DateTime.Now - lastMsg).TotalSeconds >= 1)
                {
                    if (b != 0)
                    {
                        UnturnedChat.Say(LIGHT.Instance.Translate("sale_start", b));
                        lastMsg = DateTime.Now;
                        b      -= (byte)1;
                    }
                    else if (!salesStart)
                    {
                        UnturnedChat.Say(LIGHT.Instance.Translate("sale_started", sale.Configuration.Instance.SaleTime));
                        lastMsg = DateTime.Now;
                        startSale();
                        Logger.LogWarning("Sales have started");
                    }
                }
            }
            if (salesStart)
            {
                b = 3;
                if ((SaleEndTime - DateTime.Now).TotalMinutes <= 1 && (SaleEndTime - DateTime.Now).TotalSeconds > 59 && (DateTime.Now - lastMsg).Seconds >= 60)
                {
                    UnturnedChat.Say(LIGHT.Instance.Translate("sale_ending", 1, "minute"));
                    lastMsg = DateTime.Now;
                }
                if ((SaleEndTime - DateTime.Now).TotalSeconds <= 10 && (SaleEndTime - DateTime.Now).TotalSeconds > 9 && (DateTime.Now - lastMsg).Seconds >= 10)
                {
                    UnturnedChat.Say(LIGHT.Instance.Translate("sale_ending", 10, "seconds"));
                    lastMsg = DateTime.Now;
                }
                if ((SaleEndTime - DateTime.Now).TotalSeconds <= 5 && (SaleEndTime - DateTime.Now).TotalSeconds > 4 && (DateTime.Now - lastMsg).Seconds >= 5)
                {
                    UnturnedChat.Say(LIGHT.Instance.Translate("sale_ending", 5, "seconds"));
                    lastMsg = DateTime.Now;
                }
                if (DateTime.Now >= SaleEndTime)
                {
                    UnturnedChat.Say(LIGHT.Instance.Translate("sale_end"));
                    Logger.LogWarning("Sales have ended");
                    lastMsg = DateTime.Now;
                    resetSale();
                }
            }
        }
コード例 #3
0
ファイル: Sales.cs プロジェクト: a1exliang/LPX
        public void msgSale(IRocketPlayer call)
        {
            LIGHT    sale  = LIGHT.Instance;
            TimeSpan time  = nextSale - DateTime.Now;
            double   timeD = Math.Round(time.TotalMinutes, 1);

            if (time.TotalMinutes >= 1.0 && !salesStart)
            {
                UnturnedChat.Say(call, "The next sale will start in " + timeD + " Minutes");
            }
            else if (time.TotalMinutes < 1 && !salesStart)
            {
                UnturnedChat.Say(call, "The next sale will start in " + (Math.Round(time.TotalSeconds)) + " Seconds");
            }
            else if (time.TotalSeconds <= 0 && salesStart)
            {
                UnturnedChat.Say("Sale have already started");
            }
            return;
        }
コード例 #4
0
ファイル: LIGHT.cs プロジェクト: TrueThat/LPX
 protected override void Load()
 {
     LastVehicleCheck = DateTime.Now;
     Instance         = this;
     if (LIGHT.Instance.Configuration.Instance.EnableShop)
     {
         ShopDB = new DatabaseManagerShop();
     }
     OriginalPermissions = R.Permissions;
     if (LIGHT.Instance.Configuration.Instance.LPXEnabled)
     {
         SQLPermission permission = new SQLPermission();
         R.Permissions = permission;
         U.Events.OnPlayerConnected    += RocketServerEvents_OnPlayerConnected;
         U.Events.OnPlayerDisconnected += RocketServerEvents_OnPlayerDisconnected;
     }
     Database    = new DatabaseManager();
     DatabaseCar = new DatabaseCar();
     if (LIGHT.Instance.Configuration.Instance.KitsEnabled && LIGHT.Instance.Configuration.Instance.KitCooldownResetOnDeath)
     {
         UnturnedPlayerEvents.OnPlayerDead += RocketServerEvents_OnPlayerDead;
     }
     if (LIGHT.Instance.Configuration.Instance.AllowAuction)
     {
         DatabaseAuction = new DatabaseManagerAuction();
     }
     if (LIGHT.Instance.Configuration.Instance.AutoRemoveEnabled)
     {
         LIGHT.Instance.Database.AutoRemove();
     }
     if (LIGHT.Instance.Configuration.Instance.AllowCarOwnerShip)
     {
         UnturnedPlayerEvents.OnPlayerUpdateStance += OnPlayerUpdateStance;
     }
     if (LIGHT.Instance.Configuration.Instance.SaleEnable && LIGHT.Instance.Configuration.Instance.EnableShop)
     {
         sale = new Sales();
         sale.resetSale();
     }
     if (LIGHT.Instance.Configuration.Instance.EnableShop && LIGHT.Instance.Configuration.Instance.EnableAutoDBUpdate)
     {
         ItemAsset ia;
         Logger.Log("Loading Item Database...", ConsoleColor.Yellow);
         for (ushort x = 0; x < 60000; x++)
         {
             try
             {
                 ia = (ItemAsset)Assets.find(EAssetType.ITEM, x);
                 if (ia.itemName != "" && ia.itemName != " ")
                 {
                     LIGHT.Instance.ShopDB.AutoAddItem((int)ia.id, ia.Name, LIGHT.Instance.ShopDB.CheckItemExist(x));
                 }
                 LIGHT.Instance.ShopDB.DeleteEmptyItemRow(x);
                 if (x == 500)
                 {
                     Logger.Log("We are halfway there...", ConsoleColor.Yellow);
                 }
             }
             catch
             {
                 LIGHT.Instance.ShopDB.DeleteItem(x);
             }
         }
         Logger.Log("Item Database Updated!", ConsoleColor.Yellow);
         VehicleAsset va;
         Logger.Log("Loading Vehicle Database...", ConsoleColor.Yellow);
         for (ushort x = 0; x < 20000; x++)
         {
             try
             {
                 va = (VehicleAsset)Assets.find(EAssetType.VEHICLE, x);
                 if (va.vehicleName != "" && va.vehicleName != " ")
                 {
                     LIGHT.Instance.ShopDB.AutoAddVehicle((int)va.id, va.vehicleName, LIGHT.Instance.ShopDB.CheckVehicleExist(x));
                 }
                 LIGHT.Instance.ShopDB.DeleteEmptyVehicleRow(x);
                 if (x == 50)
                 {
                     Logger.Log("Should be quick...", ConsoleColor.Yellow);
                 }
             }
             catch
             {
                 LIGHT.Instance.ShopDB.DeleteVehicle(x);
             }
         }
         Logger.Log("Vehicle Database Updated!", ConsoleColor.Yellow);
     }
 }