Beispiel #1
0
        private bool SameClan(ulong playerID, ulong friendID)
        {
            if (Clans == null)
            {
                return(false);
            }
            //Clans
            var isMember = Clans.Call("IsClanMember", playerID.ToString(), friendID.ToString());

            if (isMember != null)
            {
                return((bool)isMember);
            }
            //Rust:IO Clans
            var playerClan = Clans.Call("GetClanOf", playerID);

            if (playerClan == null)
            {
                return(false);
            }
            var friendClan = Clans.Call("GetClanOf", friendID);

            if (friendClan == null)
            {
                return(false);
            }
            return((string)playerClan == (string)friendClan);
        }
Beispiel #2
0
        void RewardForPlayerKill(BasePlayer player, BasePlayer victim, double multiplier = 1)
        {
            if (rewardrates.human > 0)
            {
                bool success  = true;
                bool isFriend = false;
                if (IsFriendsLoaded)
                {
                    isFriend = (bool)Friends?.CallHook("HasFriend", player.userID, victim.userID);
                }
                if (!isFriend && IsClansLoaded)
                {
                    string pclan = (string)Clans?.CallHook("GetClanOf", player); string vclan = (string)Clans?.CallHook("GetClanOf", victim);
                    if (pclan == vclan)
                    {
                        isFriend = true;
                    }
                }
                if (!isFriend)
                {
                    var reward = rewardrates.human * multiplier;

                    if (IsEconomicsLoaded) //Eco
                    {
                        if (options.Economincs_TakeMoneyFromVictim)
                        {
                            if (!(bool)Economics?.Call("Transfer", victim.UserIDString, player.UserIDString, rewardrates.human * multiplier))
                            {
                                SendChatMessage(player, Lang("VictimNoMoney", player.UserIDString, victim.displayName), Lang("Prefix"));
                                success = false;
                            }
                        }
                        else
                        {
                            Economics?.Call("Deposit", player.UserIDString, reward);
                        }
                    }
                    if (IsServerRewardsLoaded) //ServerRewards
                    {
                        if (options.ServerRewards_TakeMoneyFromVictim)
                        {
                            ServerRewards?.Call("TakePoints", new object [] { victim.userID, rewardrates.human * multiplier });
                        }
                        ServerRewards?.Call("AddPoints", player.userID, (int)(reward));
                        success = true;
                    }
                    if (success) //Send message if transaction was successful
                    {
                        SendChatMessage(player, Lang("KillReward", player.UserIDString, rewardrates.human * multiplier, victim.displayName), Lang("Prefix"));
                        LogToFile(Name, $"[{DateTime.Now}] " + player.displayName + " got " + rewardrates.human * multiplier + " for killing " + victim.displayName, this);
                        if (options.PrintToConsole)
                        {
                            Puts(player.displayName + " got " + reward + " for killing " + victim.displayName);
                        }
                    }
                }
            }
        }
        private string GetClanOwner(string lol)
        {
            JObject claninfo = (JObject)Clans?.Call("GetClan", lol);

            string clanowner = (string)claninfo["owner"];

            return(clanowner);

            return(null);
        }
Beispiel #4
0
        private string GetPlayerName(IPlayer player)
        {
            string clanTag = Clans?.Call <string>("GetClanOf", player);

            if (!string.IsNullOrEmpty(clanTag))
            {
                clanTag = $"[{clanTag}] ";
            }

            return($"{clanTag}{player.Name}");
        }
        private string GetUsersClan(IPlayer player)
        {
            string clan = (string)Clans?.Call("GetClanOf", player.Object);

            if (clan == null)
            {
                return(null);
            }

            return(clan);
        }
        //void OnInboundBroadcast(Dictionary<string, string> data)
        //{
        //  Puts($"OnInboundBroadcast: {data["type"]} {data["message"]}");
        //}
        #endregion

        #region Clan Hooks
        //void OnClanCreate(string player, string id, string address, string reason)
        //{
        //  if (EventClanCreateChannel.Length == 0) return;

        //  SendToPoundBot(player, "clancreate", EventClanCreateChannel, EventClanCreateColor);
        //}
        #endregion

        void SendToPoundBot(IPlayer player, string eventType, string chan, string color = null)
        {
            string playerName = player.Name;
            var    clanTag    = (string)Clans?.Call("GetClanOf", player);

            if (!string.IsNullOrEmpty(clanTag))
            {
                playerName = $"[{clanTag}]{playerName}";
            }

            SendToPoundBot(player.Id, playerName, eventType, chan, color);
        }
Beispiel #7
0
        private JObject GetClanOf(IPlayer player)
        {
            var tag = (string)Clans?.Call("GetClanOf", player);

            if (tag == null)
            {
                return(null);
            }

            var clan = (JObject)Clans?.Call("GetClan", tag);

            return(clan);
        }
Beispiel #8
0
        private string GetDisplayName(IPlayer player)
        {
            string clanTag = Clans?.Call <string>("GetClanOf", player);

            if (!string.IsNullOrEmpty(clanTag))
            {
                clanTag = $"[{clanTag}] ";
            }

            return(_pluginConfig.PlayerNameFormat
                   .Replace("{clan}", clanTag)
                   .Replace("{name}", player.Name)
                   .Replace("{steamid}", player.Id));
        }
            public bool IsInClan(string playerId, string playerDoorOwner)
            {
                bool isInClan = false;

                if (ClansAvailable())
                {
                    string clanName = Clans.Call <string>(GET_CLAN_OF_PLAYER, playerId);
                    if (!string.IsNullOrWhiteSpace(clanName))
                    {
                        isInClan = Clans.Call <bool>(IS_CLAN_MEMBER, playerDoorOwner, playerId);
                    }
                }

                return(isInClan);
            }
Beispiel #10
0
        bool IsClanMember(BasePlayer player, BasePlayer possibleMember)
        {
            if (Clans == null || !Clans.IsLoaded)
            {
                return(false);
            }

            var playerClan      = Clans.Call <string>("GetClanOf", player);
            var otherPlayerClan = Clans.Call <string>("GetClanOf", possibleMember);

            if (String.IsNullOrEmpty(otherPlayerClan) || String.IsNullOrEmpty(playerClan))
            {
                return(false);
            }
            return(playerClan == otherPlayerClan);
        }
Beispiel #11
0
        private bool IsFriend(ulong playerid, ulong ownerid)
        {
            if (!configData.HonorRelationships)
            {
                return(false);
            }

            if (configData.useFriends && Friends != null)
            {
                var fr = Friends?.CallHook("AreFriends", playerid, ownerid);
                if (fr != null && (bool)fr)
                {
                    return(true);
                }
            }
            if (configData.useClans && Clans != null)
            {
                string playerclan = (string)Clans?.CallHook("GetClanOf", playerid);
                string ownerclan  = (string)Clans?.CallHook("GetClanOf", ownerid);
                if (playerclan != null && ownerclan != null)
                {
                    if (playerclan == ownerclan)
                    {
                        return(true);
                    }
                }
            }
            if (configData.useTeams)
            {
                BasePlayer player = BasePlayer.FindByID(playerid);
                if (player != null)
                {
                    if (player.currentTeam != 0)
                    {
                        RelationshipManager.PlayerTeam playerTeam = RelationshipManager.ServerInstance.FindTeam(player.currentTeam);
                        if (playerTeam != null)
                        {
                            if (playerTeam.members.Contains(ownerid))
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
Beispiel #12
0
        void SendClans()
        {
            Puts(lang.GetMessage("sending_clans", this));

            var            clan_tags = (JArray)Clans.Call("GetAllClans");
            List <JObject> clans     = new List <JObject>();

            foreach (string ctag in clan_tags)
            {
                Puts(string.Format(lang.GetMessage("sending_clans_tag", this), ctag));
                clans.Add((JObject)Clans.Call("GetClan", ctag));
            }

            Func <int, string, bool> callback = AcceptedHandler;

            PoundBot.Call("API_SendClans", new object[] { this, clans, callback });
        }
Beispiel #13
0
        private List <BasePlayer> FindClanMember(BasePlayer player)
        {
            if (Clans == null)
            {
                return(null);
            }

            List <BasePlayer> clanMember = new List <BasePlayer>();
            string            clanName   = (string)Clans?.Call("GetClanOf", player.userID);

            if (string.IsNullOrEmpty(clanName))
            {
                return(null);
            }
            else
            {
                JObject clan = (JObject)Clans?.Call("GetClan", clanName);
                if (clan != null)
                {
                    JArray members = (JArray)clan.GetValue("members");
                    if (members != null)
                    {
                        foreach (string member in members)
                        {
                            if (member == player.UserIDString)
                            {
                                continue;
                            }
                            BasePlayer foundPlayer = FindPlayer(member);
                            if (foundPlayer)
                            {
                                clanMember.Add(foundPlayer);
                            }
                        }
                    }
                }
            }

            return(clanMember);
        }
            public bool IsInClan(BasePlayer player)
            {
                bool isInClan = false;

                if (ClansAvailable())
                {
                    object obj = Clans.CallHook(GET_CLAN_OF_PLAYER, new object[] { OriginalPlayerID });
                    if (obj != null)
                    {
                        String clanName = obj.ToString();
                        object clan     = Clans.CallHook(GET_CLAN, new object[] { clanName });
                        if (clan != null)
                        {
                            JObject  jObject   = JObject.FromObject(clan);
                            JArray   members   = (JArray)jObject.GetValue(MEMBERS);
                            string[] memberIds = members.ToObject <string[]>();
                            isInClan = (memberIds.Contains(player.userID.ToString()));
                        }
                    }
                }

                return(isInClan);
            }
Beispiel #15
0
 void Init()
 {
     Instance = this;
 }
Beispiel #16
0
 void Init()
 {
     Instance = this;
 }
        void OnPlayerChat(BasePlayer bplayer, string message, Chat.ChatChannel chatchannel)
        {
            if (chatchannel == Chat.ChatChannel.Team)
            {
                return;
            }
            IPlayer player = bplayer.IPlayer;
#else
        void OnUserChat(IPlayer player, string message)
        {
#endif
            if (UseBetterChat)
            {
                return;
            }
            SendToPoundBot(player, message, RelayChatChannel, RelayChatColor);
        }

        void OnBetterChat(Dictionary <string, object> data)
        {
            if (!UseBetterChat)
            {
                return;
            }

#if RUST
            if ((Chat.ChatChannel)data["ChatChannel"] == Chat.ChatChannel.Team)
            {
                return;
            }
#endif

            string color = RelayChatColor;

            if (RelayChatColor != null)
            {
                Dictionary <string, object> m = (Dictionary <string, object>)data["MessageSettings"];

                color = (string)m["Color"];
            }

            IPlayer player = (IPlayer)data["Player"];

            SendToPoundBot(player, (string)data["Message"], RelayChatChannel, color);
        }

        void SendToPoundBot(IPlayer player, string message, string channel, string embed_color = null)
        {
            string playerName = player.Name;
            var    clanTag    = (string)Clans?.Call("GetClanOf", player);

            if (!string.IsNullOrEmpty(clanTag))
            {
                playerName = $"[{clanTag}]{playerName}";
            }

            SendToPoundBot(playerName, message, channel, embed_color);
        }

        void SendToPoundBot(string player, string message, string channel, string embed_color = null)
        {
            if (channel.Length == 0)
            {
                Puts("Channel not defined. Please set your channel names in config/PoundBotChatRelay.json.");
                return;
            }

            KeyValuePair <string, bool>[] message_parts = new KeyValuePair <string, bool> [4];
            message_parts[0] = new KeyValuePair <string, bool>($"{lang.GetMessage("chat.Prefix", this)}{DateTime.Now.ToString(lang.GetMessage("chat.DateFormat", this))} **", false);
            message_parts[1] = new KeyValuePair <string, bool>(player, true);
            message_parts[2] = new KeyValuePair <string, bool>("**: ", false);
            message_parts[3] = new KeyValuePair <string, bool>(message, true);
            PoundBot.Call(
                "API_SendChannelMessage",
                new object[] { this, channel, message_parts, embed_color, null }
                );
        }
Beispiel #18
0
        private object OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
            if (entity is BuildingBlock || entity.name.Contains("deploy") || entity.name.Contains("building"))
            {
                var player = info?.Initiator?.ToPlayer();

                if (!player || !entity.OwnerID.IsSteamId())
                {
                    return(null);
                }

                if (cFile.FriendBypass.Enabled)
                {
                    // Owner checks
                    if (cFile.FriendBypass.PlayerOwner.Enabled && player.userID == entity.OwnerID)
                    {
                        return(null);
                    }
                    // Friend checks

                    if (Friends)
                    {
                        var hasFriend = Friends?.Call("HasFriend", entity.OwnerID.ToString(), player.UserIDString) ?? false;
                        if (cFile.FriendBypass.FriendsApi.Enabled && (bool)hasFriend)
                        {
                            return(null);
                        }
                    }

                    if (Clans)
                    {
                        // Clan checks
                        var targetClan = (string)Clans?.Call("GetClanOf", entity.OwnerID.ToString());
                        var playerClan = (string)Clans?.Call("GetClanOf", player.UserIDString);
                        if (cFile.FriendBypass.RustIoClans.Enabled && playerClan != null && targetClan != null && targetClan == playerClan)
                        {
                            return(null);
                        }
                    }
                }

                // Prevents player from damaging after friendbypass checks
                if (cFile.StopAllRaiding)
                {
                    PrintToChat(player, Lang("CantDamage", player.UserIDString));
                    return(true);
                }

                // No raid command checks
                if (!_canRaid)
                {
                    PrintToChat(player, Lang("Cmd_CantRaid", player.UserIDString, GetFormattedTime((_cachedRaidTime.AddMinutes(_startMinutes)
                                                                                                    - DateTime.UtcNow).TotalSeconds)));
                    return(true);
                }

                // Wipe raid checks
                if (cFile.WipeRaiding.Enabled && !_canWipeRaid)
                {
                    PrintToChat(player, Lang("Cmd_CantRaid", player.UserIDString, GetFormattedTime((_cachedWipeTime.AddMinutes(cFile.WipeRaiding.MinsFromWipe)
                                                                                                    - DateTime.UtcNow).TotalSeconds)));
                    return(true);
                }
                if (cFile.WipeRaiding.Enabled)
                {
                    return(null);
                }
            }
            return(null);
        }
        private void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
            if (entity == null)
            {
                return;
            }
            if (!Economics && !ServerRewards)
            {
                return;
            }
            if (!info?.Initiator?.ToPlayer())
            {
                return;
            }

            var player = info.Initiator.ToPlayer();
            var animal = UppercaseFirst(entity.LookupPrefab().ToString().Replace("[0]", ""));

            amount = 0;

            if (entity.ToPlayer() != null && !(entity is NPCPlayer))
            {
                var victim = entity.ToPlayer();
                if (player == victim)
                {
                    return;
                }
                amount = config.Settings.Rewards[PluginRewards.Player];
                animal = "player";
                if (Friends && config.Settings.Rewards[PluginRewards.PlayerFriend] != 0)
                {
                    bool isFriend        = Friends.Call <bool>("HasFriend", victim.userID, player.userID);
                    bool isFriendReverse = Friends.Call <bool>("HasFriend", player.userID, victim.userID);
                    if (isFriend && isFriendReverse)
                    {
                        amount = config.Settings.Rewards[PluginRewards.PlayerFriend];
                        animal = "friend";
                    }
                }
                if (Clans && config.Settings.Rewards[PluginRewards.ClanMember] != 0)
                {
                    string victimclan = Clans.Call <string>("GetClanOf", victim.userID);
                    string playerclan = Clans.Call <string>("GetClanOf", player.userID);
                    if (victimclan == playerclan)
                    {
                        amount = config.Settings.Rewards[PluginRewards.ClanMember];
                        animal = "clan member";
                    }
                }
            }
            else
            {
                if (entity is NPCMurderer)
                {
                    animal = "Murderer"; config.Settings.Rewards.TryGetValue(animal, out amount);
                }
                else if (entity is NPCPlayerApex)
                {
                    animal = "Scientist"; config.Settings.Rewards.TryGetValue(animal, out amount);
                }
                else if (entity.GetComponent("BaseNpc"))
                {
                    animal = UppercaseFirst(entity.LookupPrefab().ToString().Replace("[0]", ""));
                    config.Settings.Rewards.TryGetValue(animal, out amount);
                }
            }

            if (amount != 0)
            {
                GiveCredit(player, "kill", amount, animal);
            }
        }