Beispiel #1
0
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj))
            {
                return(false);
            }
            if (ReferenceEquals(this, obj))
            {
                return(true);
            }
            if (obj.GetType() != GetType())
            {
                return(false);
            }

            /*
             *  TODO; Improve
             */
            return(RocketPlayer.Equals(((UPlayer)obj).RocketPlayer));
        }
Beispiel #2
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);
                }
            }
        }