Advertisement
Guest User

Untitled

a guest
Feb 18th, 2023
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.69 KB | None | 0 0
  1.             public void Set(ulong userid, RaidableMode mode)
  2.             {
  3.                 if (userid.HasPermission("raidablebases.buyraid.bypass.cooldown"))
  4.                 {
  5.                     return;
  6.                 }
  7.  
  8.                 var diff = mode == RaidableMode.Easy ? Easy : mode == RaidableMode.Medium ? Medium : mode == RaidableMode.Hard ? Hard : mode == RaidableMode.Expert ? Expert : Nightmare;
  9.  
  10.                 if (diff.Cooldown <= 0)
  11.                 {
  12.                     return;
  13.                 }
  14.  
  15.                 var cooldowns = new List<double>() { diff.Cooldown };
  16.                 var player = BasePlayer.FindByID(userid);
  17.  
  18.                 if (player.IsReallyValid())
  19.                 {
  20.                     if (player.IsFlying)
  21.                     {
  22.                         player.ChatMessage("FLYING"); return;
  23.                     }
  24.  
  25.                     if (player.IsAdmin || player.IsDeveloper)
  26.                     {
  27.                         player.ChatMessage("ADMIN/DEV"); cooldowns.Add(diff.Admin);
  28.                     }
  29.                 }
  30.  
  31.                 if (userid.HasPermission("raidablebases.vipcooldown"))
  32.                 {
  33.                     player.ChatMessage("VIP"); cooldowns.Add(diff.VIP);
  34.                 }
  35.  
  36.                 if (userid.HasPermission("raidablebases.allow"))
  37.                 {
  38.                     player.ChatMessage("ALLOW"); cooldowns.Add(diff.Allow);
  39.                 }
  40.  
  41.                 double cooldown = double.MaxValue;
  42.                
  43.                 foreach (double value in cooldowns)
  44.                 {
  45.                     if (value < cooldown)
  46.                     {
  47.                         cooldown = value;
  48.                     }
  49.                 }
  50.  
  51.                 if (cooldown <= 0)
  52.                 {
  53.                     player.ChatMessage("NO COOLDOWN SET");
  54.                     return;
  55.                 }
  56.                
  57.                 player.ChatMessage("COOLDOWN APPLIED");
  58.  
  59.                 BuyableInfo bi;
  60.                 if (!data.BuyableCooldowns.TryGetValue(userid, out bi))
  61.                 {
  62.                     data.BuyableCooldowns[userid] = bi = new BuyableInfo();
  63.                 }
  64.  
  65.                 string expiredDate = DateTime.Now.AddSeconds(cooldown).ToString();
  66.  
  67.                 switch (mode)
  68.                 {
  69.                     case RaidableMode.Easy: bi.Easy = expiredDate; break;
  70.                     case RaidableMode.Medium: bi.Medium = expiredDate; break;
  71.                     case RaidableMode.Hard: bi.Hard = expiredDate; break;
  72.                     case RaidableMode.Expert: bi.Expert = expiredDate; break;
  73.                     case RaidableMode.Nightmare: bi.Nightmare = expiredDate; break;
  74.                 }
  75.             }
  76.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement