private void OnPlayerChatted(Rocket.Unturned.Player.UnturnedPlayer player, ref UnityEngine.Color color, string message, SDG.Unturned.EChatMode chatMode, ref bool cancel)
        {
            // If player chatted like "Hey n***a" we'll return the method.
            if (!message.StartsWith("/"))
            {
                return;
            }
            // So, player entered the command and we'll deleting "/" letter from message.
            message = message.Remove(0, 1);
            // Deleting command arguments bcuz we only need the command.
            string[] args;
            if (message.Split(' ').Length > 1)
            {
                args = message.Split(' ').Skip(1).ToArray();
            }
            else
            {
                args = new string[0];
            }
            // Set message to command name.
            message = message.Split(' ')[0];

            CommandLoggerEntry Entry = this.Configuration.Instance.Entries.Where(entry => entry.Name == message ^ entry.GetAliases().Contains(message)).FirstOrDefault();

            if (Entry.Equals(default(CommandLoggerEntry)))
            {
                return;
            }

            this.Logger.Log(string.Format(this.Configuration.Instance.LogFormat, System.DateTime.Now, player.DisplayName, player.CSteamID.m_SteamID, Entry.Name, message, string.Join(" ", args)));
        }
        private void OnPlayerConnected(UP player)
        {
            var steamid = player.CSteamID;

            dict.Add(steamid, 1);
            player.Player.gameObject.AddComponent <PlayerComponent>();
        }
Example #3
0
 private void TPA_PlayerJoin(Rocket.Unturned.Player.UnturnedPlayer player)
 {
     if (CommandTPA.requests.ContainsKey(player.CSteamID))
     {
         CommandTPA.requests.Remove(player.CSteamID);
     }
 }
 public void Execute(IRocketPlayer caller, string[] command)
 {
     //ManageUI.UnLoad();
     //Console.WriteLine(ManageUI.Instances == null);
     //Logger.Log("Inventory UI stoped", ConsoleColor.Cyan);
     Rocket.Unturned.Player.UnturnedPlayer player = (Rocket.Unturned.Player.UnturnedPlayer)caller;
     SDG.Unturned.EffectManager.askEffectClearAll();
 }
Example #5
0
        void playerConnected(UP up)
        {
            var color = Color.yellow;

            Log($"Player {up.CSteamID} with language {conf.GetLanguage(up.CSteamID)}", Utils.ToConsoleColor(color));
            foreach (var translation in DefaultTranslations)
            {
                UnturnedChat.Say(up, Translate(up, translation.Id), color);
            }
        }
Example #6
0
 private void Events_OnPlayerConnected(Rocket.Unturned.Player.UnturnedPlayer player)
 {
     if (player.HasPermission("feed.main"))
     {
         player.Hunger = 0;
         player.Thirst = 0;
     }
     else
     {
         Logger.Log("The player who has joined does not have feed.main permissions!", ConsoleColor.White);
     }
 }
 public void Execute(IRP caller, string[] command)
 {
     if (caller is UP)
     {
         UP up = (UP)caller;
         if (command.Length == 1)
         {
             if (!TryFindPlayer(command[0], out UP target))
             {
                 SendChat(up, $"{Instance.DefaultTranslations.Translate("ErrorIncorrectPlayer")}", Color.white);
                 return;
             }
             target.Player.Heal();
             SendChat(up, $"{Instance.DefaultTranslations.Translate("SuccessfullyHealedPlayer", target.CharacterName)}", Color.white);
             if (Config.MessageHeal)
             {
                 SendChat(target, $"{Instance.DefaultTranslations.Translate("YouWasHealed")}", Color.white);
             }
         }
         else if (command.Length == 0)
         {
             up.Player.Heal();
             SendChat(up, $"{Instance.DefaultTranslations.Translate("SuccessfullyHealedYourself")}", Color.white);
         }
         else
         {
             SendChat(up, $"{Syntax}", Color.white);
         }
     }
     else
     {
         if (command.Length == 1)
         {
             if (!TryFindPlayer(command[0], out UP target))
             {
                 SendConsole($"{Instance.DefaultTranslations.Translate("ErrorIncorrectPlayer")}", ConsoleColor.White);
                 return;
             }
             target.Player.Heal();
             SendConsole($"{Instance.DefaultTranslations.Translate("SuccessfullyHealedPlayer", target.CharacterName)}", ConsoleColor.White);
             if (Config.MessageHeal)
             {
                 SendChat(target, $"{Instance.DefaultTranslations.Translate("YouWasHealed")}", Color.white);
             }
         }
         else
         {
             SendConsole($"{Syntax}", ConsoleColor.White);
         }
     }
 }
Example #8
0
 public void ResetLicense(Rocket.Unturned.Player.UnturnedPlayer player)
 {
     try
     {
         MySqlConnection connection = CreateConnection();
         MySqlCommand    command    = connection.CreateCommand();
         command.CommandText = "update `" + LPXRemastered.Instance.Configuration.Instance.DatabaseTableName + "` set `permission` = '' where `steamId` = '" + player.Id + "'";
         connection.Open();
         command.ExecuteScalar();
         connection.Close();
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
 }
Example #9
0
        private void UnturnedPlayerEvents_OnPlayerChatted(Rocket.Unturned.Player.UnturnedPlayer player, ref UnityEngine.Color color, string message, SDG.Unturned.EChatMode chatMode, ref bool cancel)
        {
            ChatControlPlayerComponent component = player.GetComponent <ChatControlPlayerComponent>();

            if (!player.HasPermission("ChatControl.IgnoreBadwords"))
            {
                foreach (string badword in ChatControl.Instance.Configuration.Instance.Badwords)
                {
                    if (message.ToLower().Contains(badword.ToLower()))
                    {
                        UnturnedChat.Say(player, Translate("badword_detected", badword, ++component.Warnings), MessageColor);
                        cancel = true;
                        break;
                    }
                }
            }

            if (Configuration.Instance.WarningsBeforeKick > 0 && component.Warnings >= Configuration.Instance.WarningsBeforeKick)
            {
                player.Kick(Translate("kick_ban_reason"));
                return;
            }
            if (Configuration.Instance.WarningsBeforeBan > 0 && component.Warnings >= Configuration.Instance.WarningsBeforeBan)
            {
                player.Ban(Translate("kick_ban_reason"), Configuration.Instance.BanDuration);
                return;
            }



            if (!player.HasPermission("ChatControl.IgnoreMute"))
            {
                if (component.Warnings >= Configuration.Instance.WarningsBeforeMute)
                {
                    component.IsMuted = true;
                }
            }

            if (component.IsMuted)
            {
                cancel = true;
                UnturnedChat.Say(player, Translate("you_are_muted"), MessageColor);
                return;
            }
        }
Example #10
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            Rocket.Unturned.Player.UnturnedPlayer player = (Rocket.Unturned.Player.UnturnedPlayer)caller;
            if (player == null)
            {
                return;
            }
            foreach (VaultStorage vaults in Uber_VaultS.vaultList)
            {
                if (vaults.SteamID == player.CSteamID)
                {
                    byte            x, y;
                    ushort          plant, index;
                    BarricadeRegion regionBarricade;
                    if (BarricadeManager.tryGetInfo(vaults.Locker, out x, out y, out plant, out index, out regionBarricade))
                    {
                        InteractableStorage IStorage = (InteractableStorage)regionBarricade.drops[index].interactable;
                        IStorage.isOpen = true;
                        IStorage.opener = player.Player;
                        //IStorage.name = "U" + player.CSteamID.ToString();

                        if (vaults.alreadyOpened == false)
                        {
                            IStorage.items.resize((byte)vaults.SizeX, (byte)vaults.SizeY);
                            IStorage.items.clear();
                            if (vaults.ItemList.getItemCount() > 0)
                            {
                                for (byte i = 0; i < vaults.ItemList.getItemCount(); i++)
                                {
                                    ItemJar currentItemJar = vaults.ItemList.getItem(i);
                                    Item    CurrentItem    = currentItemJar.item;
                                    IStorage.items.addItem(vaults.ItemList.getItem(i).x, vaults.ItemList.getItem(i).y, vaults.ItemList.getItem(i).rot, vaults.ItemList.getItem(i).item);
                                }
                            }
                            vaults.alreadyOpened = true;
                        }

                        player.Inventory.isStoring = true;
                        player.Inventory.storage   = IStorage;
                        player.Inventory.updateItems(PlayerInventory.STORAGE, IStorage.items);
                        player.Inventory.sendStorage();
                    }
                }
            }
        }
        public void Execute(IRP caller, string[] command)
        {
            UP up = (UP)caller;

            if (command.Length == 1)
            {
                if (command[0] == "*")
                {
                    foreach (var pl in Provider.clients)
                    {
                        pl.player.Heal();
                        if (Config.MessageHeal)
                        {
                            SendChat(UP.FromSteamPlayer(pl), $"{Instance.DefaultTranslations.Translate("YouWasHealed")}", Color.white);
                        }
                    }
                    SendChat(up, $"{Instance.DefaultTranslations.Translate("SuccessfullyHealed")}", Color.white);
                }
                else
                {
                    if (int.Parse(command[0]) > 0 && int.Parse(command[0]) <= Config.MaximumRadius)
                    {
                        var pls = Provider.clients.FindAll(x => Vector3.Distance(up.Position, UP.FromSteamPlayer(x).Position) <= int.Parse(command[0]) && x.playerID.steamID.m_SteamID != up.CSteamID.m_SteamID);
                        foreach (var pl in pls)
                        {
                            pl.player.Heal();
                            if (Config.MessageHeal)
                            {
                                SendChat(UP.FromSteamPlayer(pl), $"{Instance.DefaultTranslations.Translate("YouWasHealed")}", Color.white);
                            }
                        }
                        SendChat(up, $"{Instance.DefaultTranslations.Translate("SuccessfullyHealedRadius", pls.Count, command[0])}", Color.white);
                    }
                    else
                    {
                        SendChat(up, $"{Instance.DefaultTranslations.Translate("IncorrectRadius", Config.MaximumRadius)}", Color.white);
                    }
                }
            }
            else
            {
                SendChat(up, $"{Syntax}", Color.white);
            }
        }
Example #12
0
 public static bool TryFindPlayer(string parameter, out UP target)
 {
     if (ulong.TryParse(parameter, out ulong SID))
     {
         target = UP.FromCSteamID(new CSteamID(SID));
     }
     else
     {
         target = UP.FromName(parameter);
     }
     if (target != null)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #13
0
        public void PlayerDisconnect(Rocket.Unturned.Player.UnturnedPlayer pPlayer)
        {
            MySqlConnection connection = createConnection();
            MySqlCommand    command    = connection.CreateCommand();

            connection.Open();
            //////////////////
            command.CommandText = "DELETE from `itemlist` WHERE `steamId`='" + pPlayer.CSteamID.ToString() + "';";
            command.ExecuteScalar();
            {
                foreach (VaultStorage store in Uber_VaultS.vaultList)
                {
                    if (store.SteamID == pPlayer.CSteamID)
                    {
                        byte   x, y;
                        ushort plant, index;
                        SDG.Unturned.BarricadeRegion regionBarricade;
                        if (SDG.Unturned.BarricadeManager.tryGetInfo(store.Locker, out x, out y, out plant, out index, out regionBarricade))
                        {
                            SDG.Unturned.InteractableStorage IStorage = (SDG.Unturned.InteractableStorage)regionBarricade.drops[index].interactable;
                            for (byte i = 0; i < IStorage.items.getItemCount(); i++)
                            {
                                SDG.Unturned.ItemJar   iJar   = IStorage.items.getItem(i);
                                SDG.Unturned.Item      Item   = iJar.item;
                                SDG.Unturned.ItemAsset iAsset = (SDG.Unturned.ItemAsset)SDG.Unturned.Assets.find(SDG.Unturned.EAssetType.ITEM, Item.id);

                                string       query = "INSERT INTO `itemlist` (`steamID`, `id`, `quality`, `durability`, `x`, `y`, `rot`, `data`, `data_size`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
                                MySqlCommand cmd   = PrepareCommand(query, new object[] { pPlayer.CSteamID.ToString(), Item.id.ToString(), Item.quality, Item.durability, iJar.x, iJar.y, iJar.rot, Item.metadata, Item.metadata.Length }, connection);
                                cmd.ExecuteNonQuery();
                            }
                        }

                        SDG.Unturned.BarricadeManager.damage(store.Locker, 30000f, 1, false);
                        //SDG.Unturned.BarricadeManager.Destroy(store.Locker.gameObject);
                        Uber_VaultS.vaultList.Remove(store);
                        break;
                    }
                }
            }
            //////////////////
            connection.Close();
        }
 void FixedUpdate()
 {
     if ((DateTime.Now - c).TotalSeconds >= 0.5)
     {
         var untplayer = UP.FromPlayer(player);
         var steamid   = untplayer.CSteamID;
         if (Pos != lastPos)
         {
             dict.TryGetValue(steamid, out var value);
             lastPos = Pos;
             var x = Math.Ceiling(untplayer.Position.x).ToString();
             var y = Math.Ceiling(untplayer.Position.y).ToString();
             var z = Math.Ceiling(untplayer.Position.z).ToString();
             if (value == 1)
             {
                 EffectManager.sendUIEffect(56843, 3457, steamid, true, x, y, z);
             }
         }
     }
 }
Example #15
0
        private void Events_OnPlayerConnected(Rocket.Unturned.Player.UnturnedPlayer player)
        {
            SetTimer();
            void OnTimedEvent(Object source, ElapsedEventArgs e)
            {
                if (player.HasPermission("queue.pass") == false)
                {
                    if (Provider.clients.Count() >= Configuration.Instance.PlayerLimit)
                    {
                        UnturnedChat.Say(player, QueuePlugin.Instance.Translate("QueueRemind"));
                    }
                }
            }

            void SetTimer()
            {
                // Create a timer with a two second interval.
                aTimer = new System.Timers.Timer(Configuration.Instance.AutoRemind);
                // Hook up the Elapsed event for the timer.
                aTimer.Elapsed  += OnTimedEvent;
                aTimer.AutoReset = true;
                aTimer.Enabled   = true;
            }

            if (Provider.clients.Count() >= Configuration.Instance.PlayerLimit)
            {
                if (player.HasPermission("queue.pass"))
                {
                    UnturnedChat.Say(player, QueuePlugin.Instance.Translate("QueueSucceed"));
                    Logger.Log($"{player.DisplayName} has been let into the server via priority queue!");
                }
                else
                {
                    player.Kick(QueuePlugin.Instance.Translate("ExceedKick", Configuration.Instance.PlayerLimit));
                    Logger.Log($"{player.DisplayName} has been kicked since they do not have priority queue!");
                }
            }
        }
Example #16
0
        internal static void ReportPlayer(Rocket.Unturned.Player.UnturnedPlayer player)
        {
            if (player == null || !working)
            {
                return;
            }

            new Thread(() =>
            {
                try
                {
                    var httpRequest = (HttpWebRequest)WebRequest.Create(string.Format(REPORT_URL, 2));

                    var dataBuilder = new StringBuilder("data=");

                    dataBuilder.Append(string.Join(";", new[] {
                        player.CSteamID.ToString()
                    }));

                    var data = Encoding.ASCII.GetBytes(dataBuilder.ToString());

                    httpRequest.Method        = "POST";
                    httpRequest.ContentType   = "application/x-www-form-urlencoded";
                    httpRequest.ContentLength = data.Length;

                    using (var stream = httpRequest.GetRequestStream())
                    {
                        stream.Write(data, 0, data.Length);
                    }
                }
                catch (Exception)
                {
                    // ignored
                }
            }).Start();
        }
 private void Events_OnPlayerConnected(Rocket.Unturned.Player.UnturnedPlayer player)
 {
     player.Player.gameObject.getOrAddComponent <SpeedSetterComponent>();
 }
Example #18
0
 public static void SendChat(UP up, string text, Color color)
 {
     ChatManager.serverSendMessage($"<b><color=green>[HealingBall]</color> {text}</b>", color, null, up.SteamPlayer(), EChatMode.SAY, "", true);
 }
        private void OnPlayerDisconnected(UP player)
        {
            var steamid = player.CSteamID;

            dict.Remove(steamid);
        }
Example #20
0
 public void Execute(IRP caller, string[] command)
 {
     if (caller is UP)
     {
         UP up = (UP)caller;
         if (command.Length == 2)
         {
             var health = int.Parse(command[1]);
             if (health == 0)
             {
                 SendChat(up, $"{Instance.DefaultTranslations.Translate("ErrorIncorrectCount")}", Color.white);
                 return;
             }
             if (!TryFindPlayer(command[0], out UP target))
             {
                 SendChat(up, $"{Instance.DefaultTranslations.Translate("ErrorIncorrectPlayer")}", Color.white);
                 return;
             }
             if (target.Health < health)
             {
                 target.Heal((byte)(health - int.Parse(target.Health.ToString())));
             }
             else
             {
                 target.Damage((byte)(int.Parse(target.Health.ToString()) - health), Vector3.zero, EDeathCause.PUNCH, ELimb.SKULL, CSteamID.Nil);
                 target.Player.life.serverSetBleeding(false);
             }
             SendChat(up, $"{Instance.DefaultTranslations.Translate("SuccessfullySetHealth", target.CharacterName, health)}", Color.white);
             if (Config.MessageSetHealth)
             {
                 SendChat(target, $"{Instance.DefaultTranslations.Translate("HealthWasChanged", health)}", Color.white);
             }
         }
         else
         {
             SendChat(up, $"{Syntax}", Color.white);
         }
     }
     else
     {
         if (command.Length == 2)
         {
             var health = int.Parse(command[1]);
             if (health == 0)
             {
                 SendConsole($"{Instance.DefaultTranslations.Translate("ErrorIncorrectCount")}", ConsoleColor.White);
                 return;
             }
             if (!TryFindPlayer(command[0], out UP target))
             {
                 SendConsole($"{Instance.DefaultTranslations.Translate("ErrorIncorrectPlayer")}", ConsoleColor.White);
                 return;
             }
             if (target.Health < health)
             {
                 target.Heal((byte)(health - int.Parse(target.Health.ToString())));
             }
             else
             {
                 target.Damage((byte)(int.Parse(target.Health.ToString()) - health), Vector3.zero, EDeathCause.KILL, ELimb.LEFT_ARM, CSteamID.Nil);
                 target.Player.life.serverSetBleeding(false);
             }
             SendConsole($"{Instance.DefaultTranslations.Translate("SuccessfullySetHealth", target.CharacterName, health)}", ConsoleColor.White);
             if (Config.MessageSetHealth)
             {
                 SendChat(target, $"{Instance.DefaultTranslations.Translate("HealthWasChanged", health)}", Color.white);
             }
         }
         else
         {
             SendConsole($"{Syntax}", ConsoleColor.White);
         }
     }
 }
Example #21
0
        public void PlayerConnect(Rocket.Unturned.Player.UnturnedPlayer pPlayer)
        {
            MySqlConnection connection = createConnection();
            MySqlCommand    command    = connection.CreateCommand();

            connection.Open();
            //////////////////
            command.CommandText = "select * from `itemlist` WHERE `steamId`='" + pPlayer.CSteamID.ToString() + "';";
            SDG.Unturned.Items ItemListN = new SDG.Unturned.Items(0);
            MySqlDataReader    reader    = command.ExecuteReader();

            while (reader.Read())
            {
                SDG.Unturned.Item NItem = new SDG.Unturned.Item(ushort.Parse((string)reader["id"], CultureInfo.InvariantCulture), 1, (byte)(int)reader["quality"]);
                NItem.durability = (byte)(int)reader["durability"];

                ItemListN.addItem((byte)(int)reader["x"], (byte)(int)reader["y"], (byte)(int)reader["rot"], NItem);

                SDG.Unturned.ItemAsset ia = (SDG.Unturned.ItemAsset)SDG.Unturned.Assets.find(SDG.Unturned.EAssetType.ITEM, NItem.id);
                int metadataSize          = reader.GetInt32("data_size");
                if (metadataSize > 0)
                {
                    byte[] metadata = new byte[metadataSize];
                    reader.GetBytes(reader.GetOrdinal("data"), 0, metadata, 0, metadataSize);
                    NItem.metadata = metadata;
                }
            }
            reader.Close();

            command.CommandText = "select * from `vaults`;";
            SDG.Unturned.Barricade NewBarricade  = new SDG.Unturned.Barricade(366);
            UnityEngine.Transform  NewBTransform = SDG.Unturned.BarricadeManager.dropBarricade(NewBarricade, null, new UnityEngine.Vector3(-20, -20, -20), 0, 0, 0, ulong.Parse(pPlayer.Id), 29832);
            reader = command.ExecuteReader();
            while (reader.Read())
            {
                if ((string)reader["steamId"] == pPlayer.CSteamID.ToString())
                {
                    //Create new vaultstorage in home list
                    Uber_VaultS.vaultList.Add(new VaultStorage()
                    {
                        SizeX         = (int)reader["sizex"],
                        SizeY         = (int)reader["sizey"],
                        Player        = pPlayer,
                        SteamID       = pPlayer.CSteamID,
                        Locker        = NewBTransform,
                        alreadyOpened = false,
                        ItemList      = ItemListN
                    });
                    reader.Close();
                    connection.Close();
                    return;
                }
            }
            reader.Close();

            ////////////////// ////////////////// ////////////////// ////////////////// ////////////////// //////////////////
            //In this case, no vault was found to be saved. Need to make a vault and push to db
            command.CommandText = "INSERT INTO `vaults` (`steamId`, `sizex`, `sizey`) VALUES ('" + pPlayer.CSteamID.ToString() + "', '3', '2');";
            command.ExecuteScalar();
            {
                Uber_VaultS.vaultList.Add(new VaultStorage()
                {
                    SizeX         = 3,
                    SizeY         = 2,
                    Player        = pPlayer,
                    SteamID       = pPlayer.CSteamID,
                    Locker        = NewBTransform,
                    alreadyOpened = false
                });
            }
            //////////////////
            connection.Close();
        }