コード例 #1
0
        internal void listPlayers(RocketPlayer caller)
        {
            if (players.Count == 0)
            {
                RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_player_list_clear"));
                return;
            }
            else
            {
                string playersString = "";

                foreach (KeyValuePair <string, Sentence> player in players)
                {
                    try { playersString += RocketPlayer.FromName(player.Key).CharacterName + " (" + player.Value.Cell.Name + "), "; }
                    catch { }
                }

                if (playersString != "")
                {
                    playersString = playersString.Remove(playersString.Length - 2) + ".";
                }

                RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_player_list", playersString));
                return;
            }
        }
コード例 #2
0
        internal void removePlayer(RocketPlayer caller, string playerName)
        {
            RocketPlayer target;

            try
            {
                target = RocketPlayer.FromCSteamID(new CSteamID(Convert.ToUInt64(playerName)));
            }
            catch
            {
                target = RocketPlayer.FromName(playerName);
            }

            if (target != null && players.ContainsKey(target.ToString()))
            {
                removePlayerFromJail(target, players[target.ToString()]);
                RocketChat.Say(target, JailTime.Instance.Translate("jailtime_player_release_msg"));

                if (caller != null)
                {
                    RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_player_released", target.CharacterName));
                }
                players.Remove(target.ToString());
            }
            else
            {
                if (caller != null)
                {
                    RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_player_notfound", playerName));
                }
                return;
            }
        }
コード例 #3
0
        // Player Methods

        internal void addPlayer(RocketPlayer caller, string playerName, string jailName = "", uint jailTime = 0)
        {
            Cell         jail;
            RocketPlayer target = RocketPlayer.FromName(playerName);

            if (jailTime == 0)
            {
                jailTime = Configuration.JailTimeInSeconds;
            }

            if (target == null)
            {
                RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_player_notfound", jailName));
                return;
            }
            else if (players.ContainsKey(target.ToString()))
            {
                RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_player_in_jail", target.CharacterName));
                return;
            }
            else
            {
                if (target.IsAdmin || target.Permissions.Contains("jail.immune"))
                {
                    RocketChat.Say(target, JailTime.Instance.Translate("jailtime_player_immune"));
                    return;
                }
                else if (cells.Count == 0)
                {
                    RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_jail_notset", jailName));
                    return;
                }
                else if (jailName == "")
                {
                    jail = getRandomCell();
                }
                else
                {
                    jail = getCellbyName(jailName);
                }

                if (jail == null)
                {
                    RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_jail_notfound", jailName));
                    return;
                }

                players.Add(target.ToString(), new Sentence(jail, jailTime, target.Position));
                movePlayerToJail(target, jail);
                target.GiveItem(303, 1);
                target.GiveItem(304, 1);

                RocketChat.Say(target, JailTime.Instance.Translate("jailtime_player_arrest_msg", jailTime));
                RocketChat.Say(caller, JailTime.Instance.Translate("jailtime_player_arrested", target.CharacterName, jail.Name));
            }
        }
コード例 #4
0
        private void DoQueuedUpdateCommands()
        {
            if (reloadCalled)       //Reload settings if called.
            {
                this.ReloadConfiguration();
                GetSettings();
                BuildProfessionWeighedList();
                logHelper.LogMessage(LogHelper.MESSAGELEVEL_WARNING, "Configuration Reloaded! Any active changes not saved.");
                reloadCalled = false;
            }

            if (adminGiveRequested)       //Admin gives kit TODO: CLEANUP

            {
                SteamPlayer steamPlayer;

                if (PlayerTool.tryGetSteamPlayer(givePlayerName, out steamPlayer) && DoesKitExist(giveKitName))           //If steam playername is found.
                {
                    ClearInventory(RocketPlayer.FromName(givePlayerName));
                    GivePlayerKit(RocketPlayer.FromName(givePlayerName), giveKitName, true);
                    logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "Admin gave " + givePlayerName + " the " + giveKitName + " kit.");
                }
                else
                {
                    logHelper.LogMessage(LogHelper.MESSAGELEVEL_WARNING, "givekit: no such player or kit.");
                }

                adminGiveRequested = false;
            }

            if (saveCalled)
            {
                ApplySettings();
                this.Configuration.Save();
                logHelper.LogMessage(LogHelper.MESSAGELEVEL_WARNING, "Configuration written to disk.");
                saveCalled = false;
            }
        }
コード例 #5
0
ファイル: GearUpCommand.cs プロジェクト: Zamirathe/MashTools
        public void Execute(RocketPlayer player, string[] cmd)
        {
            if (!Initialized)
            {
                Initialize();
            }

            if (player == null)
            {
                return;
            }

            if (!Config.AllowCmd)
            {
                Say(player, GearUp.TDict["command_disabled"]?.ToString(), Config.ErrorColor);
                Log("GU: Commands are disabled.");
                return;
            }

            PERM perms = GetPermLevel(player);

            try {
                if (perms <= PERM.None && string.Join("", cmd) != "-info")
                {
                    Say(player, GearUp.TDict["access_denied"]?.ToString(), Color.red);
                    return;
                }

                if (cmd.Length == 0 && perms >= PERM.Self)
                {
                    player.GetComponent <GearUpComp>()?.AskGearUp();
                    return;
                }

                if (cmd.Length >= 1)
                {
                    if (!cmd[0].StartsWith("-"))
                    {
                        RocketPlayer pFromCmd = RocketPlayer.FromName(cmd[0]);
                        Kit          kFromCmd = GetKitByName(cmd[0]);

                        // kit
                        if (kFromCmd != null && perms >= PERM.Self)
                        {
                            player.GetComponent <GearUpComp>()?.AskGearUp(null, kFromCmd);
                            return;
                        }

                        // player
                        if (pFromCmd != null && perms >= PERM.Other)
                        {
                            if (cmd.Length >= 2)
                            {
                                kFromCmd = GetKitByName(cmd[1]);
                                if (kFromCmd != null)
                                {
                                    pFromCmd.GetComponent <GearUpComp>()?.AskGearUp(player, kFromCmd);
                                    //Say(player, $"{GearUp.TDict["gear_gift_success"]?.Replace("%P", pFromCmd.CharacterName)}", Config.SuccessColor);
                                    return;
                                }
                                else
                                {
                                    Say(player, $"{GearUp.TDict["access_denied_gift"]?.ToString()}", Config.ErrorColor);
                                    return;
                                }
                            }
                            else
                            {
                                Say(player, $"{GearUp.TDict["error_user_nokit"]?.ToString()}", Config.ErrorColor);
                                return;
                            }
                        }

                        // neither; bad user, no biscuit! D:<
                        Say(player, $"No matching kits or players, kits: ", Config.ErrorColor);
                        ReportPermittedKits(player);
                        return;
                    }
                    else if (cmd[0].StartsWith("-"))
                    {
                        switch (cmd[0])
                        {
                        case "-on":
                            if ((int)perms < (int)PERM.Admin)
                            {
                                return;
                            }
                            GearUp.Instance.enabled = true;
                            Say(player, "GU: Enabled", Config.SuccessColor);
                            break;

                        case "-off":
                            if ((int)perms < (int)PERM.Admin)
                            {
                                return;
                            }
                            GearUp.Instance.enabled = false;
                            Say(player, "GU: Disabled", Config.SuccessColor);
                            break;

                        case "-kits":
                        case "-list":
                        case "-l":
                            ReportPermittedKits(player);
                            break;

                        case "-?":
                            if ((int)perms < (int)PERM.Info)
                            {
                                return;
                            }
                            ShowHelp(player);
                            break;

                        case "--":
                            if ((int)perms < (int)PERM.Info)
                            {
                                return;
                            }
                            Say(player, $"GU: Plugin {(GearUp.Instance.enabled == true ? "enabled" : "disabled")}.", Color.gray);
                            break;

                        case "-reset":
                            if ((int)perms < (int)PERM.Admin)
                            {
                                return;
                            }
                            if (cmd.Length >= 2)
                            {
                                if (!string.IsNullOrEmpty(cmd[1]))
                                {
                                    RocketPlayer p = RocketPlayer.FromName(cmd[1]);
                                    if (p == null)
                                    {
                                        Say(player, $"GU: Failed to find player name matching '{cmd[1]}'!", Config.ErrorColor);
                                    }
                                    else
                                    {
                                        p.GetComponent <GearUpComp>()?.ResetCooldown(player);
                                    }
                                }
                            }
                            else
                            {
                                player.GetComponent <GearUpComp>()?.ResetCooldown();
                            }
                            break;

                        case "-info":
                            Say(player, $"GearUp {GearUp.Version} by Mash - Auria.pw [{(GearUp.Instance.enabled == true ? "enabled" : "disabled")}]", Config.InfoColor);
                            break;

                        default:
                            Say(player, "GU: Unknown operand", Config.ErrorColor);
                            break;
                        }
                        return;
                    }
                }
            } catch (Exception ex) {
                GearUp.STOP(ex.Message);
            }
        }
コード例 #6
0
        internal void Give(RocketPlayer caller, string kitId, string player, bool forceGive = false)
        {
            RocketPlayer target      = RocketPlayer.FromName(player);
            TextInfo     textInfo    = new CultureInfo("en-US", false).TextInfo;
            Kit          selectedKit = getKitByString(kitId);

            if (selectedKit == null)
            {
                RocketChat.Say(caller, GiveKit.Instance.Translate("command_givekit_kit_not_found", textInfo.ToTitleCase(kitId)));
                return;
            }
            else if (target == null)
            {
                RocketChat.Say(caller, GiveKit.Instance.Translate("command_givekit_player_not_found", textInfo.ToTitleCase(player)));
                return;
            }
            else
            {
                double gCD = getGlobalCooldown(caller);

                if (gCD > 0 && !caller.IsAdmin)
                {
                    RocketChat.Say(caller, GiveKit.Instance.Translate("command_givekit_cooldown_command", gCD));
                    return;
                }

                double kCD = getKitCooldown(caller, kitId);

                if (kCD > 0 && !caller.IsAdmin)
                {
                    RocketChat.Say(caller, GiveKit.Instance.Translate("command_givekit_cooldown_kit", kCD));
                    return;
                }

                if (caller.CSteamID == target.CSteamID)
                {
                    if (!forceGive && !(caller.IsAdmin || caller.Permissions.Contains("givekit." + kitId.ToLower()) || caller.Permissions.Contains("givekit.*")))
                    {
                        RocketChat.Say(caller, GiveKit.Instance.Translate("command_givekit_no_permissions_kit", kitId.ToLower()));
                        return;
                    }
                }
                else
                {
                    if (!(caller.IsAdmin || caller.Permissions.Contains("givekit.share") || caller.Permissions.Contains("givekit.*")))
                    {
                        RocketChat.Say(caller, GiveKit.Instance.Translate("command_givekit_no_permissions_share"));
                        return;
                    }
                }

                if (GiveKit.Instance.Configuration.StripBeforeGiving)
                {
                    target.Inventory.Clear();
                }
                foreach (KitItem item in selectedKit.Items)
                {
                    target.GiveItem(item.ItemId, item.Amount);
                }
                RocketChat.Say(caller, GiveKit.Instance.Translate("command_givekit_delivered_to_player", textInfo.ToTitleCase(kitId), target.CharacterName));
                if (!caller.Equals(target))
                {
                    RocketChat.Say(target, GiveKit.Instance.Translate("command_givekit_recieved_by_player", textInfo.ToTitleCase(kitId)));
                }
                if (!caller.IsAdmin && !caller.Permissions.Contains("givekit.nocooldown"))
                {
                    updateCooldowns(caller, selectedKit);
                }
            }
        }