Ejemplo n.º 1
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            if (command.Count() == 1)
            {
                string playerName = command[0];

                foreach (SteamPlayer plr in Provider.Players)
                {
                    //So let's convert each SteamPlayer into an UnturnedPlayer
                    UnturnedPlayer unturnedPlayer = UnturnedPlayer.FromSteamPlayer(plr);

                    if (unturnedPlayer.DisplayName.ToLower().IndexOf(playerName.ToLower()) != -1 || unturnedPlayer.CharacterName.ToLower().IndexOf(playerName.ToLower()) != -1 || unturnedPlayer.SteamName.ToLower().IndexOf(playerName.ToLower()) != -1 || unturnedPlayer.CSteamID.ToString().Equals(playerName))
                    {
                        UnturnedChat.Say(caller, "The ping of " + unturnedPlayer.DisplayName + " is " + (unturnedPlayer.Ping * 1000) + " ms.", Color.green);
                        return;
                    }
                }
            }
            else if (command.Count() == 0)
            {
                UnturnedPlayer tempPlayer = (UnturnedPlayer)caller;

                UnturnedChat.Say(caller, "Your ping is " + (tempPlayer.Ping * 1000) + " ms.", Color.green);
                return;
            }
            else
            {
                UnturnedChat.Say(caller, "Error, used this wrong. Syntax: /ping (player)");
            }
        }
Ejemplo n.º 2
0
        private void PaySalary()
        {
            foreach (SteamPlayer steamPlayer in Provider.clients)
            {
                UnturnedPlayer player = UnturnedPlayer.FromSteamPlayer(steamPlayer);
                int            amount = 0;

                foreach (Group group in Configuration.Instance.Groups)
                {
                    var salarygroup = R.Permissions.GetGroup(group.GroupName);
                    if (salarygroup.Members.Contains(player.Id))
                    {
                        amount = group.Salary;
                        if (amount < 0)
                        {
                            amount = 0;
                        }
                        if (Configuration.Instance.XpMode == false)
                        {
                            EconomyDB.AddBalance(player, amount);
                        }
                        else
                        {
                            player.Experience = player.Experience + (uint)amount;
                        }
                        UnturnedChat.Say(player, string.Format(Translate("salary_pay"), amount, Configuration.Instance.CurrencyName, salarygroup.DisplayName));
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void OnPlayersAmount(int players)
        {
            if (players != Provider.clients.Count)
            {
                return;
            }

            foreach (ArenaPlayer player in LevelManager.arenaPlayers)
            {
                UnturnedPlayer uPlayer = UnturnedPlayer.FromSteamPlayer(player.steamPlayer);

                if (Configuration.Instance.GodMode)
                {
                    uPlayer.GodMode = true;
                }
                if (Configuration.Instance.Vanish)
                {
                    uPlayer.VanishMode = true;
                }

                ChatManager.say(player.steamPlayer.playerID.steamID, Translate("protected", Configuration.Instance.Seconds), Configuration.Instance.color);
            }
            startTime = DateTime.Now;
            Finished  = false;
        }
Ejemplo n.º 4
0
        private void Update()
        {
            frame++;
            if (frame % 10 != 0)
            {
                return;
            }

            foreach (var splayer in Provider.clients)
            {
                UnturnedPlayer player = UnturnedPlayer.FromSteamPlayer(splayer);
                if (player.Player.equipment.isSelected)
                {
                    onItemEquip(player, player.Player.equipment);
                }
                if (player.IsInVehicle)
                {
                    onVehicleEnter(player, player.CurrentVehicle);
                    if (player.CurrentVehicle.checkDriver(player.CSteamID))
                    {
                        onVehicleDriver(player, player.CurrentVehicle);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private void FixedUpdate()
        {
            Frames++;
            if (Frames > 59)
            {
                if (Provider.clients.Count > 0)
                {
                    foreach (SteamPlayer sPlayer in Provider.clients)
                    {
                        PlayerUtil PlayerU = UnturnedPlayer.FromSteamPlayer(sPlayer).GetComponent <PlayerUtil>();

                        if (!PlayerU.canKill)
                        {
                            if (PlayerU.CanKillTime >= GetLongTime())
                            {
                                PlayerU.canKill = true;
                                UnturnedChat.Say(UnturnedPlayer.FromSteamPlayer(sPlayer), "You can now do damage again!", Color.yellow);
                            }
                        }
                    }
                }
                Frames = 0;
                return;
            }
        }
Ejemplo n.º 6
0
        public static void FindPlayer(string Name, out List <UnturnedPlayer> FoundPlayers)
        {
            UnturnedPlayer player;

            IsPlayerOnline(Name, out player);

            List <UnturnedPlayer> _FoundPlayers = new List <UnturnedPlayer>();

            if (player == null)
            {
                foreach (var P in Provider.clients)
                {
                    UnturnedPlayer unturnedPlayer = UnturnedPlayer.FromSteamPlayer(P);

                    if (unturnedPlayer.DisplayName.Substring(0, 4).ToLower() == Name.Substring(0, 4).ToLower())
                    {
                        _FoundPlayers.Clear();
                        _FoundPlayers.Add(unturnedPlayer);
                    }
                }
            }
            else
            {
                _FoundPlayers.Clear();
                _FoundPlayers.Add(player);
            }
            FoundPlayers = _FoundPlayers;
        }
Ejemplo n.º 7
0
        public Task HandleEventAsync(object emitter, CommandExecutedEvent @event)
        {
            async UniTask Task()
            {
                // RocketMod commands must run on main thread
                await UniTask.SwitchToMainThread();

                if (@event.CommandContext.Exception is CommandNotFoundException && R.Commands != null)
                {
                    var text = @event.CommandContext.GetCommandLine();

                    IRocketPlayer rocketPlayer = null;
                    if (@event.Actor is UnturnedUser user)
                    {
                        var player = user.SteamPlayer;
                        if (UnturnedPermissions.CheckPermissions(player, text))
                        {
                            rocketPlayer = UnturnedPlayer.FromSteamPlayer(player);
                        }
                    }
                    else if (@event.Actor.Type.Equals(KnownActorTypes.Console, StringComparison.OrdinalIgnoreCase))
                    {
                        rocketPlayer = new ConsolePlayer();
                    }

                    if (rocketPlayer != null)
                    {
                        R.Commands.Execute(rocketPlayer, text);
                        @event.CommandContext.Exception = null;
                    }
                }
            }

            return(Task().AsTask());
        }
Ejemplo n.º 8
0
 // EventManager.onEventTriggered
 private void onEventTrigger(Event @event)
 {
     if (@event.type == type.id)
     {
         int minPlayers;
         if (int.TryParse(@event.parameters[0], out minPlayers) && Provider.clients.Count < minPlayers)
         {
             UnturnedChat.Say(EventManager.Instance.Translate("exmapleevent_insufficient_players", @event.name), UnturnedChat.GetColorFromName(EventManager.Instance.Configuration.Instance.messageColor, Color.green));
             return;
         }
         List <string> parameters = @event.parameters;
         parameters.RemoveRange(0, 1);
         if (!parametersHaveItemID(parameters))
         {
             UnturnedChat.Say(EventManager.Instance.Translate("exampleevent_invalid_ids", @event.name), UnturnedChat.GetColorFromName(EventManager.Instance.Configuration.Instance.messageColor, Color.green));
             return;
         }
         foreach (var sPlayer in Provider.clients)
         {
             UnturnedPlayer player = UnturnedPlayer.FromSteamPlayer(sPlayer);
             bool           fin    = false;
             while (!fin)
             {
                 ushort itemID;
                 if (ushort.TryParse(parameters[UnityEngine.Random.Range(0, parameters.Count)], out itemID))
                 {
                     player.GiveItem(itemID, 1);
                     UnturnedChat.Say(player, EventManager.Instance.Translate("exampleevent_give_away", @event.name), UnturnedChat.GetColorFromName(EventManager.Instance.Configuration.Instance.messageColor, Color.green));
                     fin = true;
                 }
             }
         }
     }
 }
Ejemplo n.º 9
0
 private void OnDisconnected(UnturnedPlayer player)
 {
     foreach (SteamPlayer p in Provider.clients)
     {
         UnturnedPlayer.FromSteamPlayer(p).GetComponent <ExtraPlayer>().OnDisconnect(player);
     }
 }
Ejemplo n.º 10
0
        private void Events_OnPlayerConnected(UnturnedPlayer player)
        {
            if (Configuration.Instance.PvPOnOffPermission)
            {
                var SteamID = ((UnturnedPlayer)player).CSteamID;
                foreach (var steamPlayer in Provider.clients)
                {
                    if (player.IsAdmin && Configuration.Instance.IgnoreAdmin)
                    {
                        return;
                    }

                    if (steamPlayer.playerID.steamID == SteamID && player.HasPermission(Configuration.Instance.Permission))
                    {
                        Provider.isPvP = true;

                        if (Configuration.Instance.PvPOnOffMessage)
                        {
                            UnturnedChat.Say(Translate("pvp_on"));
                        }
                        continue;
                    }

                    UnturnedPlayer Players = UnturnedPlayer.FromSteamPlayer(steamPlayer);

                    if (Players.HasPermission(Configuration.Instance.Permission))
                    {
                        return;
                    }
                }
            }
        }
        public async Task HandleEventAsync(object emitter, CommandExecutedEvent @event)
        {
            if (@event.CommandContext.Exception is CommandNotFoundException && R.Commands != null)
            {
                var text = @event.CommandContext.GetCommandLine();

                IRocketPlayer rocketPlayer = null;
                if (@event.Actor is UnturnedUser user)
                {
                    var player = user.SteamPlayer;
                    if (UnturnedPermissions.CheckPermissions(player, text))
                    {
                        rocketPlayer = UnturnedPlayer.FromSteamPlayer(player);
                    }
                }
                else if (@event.Actor.Type.Equals(KnownActorTypes.Console, StringComparison.OrdinalIgnoreCase))
                {
                    rocketPlayer = new ConsolePlayer();
                }

                if (rocketPlayer != null)
                {
                    R.Commands.Execute(rocketPlayer, text);
                    @event.CommandContext.Exception = null;
                }
            }
        }
Ejemplo n.º 12
0
 public static bool BroadCast(string pluginid, string key, Color color, params object[] parameters)
 {
     foreach (SteamPlayer sp in Provider.clients)
     {
         UnturnedPlayer         player    = UnturnedPlayer.FromSteamPlayer(sp);
         Plugin.PlayerComponent component = player.GetComponent <Plugin.PlayerComponent>();
         string lang = component.lang;
         string text = Instance.Configuration.Instance.PluginTranslate.Find(x => x.pluginid == pluginid).Langs.Find(x => x.LangID == lang).LangString.Find(x => x.id == key).text;
         if (string.IsNullOrEmpty(text))
         {
             return(false);
         }
         if (text.Contains("{") && text.Contains("}") && parameters != null && parameters.Length != 0)
         {
             for (int i = 0; i < parameters.Length; i++)
             {
                 if (parameters[i] == null)
                 {
                     parameters[i] = "NULL";
                 }
             }
             text = string.Format(text, parameters);
         }
         UnturnedChat.Say(player, text, color);
     }
     return(true);
 }
Ejemplo n.º 13
0
        private void UnturnedPlayerEvents_OnPlayerChatted(Rocket.Unturned.Player.UnturnedPlayer player, ref UnityEngine.Color color, string message, SDG.Unturned.EChatMode chatMode, ref bool cancel)
        {
            var result = GetChannel(player.CSteamID);

            if (result != null && chatMode == 0 && player.HasPermission("channel." + result.Channel.ToLower()) && result.Channel.ToLower() != "global" && !message.StartsWith("/") && !message.StartsWith("@"))
            {
                cancel = true;
                foreach (var steamplayer in Provider.clients)
                {
                    UnturnedPlayer stm = UnturnedPlayer.FromSteamPlayer(steamplayer);
                    if (stm.HasPermission("channel." + result.Channel.ToLower()))
                    {
                        UnturnedChat.Say(steamplayer.playerID.steamID, "[" + result.Channel + "] " + player.CharacterName + " : " + message);
                        Times = 1;
                    }
                }
            }
            if (result.Channel.ToLower() == "global" && chatMode == 0 && (!message.StartsWith("/") && !message.StartsWith("@")))
            {
                if (player.HasPermission("chat.global"))
                {
                    ChatManager.instance.askChat(player.CSteamID, 0, message);
                    Times = 1;
                }
            }
            if (Times == 0)
            {
                UnturnedChat.Say(player, Translate("no_permission"));
            }
        }
Ejemplo n.º 14
0
        public void ExecuteCommandRespond(IRocketPlayer caller, string[] parameters)
        {
            if (parameters.Length < 1)
            {
                UnturnedChat.Say(caller, "Usage: /respond <player>", Color.yellow);
                return;
            }

            UnturnedPlayer player   = (UnturnedPlayer)caller;
            UnturnedPlayer toRescue = UnturnedPlayer.FromName(string.Join(" ", parameters));

            if (toRescue == null)
            {
                UnturnedChat.Say(caller, Translate("noplayer"), Color.yellow);
                return;
            }

            if (emergencies.ContainsKey(toRescue.CSteamID))
            {
                emergencies.Remove(toRescue.CSteamID);
                foreach (SteamPlayer sp in Provider.clients)
                {
                    UnturnedPlayer tmpPlayer = UnturnedPlayer.FromSteamPlayer(sp);
                    if ((tmpPlayer.HasPermission("emergency.receive") && !silent.Contains(tmpPlayer.CSteamID)) || tmpPlayer.CSteamID == player.CSteamID || tmpPlayer.CSteamID == toRescue.CSteamID)
                    {
                        UnturnedChat.Say(tmpPlayer, Translate("respond", player.CharacterName, toRescue.CharacterName), Color.cyan);
                    }
                }
            }
            else
            {
                UnturnedChat.Say(caller, Translate("noemergency", toRescue.CharacterName), Color.yellow);
            }
        }
Ejemplo n.º 15
0
        public void ExecuteCommand911(IRocketPlayer caller, string[] parameters)
        {
            if (parameters.Length < 1)
            {
                UnturnedChat.Say(caller, "Usage: /emergency <message>", Color.yellow);
                return;
            }

            string msg = string.Join(" ", parameters);

            UnturnedPlayer player = (UnturnedPlayer)caller;

            if (!emergencies.ContainsKey(player.CSteamID))
            {
                emergencies.Add(player.CSteamID, DateTime.Now);
            }
            foreach (SteamPlayer sp in Provider.clients)
            {
                UnturnedPlayer tmpPlayer = UnturnedPlayer.FromSteamPlayer(sp);
                if ((tmpPlayer.HasPermission("emergency.receive") && !silent.Contains(tmpPlayer.CSteamID)) || tmpPlayer.CSteamID == player.CSteamID)
                {
                    if (Configuration.Instance.ShowCoordinates)
                    {
                        string x = Math.Round(player.Position.x).ToString();
                        string y = Math.Round(player.Position.y).ToString();
                        string z = Math.Round(player.Position.z).ToString();
                        UnturnedChat.Say(tmpPlayer, Translate("emergencycoords", player.CharacterName, msg, x, y, z), Color.red);
                    }
                    else
                    {
                        UnturnedChat.Say(tmpPlayer, Translate("emergency", player.CharacterName, msg), Color.red);
                    }
                }
            }
        }
Ejemplo n.º 16
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            if (command.Count() == 1)
            {
                string playerName = command[0];

                //Find player
                foreach (SteamPlayer plr in Provider.Players)
                {
                    //So let's convert each SteamPlayer into an UnturnedPlayer
                    UnturnedPlayer unturnedPlayer = UnturnedPlayer.FromSteamPlayer(plr);

                    if (unturnedPlayer.DisplayName.ToLower().IndexOf(playerName.ToLower()) != -1 || unturnedPlayer.CharacterName.ToLower().IndexOf(playerName.ToLower()) != -1 || unturnedPlayer.SteamName.ToLower().IndexOf(playerName.ToLower()) != -1 || unturnedPlayer.CSteamID.ToString().Equals(playerName))
                    {
                        unturnedPlayer.Damage(200, unturnedPlayer.Position, EDeathCause.KILL, ELimb.LEFT_BACK, unturnedPlayer.CSteamID);
                        UnturnedChat.Say(caller, "Killed " + unturnedPlayer.DisplayName + ".", Color.green);
                        return;
                    }
                }
                UnturnedChat.Say(caller, "Player not found.", Color.red);
            }
            else
            {
                UnturnedChat.Say(caller, "Error.", Color.red);
                return;
            }
        }
        private void announcementManager()
        {
            if (((DateTime.Now - this.lastCalledTimer).TotalSeconds > 30))
            {
                lastCalledTimer = DateTime.Now;

                if (PaintballManager.paintballOn)
                {
                    UnturnedChat.Say("Join paintball! Do '/paintball join' to join. Your inventory and experience is saved!", Color.cyan);
                }

                if (!PaintballManager.paintballOn && PaintballManager.playerWins.Count() > 0)
                {
                    foreach (SteamPlayer plr in Provider.Players)
                    {
                        //So let's convert each SteamPlayer into an UnturnedPlayer
                        UnturnedPlayer unturnedPlayer = UnturnedPlayer.FromSteamPlayer(plr);

                        if (PaintballManager.playerWins.ContainsKey(unturnedPlayer.CSteamID))
                        {
                            UnturnedChat.Say(unturnedPlayer, "You have a prize from paintball, claim it with '/paintball reward'.", Color.cyan);
                        }
                    }
                }
            }
        }
Ejemplo n.º 18
0
        public static JObject Generate_PlayerStatus(string message, SteamPlayer player, ServerSetting bot)
        {
            JObject obj       = new JObject();
            JArray  arrEmbeds = new JArray();
            JObject objEmbed  = new JObject();
            JObject objAuthor = new JObject();
            JObject objFooter = new JObject();

            objAuthor.Add("name", player.playerID.playerName);
            if (bot.LinkSenderProfile)
            {
                objAuthor.Add("url", "http://steamcommunity.com/profiles/" + player.playerID.steamID.ToString());
            }
            objAuthor.Add("icon_url", UnturnedPlayer.FromSteamPlayer(player).SteamProfile.AvatarFull.AbsoluteUri);

            objFooter.Add("text", string.Format(DiscordHook.Instance.Translations.Instance["player_status_count"], DiscordHook.Players));

            objEmbed.Add("title", DiscordHook.Instance.Translations.Instance["player_status_title"]);
            objEmbed.Add("description", message);
            objEmbed.Add("color", int.Parse(bot.ColorJoinLeave, NumberStyles.HexNumber));
            if (bot.ShowPlayerCount)
            {
                objEmbed.Add("footer", objFooter);
            }
            objEmbed.Add("author", objAuthor);
            arrEmbeds.Add(objEmbed);

            obj.Add("username", DiscordHook.Instance.Configuration.Instance.ServerName);
            obj.Add("tts", false);
            obj.Add("embeds", arrEmbeds);

            return(obj);
        }
Ejemplo n.º 19
0
        private void Reloj_Elapsed(object sender, ElapsedEventArgs e)
        {
            TaskDispatcher.QueueOnMainThread(() =>
            {
                Provider.clients.ForEach(delegate(SteamPlayer client)
                {
                    UnturnedPlayer playeR;
                    playeR    = UnturnedPlayer.FromSteamPlayer(client);
                    bool flag = Nadadores.Contains(playeR.CSteamID);

                    if (!flag)
                    {
                        Savedata valor = playeR.GetComponent <Savedata>();
                        if (valor.tiempo <= 3)
                        {
                            playeR.Damage(100, playeR.Position, EDeathCause.BREATH, ELimb.SKULL, playeR.CSteamID);
                        }
                        else
                        {
                            valor.tiempo--;
                        }
                    }
                });
            });
        }
Ejemplo n.º 20
0
        public void FixedUpdate()
        {
            frames++;

            if (frames > 60)
            {
                if (Provider.clients.Count > 0)
                {
                    foreach (SteamPlayer sPlayer in Provider.clients)
                    {
                        UnturnedPlayer player = UnturnedPlayer.FromSteamPlayer(sPlayer);
                        if (!(player.HasPermission("godvanishplus.dequip")))
                        {
                            return;
                        }
                        else if (player.Features.GodMode || player.Features.VanishMode)
                        {
                            if (player.Player.equipment.isEquipped)
                            {
                                player.Player.equipment.dequip();
                                frames = 0;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 21
0
        private void Update()
        {
            foreach (var a in Provider.clients.ToList())
            {
                var ID      = a.playerID.steamID;
                var UPlayer = UnturnedPlayer.FromSteamPlayer(a);

                if (!LastPosition.ContainsKey(ID))
                {
                    LastPosition.Add(ID, new PlayerData(UPlayer.Position, DateTime.Now));
                    return;
                }
                else if (LastPosition.ContainsKey(ID))
                {
                    if (LastPosition[ID].LastPosition == UPlayer.Position && DateTime.Now.Subtract(LastPosition[ID].LastPositionChange).TotalSeconds >= Configuration.Instance.AFKMaxTime)
                    {
                        Provider.kick(ID, Translate("afk_kick_reason"));
                    }
                    else if (LastPosition[ID].LastPosition != UPlayer.Position)
                    {
                        LastPosition[ID].Update(UPlayer.Position, DateTime.Now);
                    }
                }
            }
        }
Ejemplo n.º 22
0
 public void refreshName(SteamPlayer player)
 {
     if (Configuration.Instance.InkognitoUseGroupPrefixAndSuffix)
     {
         UnturnedPlayer uPlayer          = UnturnedPlayer.FromSteamPlayer(player);
         string         currentPrefix    = "";
         int            currentPrefixPri = -1;
         string         currentSuffix    = "";
         int            currentSuffixPri = -1;
         foreach (var group in R.Permissions.GetGroups(uPlayer, false))
         {
             if (group.Prefix != "" && group.Priority > currentPrefixPri)
             {
                 currentPrefix    = group.Prefix;
                 currentPrefixPri = group.Priority;
             }
             if (group.Suffix != "" && group.Priority > currentSuffixPri)
             {
                 currentSuffix    = group.Suffix;
                 currentSuffixPri = group.Priority;
             }
         }
         player.playerID.characterName = currentPrefix + Configuration.Instance.InkognitoNames[randomNum(0, Configuration.Instance.InkognitoNames.Count)] + currentSuffix;
     }
     else
     {
         player.playerID.characterName = Configuration.Instance.InkognitoNames[randomNum(0, Configuration.Instance.InkognitoNames.Count)];
     }
 }
        void DisableAllPlayersSpawnProtection()
        {
            foreach (var player in Provider.clients)
            {
                try
                {
                    var uP = UnturnedPlayer.FromSteamPlayer(player);
                    if (uP == null)
                    {
                        continue;
                    }

                    var component = uP.GetComponent <ProtectionComponent>();
                    if (component == null)
                    {
                        continue;
                    }

                    if (component.protectionEnabled)
                    {
                        component.StopProtection();
                    }
                }
                catch { }
            }
        }
Ejemplo n.º 24
0
        private void onChat(SteamPlayer player, EChatMode mode, ref Color chatted, ref bool isRich, string text, ref bool isVisible)
        {
            var converted = UnturnedPlayer.FromSteamPlayer(player);

            var webhook = Configuration.Instance.DiscordWebHookLink;

            var lower = text.ToLower();

            var ip = SteamGameServer.GetPublicIP();

            var address = ip.ToString();

            if (Configuration.Instance.LogCommands.Any(w => lower.StartsWith($"/{w.name} ")))
            {
                if (webhook == "Discord Webhook Here")
                {
                    return;
                }
                sendDiscordWebhook(webhook, ("{  \"username\": \"Command Log\",  \"avatar_url\": \"https://i.imgur.com/4M34hi2.png\",  \"embeds\": [    {      \"title\": \"Command Executed\",      \"color\": 15258703,      \"fields\": [        {          \"name\": \"Executer - !executer!\",          \"value\": \"ExecuterID\",          \"inline\": true        },        {          \"name\": \"Command:\",          \"value\": \"*!args!*\"        },        {          \"name\": \"Server IP\",          \"value\": \"!ip!\"        }      ],      \"thumbnail\": {        \"url\": \"https://i.pinimg.com/originals/1b/e8/41/1be84116e72d71bd6785c7050fefd2e3.gif\"      },      \"image\": {        \"url\": \"https://upload.wikimedia.org/wikipedia/commons/5/5a/A_picture_from_China_every_day_108.jpg\"      },      \"footer\": {        \"text\": \"CommandLog by ExoPlugins\",        \"icon_url\": \"https://media.discordapp.net/attachments/811275497966665739/823878043906080778/image0.png?width=128&height=128\"      }    }  ]}").Replace("!executer!", converted.DisplayName).Replace("*!args!*", $"`{lower}`").Replace("!ip!", address).Replace("ExecuterID", converted.Id));
            }

            else if (Configuration.Instance.LogCommands.Any(w => lower.StartsWith($"/{w.name}")))
            {
                if (webhook == "Discord Webhook Here")
                {
                    return;
                }
                sendDiscordWebhook(webhook, ("{  \"username\": \"Command Log\",  \"avatar_url\": \"https://i.imgur.com/4M34hi2.png\",  \"embeds\": [    {      \"title\": \"Command Executed\",      \"color\": 15258703,      \"fields\": [        {          \"name\": \"Executer - !executer!\",          \"value\": \"ExecuterID\",          \"inline\": true        },        {          \"name\": \"Command:\",          \"value\": \"*!args!*\"        },        {          \"name\": \"Server IP\",          \"value\": \"!ip!\"        }      ],      \"thumbnail\": {        \"url\": \"https://i.pinimg.com/originals/1b/e8/41/1be84116e72d71bd6785c7050fefd2e3.gif\"      },      \"image\": {        \"url\": \"https://upload.wikimedia.org/wikipedia/commons/5/5a/A_picture_from_China_every_day_108.jpg\"      },      \"footer\": {        \"text\": \"CommandLog by ExoPlugins\",        \"icon_url\": \"https://media.discordapp.net/attachments/811275497966665739/823878043906080778/image0.png?width=128&height=128\"      }    }  ]}").Replace("!executer!", converted.DisplayName).Replace("*!args!*", $"`{lower}`").Replace("!ip!", address).Replace("ExecuterID", converted.Id));
            }
        }
        //Once I figure out overriding the netcode for this I shouldn't have to do this tickbased so no more shitty performance
        public static void CheckEquips()
        {
            foreach (SteamPlayer pla in Provider.clients)
            {
                UnturnedPlayer rPlayer = UnturnedPlayer.FromSteamPlayer(pla);
                if ((rPlayer.Player.equipment.useable as UseableGun) == null || !rPlayer.Player.equipment.isEquipped)
                {
                    continue;
                }

                bool isAllowed = false;

                foreach (var permission in Instance.Configuration.Instance.Permissions.Where(permission => rPlayer.HasPermission(permission)))
                {
                    isAllowed = true;
                }

                if (Instance.Configuration.Instance.BlacklistedGunIds.Contains(
                        ((ItemGunAsset)rPlayer.Player.equipment.asset).id))
                {
                    isAllowed = false;
                }


                if (isAllowed)
                {
                    return;
                }

                rPlayer.Player.equipment.dequip();
            }
        }
Ejemplo n.º 26
0
        protected override void Load()
        {
            //         Logger.Log("Event Plugin Started!");
            U.Events.OnPlayerDisconnected       += OnPlayerDisconnected;
            U.Events.OnPlayerConnected          += OnPlayerConnected;
            UnturnedPlayerEvents.OnPlayerRevive += OnPlayerRevive;
            UnturnedPlayerEvents.OnPlayerDead   += OnPlayerDead;

            CommandEvent.joinedPlayers = new List <PlayerData>();
            CommandEvent.eventActive   = false;
            CommandEvent.started       = false;

            Instance = this;

            foreach (SteamPlayer plr in Provider.Players)
            {
                //So let's convert each SteamPlayer into an UnturnedPlayer
                UnturnedPlayer unturnedPlayer = UnturnedPlayer.FromSteamPlayer(plr);

                unturnedPlayer.GodMode = false;

                //Reset permissions
                Rocket.Core.R.Permissions.RemovePlayerFromGroup("EventGroup", unturnedPlayer);
                Rocket.Core.R.Permissions.AddPlayerToGroup("Guest", unturnedPlayer);
            }
            //            joinedPlayers = new ArrayList();
            //joinedPlayers = new PlayerData[Configuration.Instance.totalPlayersInServer];
        }
Ejemplo n.º 27
0
        public static JObject Generate_Abuse(string message, SteamPlayer admin, ServerSetting bot)
        {
            if (admin == null)
            {
                return(null);
            }

            JObject obj       = new JObject();
            JArray  arrEmbeds = new JArray();
            JObject objEmbed  = new JObject();
            JObject objAuthor = new JObject();

            objAuthor.Add("name", admin.playerID.playerName);
            if (bot.LinkSenderProfile)
            {
                objAuthor.Add("url", "http://steamcommunity.com/profiles/" + admin.playerID.steamID.ToString());
            }
            objAuthor.Add("icon_url", UnturnedPlayer.FromSteamPlayer(admin).SteamProfile.AvatarFull.AbsoluteUri);

            objEmbed.Add("title", DiscordHook.Instance.Translations.Instance["abuse_title"]);
            objEmbed.Add("description", message);
            objEmbed.Add("color", int.Parse(bot.ColorAbuse, NumberStyles.HexNumber));
            objEmbed.Add("author", objAuthor);
            arrEmbeds.Add(objEmbed);

            obj.Add("username", DiscordHook.Instance.Configuration.Instance.ServerName);
            obj.Add("tts", false);
            obj.Add("embeds", arrEmbeds);

            return(obj);
        }
Ejemplo n.º 28
0
 public void turnOff()
 {
     isActive = false;
     foreach (var sPlayer in Provider.clients)
     {
         sPlayer.playerID.characterName = CharNames[UnturnedPlayer.FromSteamPlayer(sPlayer).CSteamID];
     }
 }
Ejemplo n.º 29
0
 //On player left from the server
 private void Disconnect(UnturnedPlayer p)
 {
     foreach (SteamPlayer sp in Provider.clients)
     {
         UnturnedPlayer p2 = UnturnedPlayer.FromSteamPlayer(sp);
         UpdateUI(p2);
     }
 }
Ejemplo n.º 30
0
 public static bool CheckPermissions(SteamPlayer player, string command)
 {
     if (R.Commands != null && UnturnedPermissions.CheckPermissions(player, command))
     {
         R.Commands.Execute(UnturnedPlayer.FromSteamPlayer(player), command);
     }
     return(false);
 }