Пример #1
0
 public void Execute(IRocketPlayer caller, string[] command)
 {
     //Requires PlayerInfoLib to work, if not loaded time won't be tracked
     if (RocketPlugin.IsDependencyLoaded("PlayerInfoLib"))
     {
         int    totalSeconds = PlayerInfoLib.Database.QueryById(UnturnedPlayer.FromName(caller.DisplayName).CSteamID, true).TotalPlayime;
         string str          = "";
         if (totalSeconds >= 86400)
         {
             int num = totalSeconds / 86400;
             str = string.Concat(num.ToString(), "d ");
         }
         if (totalSeconds >= 3600)
         {
             int num1 = totalSeconds / 3600 % 24;
             str = string.Concat(str, num1.ToString(), "h ");
         }
         if (totalSeconds >= 60)
         {
             int num2 = totalSeconds / 60 % 60;
             str = string.Concat(str, num2.ToString(), "m ");
         }
         int num3 = totalSeconds % 60;
         str = string.Concat(str, num3.ToString(), "s");
         TranslationList translationLists = UTools.Instance.Translations.Instance;
         object[]        objArray         = new object[] { str };
         UnturnedChat.Say(caller, translationLists.Translate("total_playtime", objArray), Color.yellow);
     }
     else
     {
         UnturnedChat.Say(caller, "Playtime is not being tracked!", Color.yellow);
     }
 }
        private void ExecuteFeatures(RocketPlayer player, Package features, string itemName, bool wasAlready)
        {
            if (features.Commands != null && features.Commands.Length > 0)
            {
                foreach (var command in features.Commands)
                {
                    R.Commands.Execute(new ConsolePlayer(), command.Replace("{steamid}", player.Id).Replace("{steamname}", player.DisplayName));
                }
            }

            if (features.AddGroups != null && features.AddGroups.Length > 0)
            {
                foreach (var group in features.AddGroups)
                {
                    R.Permissions.AddPlayerToGroup(group, player);
                }
            }

            if (features.RemoveGroups != null && features.RemoveGroups.Length > 0)
            {
                foreach (var group in features.RemoveGroups)
                {
                    R.Permissions.RemovePlayerFromGroup(group, player);
                }
            }

            if (features.UconomyMoney > 0)
            {
                if (pluginInstance.Configuration.Instance.PayUconomyMoneyOnce && wasAlready)
                {
                    Logger.LogWarning("Uconomy money was already paid, skipping.");
                }
                else
                {
                    if (RocketPlugin.IsDependencyLoaded("Uconomy"))
                    {
                        // using helper to avoid depdency error message in case uconomy not installed
                        UconomyHelper.PayMoney(player.Id, features.UconomyMoney);
                    }
                    else
                    {
                        Logger.LogWarning($"Failed to pay {features.UconomyMoney} money to {player.DisplayName} {player.Id}, because Uconomy is not installed");
                    }
                }
            }

            if (!features.DisableBroadcast && player.DisplayName != null)
            {
                UnturnedChat.Say(pluginInstance.Translate("PurchaseBroadcast", player.DisplayName, itemName), pluginInstance.MessageColor);
            }
        }