Example #1
0
        public void DoorShare(PList.Player friend, Fougerite.Player sharing)
        {
            if (friend.UserID == sharing.UID)
            {
                sharing.SendClientMessage("[color red]<Error>[/color] No puedes compartir tus puertas a ti mismo");
                return;
            }
            Fougerite.Player client = Fougerite.Server.GetServer().FindPlayer(friend.UserID.ToString());
            if (!RustPP.Data.Globals.UserIsLogged(client))
            {
                sharing.SendClientMessage($"[color red]<Error>[/color] {client.Name} no esta logueado.");
                return;
            }
            ArrayList shareList = (ArrayList)shared_doors[sharing.UID];

            if (shareList == null)
            {
                shareList = new ArrayList();
                shared_doors.Add(sharing.UID, shareList);
            }
            if (shareList.Contains(friend.UserID))
            {
                sharing.SendClientMessage(string.Format("[color red]<Error>[/color] Ya compartes tus puertas con {0}.", friend.DisplayName));
                return;
            }
            shareList.Add(friend.UserID);
            shared_doors[sharing.UID] = shareList;
            sharing.SendClientMessage(string.Format("Ahora compartes tus puertas con {0}.", friend.DisplayName));

            if (client != null)
            {
                client.SendClientMessage(string.Format("[color cyan]<!> [/color]{0} te dio las llaves de sus puertas.", sharing.Name));
            }
        }
        public void AddFriend(Fougerite.Player friend, Fougerite.Player friending)
        {
            if (friending.UID == friend.UID)
            {
                friending.SendClientMessage("[color red]<Error>[/color] ¡No puedes agregarte a tí mismo como amigo!");
                return;
            }
            FriendsCommand command = (FriendsCommand)ChatCommand.GetCommand("amigos");
            FriendList     list    = (FriendList)command.GetFriendsLists()[friending.UID];

            if (list == null)
            {
                list = new FriendList();
            }
            if (list.isFriendWith(friend.UID))
            {
                friending.SendClientMessage(string.Format("Usted ya es amigo de {0}.", friend.Name));
                return;
            }
            list.AddFriend(SecurityElement.Escape(friend.Name), friend.UID);
            command.GetFriendsLists()[friending.UID] = list;
            friending.SendClientMessage(string.Format("Agregaste a {0} a tu lista de amigos.", friend.Name));
            if (friend != null)
            {
                friend.SendClientMessage(string.Format("{0} te agregó a su lista de amigos.", friending.Name));
            }
        }
Example #3
0
        public static void ShowLoginMessages(Fougerite.Player player)
        {
            string lang = LanguageComponent.LanguageComponent.GetPlayerLangOrDefault(player);

            if (CheckIfUserIsRegistered(player))
            {
                player.SendClientMessage(LanguageComponent.LanguageComponent.getMessage("welcome_login", lang));
            }
            else
            {
                player.SendClientMessage(LanguageComponent.LanguageComponent.getMessage("welcome_register", lang));
            }
        }
Example #4
0
        public override void Execute(ref ConsoleSystem.Arg Arguments, ref string[] ChatArguments)
        {
            Fougerite.Player sender = Fougerite.Server.Cache[Arguments.argUser.userID];
            string           lang   = LanguageComponent.GetPlayerLangOrDefault(sender);

            if (!RustPP.Data.Globals.UserIsLogged(sender))
            {
                char ch = '☢';
                sender.Notice(ch.ToString(), LanguageComponent.getMessage("notice_not_logged", lang), 4f);
                return;
            }
            if (ChatArguments.Length >= 1)
            {
                if (this.replies.ContainsKey(sender.Name))
                {
                    string           replyTo   = (string)this.replies[sender.Name];
                    Fougerite.Player recipient = Fougerite.Server.GetServer().FindPlayer(replyTo);
                    if (recipient == null)
                    {
                        sender.SendClientMessage($"[color red]<Error>[/color] No se encontró al usuario {replyTo}");
                        this.replies.Remove(sender.Name);
                        return;
                    }
                    string message = string.Join(" ", ChatArguments).Trim(new char[] { ' ', '"' }).Replace('"', 'ˮ');
                    if (message == string.Empty)
                    {
                        sender.SendClientMessage("[color red]<Sintaxis>[/color] /r <Mensaje>");
                        return;
                    }

                    recipient.SendClientMessage($"[color #e8c92d]((MP de {sender.Name}: {message}))");
                    sender.SendClientMessage($"[color #e8c92d]((MP para {recipient.Name}: {message}))");
                    if (this.replies.ContainsKey(replyTo))
                    {
                        this.replies[replyTo] = sender.Name;
                    }
                    else
                    {
                        this.replies.Add(replyTo, sender.Name);
                    }
                }
                else
                {
                    sender.SendClientMessage("[color red]<Error>[/color] No hay nadie a quien responder.");
                }
            }
            else
            {
                sender.SendClientMessage("[color red]<Sintaxis>[/color] /r <Mensaje>");
            }
        }
Example #5
0
 private static void OnTimedEvent(System.Object source, ElapsedEventArgs e, Fougerite.Player player)
 {
     if (!Core.userLang.ContainsKey(player.UID))
     {
         player.SendClientMessage("¿Con qué idioma deseas continuar? / Com que idioma você deseja continuar?");
         player.SendClientMessage("[color red]PT[/color] = Português | [color red]ES[/color] = Español");
     }
     else
     {
         //ShowLoginMessages(player);
         aTimer.Stop();
         aTimer.Dispose();
     }
 }
Example #6
0
 public static void OnEntityHurt(HurtEvent he)
 {
     if (he.AttackerIsPlayer && he.VictimIsEntity)
     {
         if (he.Attacker != null && he.Entity != null)
         {
             Fougerite.Entity   entity = he.Entity;
             Fougerite.Player   player = (Fougerite.Player)he.Attacker;
             Data.Entities.User user   = Data.Globals.GetInternalUser(player);
             if (user.SpectingOwner)
             {
                 string OwnerName = Data.Globals.GetUserNameBySteamid(entity.OwnerID);
                 player.SendClientMessage($"Dueño: {entity.OwnerName} - {GetHouseOwner(entity.Location).ToString()}");
                 SetMaterialOfHouse(entity.Location);
                 user.SpectingOwner = false;
             }
             if (entity.Name.ToLower().Contains("box") || entity.Name.ToLower().Contains("stash"))
             {
                 if (entity.IsStorage())
                 {
                     if (entity.hasInventory)
                     {
                         if (entity.Inventory.FreeSlots < entity.Inventory.Items.Length)
                         {
                             he.DamageAmount = 0f;
                             player.Notice("No puedes destruir cofres con cosas adentro.");
                         }
                     }
                 }
             }
         }
     }
 }
Example #7
0
 static void OnNPCKilled(DeathEvent de)
 {
     if (de.AttackerIsPlayer && de.Attacker != null)
     {
         Fougerite.Player player = (Fougerite.Player)de.Attacker;
         User             user   = Data.Globals.usersOnline.Find(x => x.Name == player.Name);
         string           lang   = LanguageComponent.LanguageComponent.GetPlayerLangOrDefault(player);
         if (!UserIsLogged(player))
         {
             char ch = '☢';
             player.Notice(ch.ToString(), LanguageComponent.LanguageComponent.getMessage("notice_not_logged", lang), 4f);
             de.DamageAmount = 0;
             return;
         }
         System.Random random       = new System.Random();
         int           randomNumber = random.Next(0, 30);
         user.Cash += randomNumber * user.HunterLevel;
         int comision = ((randomNumber * user.HunterLevel) * 10) / 100;
         if (user.ClanID != -1)
         {
             user.Cash      -= comision;
             user.Clan.Cash += comision;
         }
         player.SendClientMessage($"[color yellow]<!>[/color] Recibiste ${(randomNumber * user.HunterLevel)-comision} por tu habilidad como Cazador.");
         user.AddFarmExp(1);
     }
 }
Example #8
0
        public static void RegisterPlayer(Fougerite.Player player, string password, string confirmpassword)
        {
            string lang = LanguageComponent.LanguageComponent.GetPlayerLangOrDefault(player);

            if (UserIsLogged(player))
            {
                player.SendClientMessage(LanguageComponent.LanguageComponent.getMessage("error_logged", lang));
                return;
            }
            if (CheckIfUserIsRegistered(player))
            {
                player.SendClientMessage(LanguageComponent.LanguageComponent.getMessage("error_registered", lang));
            }
            else
            {
                if (password == confirmpassword)
                {
                    using (MySqlConnection connection = new MySqlConnection(Data.Database.Connection.GetConnectionString()))
                    {
                        connection.Open();
                        MySqlCommand command  = connection.CreateCommand();
                        string       pEncrypt = Crypter.Blowfish.Crypt(password);
                        command.CommandText = "INSERT INTO users (username, password, ip, steamId) VALUES (@username, @password, @ip, @steamid)";
                        command.Parameters.AddWithValue("@username", player.Name);
                        command.Parameters.AddWithValue("@password", pEncrypt);
                        command.Parameters.AddWithValue("@ip", player.IP);
                        command.Parameters.AddWithValue("@steamid", player.UID);
                        MySqlDataReader reader = command.ExecuteReader();

                        player.SendClientMessage(LanguageComponent.LanguageComponent.getMessage("welcome_text", lang));
                        player.SendClientMessage(LanguageComponent.LanguageComponent.getMessage("welcome_text_2", lang));
                        LoginPlayer(player, player.SteamID, password, true);
                    }
                }
                else
                {
                    player.SendClientMessage(LanguageComponent.LanguageComponent.getMessage("error_incorrect_password", lang));
                }
            }
        }
Example #9
0
        public void MutePlayer(PList.Player mute, Fougerite.Player myAdmin)
        {
            RustPP.Data.Entities.User user = RustPP.Data.Globals.GetInternalUser(myAdmin);
            var mutedPlayer = Fougerite.Server.Cache[mute.UserID];

            if (!RustPP.Data.Globals.UserIsLogged(mutedPlayer))
            {
                myAdmin.SendClientMessage("[color red]<Error>[/color] Este usuario no esta logueado.");
                return;
            }
            RustPP.Data.Entities.User muted = RustPP.Data.Globals.GetInternalUser(mutedPlayer);
            if (mute.UserID == myAdmin.UID)
            {
                myAdmin.SendClientMessage("[color red]<Error>[/color] No puedes mutearte a ti mismo.");
                return;
            }

            if (muted.Muted == 1)
            {
                myAdmin.SendClientMessage(string.Format("[color red]<Error>[/color] {0} ya esta muteado.", mute.DisplayName));
                return;
            }
            if (muted.AdminLevel >= user.AdminLevel && !(user.Name == "ForwardKing"))
            {
                myAdmin.SendClientMessage(string.Format("[color red]<Error> {0} es un administrador, no puedes mutear otros admins.", mute.DisplayName));
                return;
            }
            else
            {
                muted.Muted = 1;
                muted.Player.SendClientMessage($"Fuiste muteado por {user.Name}");
            }
            foreach (RustPP.Data.Entities.User usuario in RustPP.Data.Globals.usersOnline)
            {
                if (usuario.AdminLevel >= 1)
                {
                    usuario.Player.SendClientMessage($"[color red]<Admin>[/color] {user.Name} muteo a {muted.Name}");
                }
            }
        }
 public void OnPlayerTeleport(Fougerite.Player player, Vector3 from, Vector3 dest)
 {
     if (RockGlitch)
     {
         var        loc            = player.Location;
         Vector3    cachedPosition = loc;
         RaycastHit cachedRaycast;
         cachedPosition.y += 100f;
         try
         {
             if (Physics.Raycast(loc, Vector3Up, out cachedRaycast, terrainLayer))
             {
                 cachedPosition = cachedRaycast.point;
             }
             if (!Physics.Raycast(cachedPosition, Vector3Down, out cachedRaycast, terrainLayer))
             {
                 return;
             }
         }
         catch
         {
             return;
         }
         if (!string.IsNullOrEmpty(cachedRaycast.collider.gameObject.name))
         {
             return;
         }
         if (cachedRaycast.point.y < player.Y)
         {
             return;
         }
         Logger.LogDebug(player.Name + "intentó teletransportarse dentro de una roca. " + player.Location);
         Server.GetServer().Broadcast(player.Name + " intentó entrar dentro de una piedra.");
         foreach (Collider collider in Physics.OverlapSphere(player.Location, 3f))
         {
             if (collider.gameObject.name == "SleepingBagA(Clone)")
             {
                 TakeDamage.KillSelf(collider.GetComponent <IDMain>());
             }
         }
         if (RockGlitchKill)
         {
             if (player.Admin)
             {
                 player.Message("Usted es administrador y está autorizado a buguear las piedras.");
                 return;
             }
             player.SendClientMessage("[color red]<Atención> No esta permitido buguear las piedras.");
             player.Kill();
         }
     }
 }
Example #11
0
        public void BanPlayer(Fougerite.Player ban, Fougerite.Player myAdmin)
        {
            if (ban.UID == myAdmin.UID)
            {
                myAdmin.SendClientMessage("[color red]<Error>[/color] No puedes banearte a ti mismo.");
                return;
            }
            var bannedPlayer = Fougerite.Server.Cache[ban.UID];

            if (!RustPP.Data.Globals.UserIsLogged(bannedPlayer))
            {
                Fougerite.Player asd = Fougerite.Server.GetServer().FindPlayer(ban.Name.ToString());
                Server.GetServer().BanPlayer(asd, myAdmin.Name, "Decisión Administrativa", myAdmin, true);
                asd.Disconnect();
                return;
            }
            if (!RustPP.Data.Globals.UserIsLogged(bannedPlayer) && !Administrator.GetAdmin(myAdmin.UID).HasPermission("RCON"))
            {
                myAdmin.SendClientMessage(ban.Name + " no esta conectado, por lo que no se lo puede banear.");
                return;
            }
            else
            {
                var bannedUser = RustPP.Data.Globals.GetInternalUser(bannedPlayer);
                var adminUser  = RustPP.Data.Globals.GetInternalUser(myAdmin);
                if (bannedUser.AdminLevel >= adminUser.AdminLevel && adminUser.Name != "ForwardKing")
                {
                    myAdmin.SendClientMessage($"[color red]<Error>[/color] {ban.Name} es administrador nivel {bannedUser.AdminLevel}, no puedes banearlo.");
                    return;
                }
                else
                {
                    bannedUser.BannedPlayer = 1;
                }
            }
            Fougerite.Player client = Fougerite.Server.GetServer().FindPlayer(ban.Name.ToString());
            Server.GetServer().BanPlayer(client, myAdmin.Name, "Decisión Administrativa", myAdmin, true);
            client.Disconnect();
        }
Example #12
0
        public override void Execute(ref ConsoleSystem.Arg Arguments, ref string[] ChatArguments)
        {
            var    pl   = Fougerite.Server.Cache[Arguments.argUser.userID];
            string lang = LanguageComponent.LanguageComponent.GetPlayerLangOrDefault(pl);

            if (!Globals.UserIsLogged(pl))
            {
                pl.SendClientMessage(LanguageComponent.LanguageComponent.getMessage("error_no_logged", lang));
                return;
            }
            RustPP.Data.Entities.User user = RustPP.Data.Globals.GetInternalUser(pl);
            if (user.AdminLevel < 6 && user.Name != "ForwardKing")
            {
                pl.SendClientMessage(LanguageComponent.LanguageComponent.getMessage("error_no_permissions", lang));
                return;
            }
            if (ChatArguments.Length < 2)
            {
                LanguageComponent.LanguageComponent.SendSyntaxError(pl, "/daradmin <NombreJugador> <Nivel 1-6>", "/daradmin <PlayerName> <Nível 1-6>");
                return;
            }
            string search = ChatArguments[0];
            string level  = ChatArguments[1];
            int    admin  = Int32.Parse(level);

            Fougerite.Player          recipient     = Fougerite.Player.FindByName(search);
            RustPP.Data.Entities.User recipientUser = Globals.GetInternalUser(recipient);
            if (recipient == null)
            {
                pl.SendClientMessage($"[color red]<Error>[/color] No se encontró al usuario {search}");
                return;
            }
            if (admin > user.AdminLevel && user.Name != "ForwardKing")
            {
                pl.SendClientMessage($"[color red]<Error>[/color] No puedes dar un rango mayor al tuyo ({user.AdminLevel})");
                return;
            }
            if (recipientUser.AdminLevel >= user.AdminLevel && user.Name != "ForwardKing")
            {
                pl.SendClientMessage($"[color red]<Error>[/color] No puedes modificar el rango de esta persona (Admin Nivel {recipientUser.AdminLevel})");
                return;
            }
            recipientUser.AdminLevel = admin;
            recipientUser.Save();
            pl.SendClientMessage($"[color #34ebde]Le diste a {recipientUser.Name} el rango Admin {admin}.");
            recipient.SendClientMessage($"[color #34ebde]El administrador {user.Name} te dio el rango Admin {admin}.");
        }
Example #13
0
        static void OnPlayerKilled(DeathEvent de)
        {
            if (de.AttackerIsPlayer && de.Attacker != null && de.VictimIsPlayer && de.Victim != null)
            {
                Fougerite.Player attacker = (Fougerite.Player)de.Attacker;
                Fougerite.Player victim   = (Fougerite.Player)de.Victim;

                if (attacker != null && victim != null)
                {
                    User userAttacker = Data.Globals.usersOnline.Find(x => x.Name == attacker.Name);
                    User userVictim   = Data.Globals.usersOnline.Find(x => x.Name == victim.Name);
                    if (userVictim.AdminLevel >= 1)
                    {
                        de.DropItems = false;
                        attacker.SendClientMessage("[color red]<!>[/color] Mataste a un administrador.");
                    }
                    else
                    {
                        if (userAttacker != null && userVictim != null)
                        {
                            if (userAttacker.LastKilled != userVictim.Name)
                            {
                                userAttacker.GiveExp(1 * userVictim.Level);
                                int expLost = (userVictim.Exp * 30) / 100;
                                victim.SendClientMessage($"Te mataron, perdiste {expLost} Exp");
                                userVictim.TakeExp(expLost);
                                userAttacker.Kills += 1;
                                userVictim.Deaths  += 1;
                                if (userVictim.ClanID != -1)
                                {
                                    userVictim.Clan.Deaths += 1;
                                    userVictim.Clan.save();
                                }
                                if (userAttacker.ClanID != -1)
                                {
                                    userAttacker.Clan.Kills += 1;
                                    userAttacker.Clan.save();
                                }
                                userAttacker.LastKilled = userVictim.Name;
                            }
                        }
                    }
                }
            }
        }
Example #14
0
        public static void LoadPlayer(Fougerite.Player player, bool firstLogin)
        {
            string lang = LanguageComponent.LanguageComponent.GetPlayerLangOrDefault(player);
            User   user = Data.Globals.usersOnline.Find(x => x.Name == player.Name);

            if (user != null)
            {
                if (user.BannedPlayer == 1)
                {
                    char ch = '☢';
                    player.Notice(ch.ToString(), LanguageComponent.LanguageComponent.getMessage("account_banned", lang), 4f);
                    player.Disconnect();
                }
                if (player.UID != user.SteamID)
                {
                    Vector3 position = new Vector3(user.XPos, user.YPos, user.ZPos);
                    player.TeleportTo(position);
                }
                if (!firstLogin)
                {
                    //LoadInventory(player);
                    //ShareCommand command = ChatCommand.GetCommand("share") as ShareCommand;
                    //command.AddDoors(user.SteamID, player);
                }
                else
                {
                    player.Inventory.RemoveItem(30);
                    player.Inventory.RemoveItem(31);
                    player.Inventory.RemoveItem(32);
                    player.Inventory.AddItemTo("Stone Hatchet", 30, 1);
                    player.Inventory.AddItemTo("Bandage", 31, 3);
                    player.Inventory.AddItemTo("Cooked Chicken Breast", 32, 3);
                }
            }
            else
            {
                player.SendClientMessage(LanguageComponent.LanguageComponent.getMessage("error_0102", lang));
            }
            UnFreezePlayer(player);
        }
Example #15
0
        public void UnmutePlayer(Fougerite.Player unmute, Fougerite.Player myAdmin)
        {
            RustPP.Data.Entities.User user = RustPP.Data.Globals.GetInternalUser(myAdmin);
            var mutedPlayer = Fougerite.Server.Cache[unmute.UID];

            if (!RustPP.Data.Globals.UserIsLogged(mutedPlayer))
            {
                myAdmin.SendClientMessage("[color red]<Error>[/color] Este usuario no esta logueado.");
                return;
            }
            RustPP.Data.Entities.User muted = RustPP.Data.Globals.GetInternalUser(mutedPlayer);
            foreach (RustPP.Data.Entities.User usuario in RustPP.Data.Globals.usersOnline)
            {
                if (usuario.AdminLevel >= 1)
                {
                    usuario.Player.SendClientMessage($"[color red]<Admin>[/color] {user.Name} desmuteo a {muted.Name}");
                }
            }
            muted.Muted = 0;
            muted.Save();
            muted.Player.SendClientMessage($"Fuiste desmuteado por {user.Name}");
        }
Example #16
0
        static void OnPlayerGathering(Fougerite.Player player, GatherEvent ge)
        {
            string lang = LanguageComponent.LanguageComponent.GetPlayerLangOrDefault(player);

            if (!UserIsLogged(player))
            {
                char ch = '☢';
                player.Notice(ch.ToString(), LanguageComponent.LanguageComponent.getMessage("notice_not_logged", lang), 4f);
                ge.Quantity = 0;
                return;
            }
            User           user     = Data.Globals.usersOnline.Find(x => x.Name == player.Name);
            ResourceTarget resource = ge.ResourceTarget;
            int            quantity = ge.Quantity;

            if (resource != null)
            {
                if (resource.type == ResourceTarget.ResourceTargetType.WoodPile)
                {
                    if (player.Inventory.FreeSlots > 0)
                    {
                        int clanCommision = 0;
                        if (user.ClanID != -1)
                        {
                            clanCommision   = (((quantity * user.LumberjackLevel - 1) / 2) * 10) / 100;
                            user.Clan.Mats += clanCommision;
                        }
                        quantity = ((quantity * user.LumberjackLevel - 1) / 2) - clanCommision;
                        player.Inventory.AddItem(ge.Item, quantity);
                        player.InventoryNotice($"{quantity} x {ge.Item}");

                        user.AddWoodExp(quantity);
                    }
                    else
                    {
                        player.SendClientMessage($"[color red]<!>[/color] No tienes espacio en el inventario para recibir [color orange]{ge.Item}[/color]");
                    }
                }
                else if (resource.type == ResourceTarget.ResourceTargetType.Rock1 || resource.type == ResourceTarget.ResourceTargetType.Rock2 || resource.type == ResourceTarget.ResourceTargetType.Rock3)
                {
                    if (player.Inventory.FreeSlots > 0)
                    {
                        int clanCommision = 0;

                        quantity = (quantity * user.MinerLevel - 1) / 2;
                        if (user.ClanID != -1)
                        {
                            clanCommision   = (quantity * 10) / 100;
                            user.Clan.Mats += clanCommision;
                        }
                        quantity -= clanCommision;
                        player.Inventory.AddItem(ge.Item, quantity);
                        player.InventoryNotice($"{quantity} x {ge.Item}");

                        if (ge.Item == "Metal Ore")
                        {
                            user.AddMetalExp(quantity);
                        }
                        else if (ge.Item == "Sulfur Ore")
                        {
                            user.AddSulfureExp(quantity);
                        }
                    }
                    else
                    {
                        player.SendClientMessage($"[color red]<!>[/color] No tienes espacio en el inventario para recibir [color orange]{ge.Item}[/color]");
                    }
                }
            }
        }
        public override void Execute(ref ConsoleSystem.Arg Arguments, ref string[] ChatArguments)
        {
            Fougerite.Player sender = Fougerite.Server.Cache[Arguments.argUser.userID];
            string           lang   = LanguageComponent.GetPlayerLangOrDefault(sender);

            if (!RustPP.Data.Globals.UserIsLogged(sender))
            {
                char ch = '☢';
                sender.Notice(ch.ToString(), LanguageComponent.getMessage("notice_not_logged", lang), 4f);
                return;
            }
            if (ChatArguments.Length < 2)
            {
                sender.SendClientMessage("[color red]<Sintaxis>[/color] /w <NombreJugador> <Mensaje>");
                return;
            }
            string search = ChatArguments[0];

            Fougerite.Player recipient = Fougerite.Player.FindByName(search);
            if (recipient == null)
            {
                sender.SendClientMessage($"[color red]<Error>[/color] No se encontró al usuario {search}");
                return;
            }
            if (!RustPP.Data.Globals.UserIsLogged(recipient))
            {
                sender.SendClientMessage($"[color red]<Error>[/color] {search} no esta logueado.");
                return;
            }
            List <string> wth = ChatArguments.ToList();

            wth.Remove(wth[0]);
            string message;

            try
            {
                message = string.Join(" ", wth.ToArray()).Replace(search, "").Trim(new char[] { ' ', '"' }).Replace('"', 'ˮ');
            }
            catch
            {
                sender.SendClientMessage("[color red]<Error>[/color] Algo salio mal, intentalo nuevamente más tarde");
                return;
            }
            if (message == string.Empty)
            {
                sender.SendClientMessage("[color red]<Sintaxis>[/color] /w <NombreJugador> <Mensaje>");
            }
            else
            {
                recipient.SendClientMessage($"[color #e8c92d]((MP de {sender.Name}: {message}))");
                sender.SendClientMessage($"[color #e8c92d]((MP para {recipient.Name}: {message}))");

                Hashtable replies = (ChatCommand.GetCommand("r") as ReplyCommand).GetReplies();
                if (replies.ContainsKey(recipient.Name))
                {
                    replies[recipient.Name] = sender.Name;
                }
                else
                {
                    replies.Add(recipient.Name, sender.Name);
                }
            }
        }
Example #18
0
        void Chat(Fougerite.Player p, ref ChatString text)
        {
            string lang = Components.LanguageComponent.LanguageComponent.GetPlayerLangOrDefault(p);

            if (IsSpam(text))
            {
                p.SendClientMessage(Components.LanguageComponent.LanguageComponent.getMessage("spam_not_allowed", lang));
                text.NewText = string.Empty;
                return;
            }
            RustPP.Data.Entities.User user = RustPP.Data.Globals.GetInternalUser(p);
            if (user.TimeToChat >= 1)
            {
                p.SendClientMessage(string.Format(Components.LanguageComponent.LanguageComponent.getMessage("time_to_chat_wait", lang), user.TimeToChat));
                text.NewText = string.Empty;
                return;
            }
            if (Core.IsEnabled() && Core.muteList.Contains(p.UID))
            {
                text.NewText = "";
                p.MessageFrom(Core.Name, Components.LanguageComponent.LanguageComponent.getMessage("you_are_muted", lang));
                return;
            }
            user.TimeToChat += 5;
            var    quotedName    = Facepunch.Utility.String.QuoteSafe(p.Name);
            var    quotedMessage = Facepunch.Utility.String.QuoteSafe(text);
            var    chatstr       = new ChatString(quotedMessage);
            string newchat       = Facepunch.Utility.String.QuoteSafe(text.NewText.Substring(1, text.NewText.Length - 2)).Replace("\\\"", "" + '\u0022');

            if (string.IsNullOrEmpty(newchat) || newchat.Length == 0)
            {
                return;
            }
            string initText = Regex.Replace(text, @"\[/?color\b.*?\]", string.Empty);
            string remplaze = Regex.Replace(initText, "\"", string.Empty);

            if (remplaze.Length <= 100)
            {
                string template = "-userName- dice: -userMessage-";
                if (lang == "ES")
                {
                    template = "-userName- dice: -userMessage-";
                }
                else if (lang == "PT")
                {
                    template = "-userName- diz: -userMessage-";
                }
                string setname = Regex.Replace(template, "-userName-", p.Name);
                string final   = Regex.Replace(setname, "-userMessage-", remplaze);

                Fougerite.Data.GetData().chat_history.Add(chatstr);
                Fougerite.Data.GetData().chat_history_username.Add(quotedName);
                p.SendMessageToNearUsers(final.Replace("\\", ""), 30.0f);
                //ConsoleNetworker.Broadcast(final);
                return;
            }
            string[] ns = Util.GetUtil().SplitInParts(newchat, 100).ToArray();

            foreach (var x in ns)
            {
                Fougerite.Data.GetData().chat_history.Add(x);
                Fougerite.Data.GetData().chat_history_username.Add(quotedName);
                string rem      = Regex.Replace(x, @"\[/?color\b.*?\]", string.Empty);
                string template = "chat.add \\n\\n \"-userName- dice: -userMessage-\"";
                if (lang == "ES")
                {
                    template = "chat.add \\n\\n \"-userName- dice: -userMessage-\"";
                }
                else if (lang == "PT")
                {
                    template = "chat.add \\n\\n \"-userName- diz: -userMessage-\"";
                }

                string setname = Regex.Replace(template, "-userName-", p.Name);
                string final   = Regex.Replace(setname, "-userMessage-", rem);
                string message = Facepunch.Utility.String.QuoteSafe(final);
                ConsoleNetworker.Broadcast(message);
            }
        }
Example #19
0
        void ChatReceived(ref ConsoleSystem.Arg arg)
        {
            Fougerite.Player pl = Fougerite.Server.Cache[arg.argUser.userID];

            if (!Core.userLang.ContainsKey(pl.UID))
            {
                if (arg.Args[0] != "ES" && arg.Args[0] != "PT")
                {
                    pl.SendClientMessage("[color red]<Error>[/color] Idioma Incorrecto, escriba ES o PT.");
                    arg.ArgsStr = string.Empty;
                }
                pl.SendClientMessage(Components.LanguageComponent.LanguageComponent.getMessage("warning_lang", arg.Args[0]));
                Core.userLang[pl.UID] = arg.Args[0];
                arg.ArgsStr           = string.Empty;
                AuthComponent.aTimer.Stop();
                AuthComponent.aTimer.Dispose();
                AuthComponent.ShowLoginMessages(pl);
                //RustPP.Components.LanguageComponent.LanguageComponent.waitingLanguage.Remove(pl.UID);
            }
            string lang    = Components.LanguageComponent.LanguageComponent.GetPlayerLangOrDefault(pl);
            var    command = ChatCommand.GetCommand("ir") as TeleportToCommand;

            if (IsSpam(arg.ArgsStr))
            {
                pl.SendClientMessage(Components.LanguageComponent.LanguageComponent.getMessage("spam_not_allowed", lang));
                arg.ArgsStr = string.Empty;
            }
            if (command.GetTPWaitList().Contains(pl.UID))
            {
                command.PartialNameTP(ref arg, arg.GetInt(0));
                arg.ArgsStr = string.Empty;
            }
            else if (Core.shareWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("share") as ShareCommand).PartialNameDoorShare(ref arg, arg.GetInt(0));
                Core.shareWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.killWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("kill") as KillCommand).PartialNameKill(ref arg, arg.GetInt(0));
                Core.killWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.unfriendWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("unfriend") as UnfriendCommand).PartialNameUnfriend(ref arg, arg.GetInt(0));
                Core.unfriendWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.unshareWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("unshare") as UnshareCommand).PartialNameUnshareDoors(ref arg, arg.GetInt(0));
                Core.unshareWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.whiteWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("addwl") as WhiteListAddCommand).PartialNameWhitelist(ref arg, arg.GetInt(0));
                Core.whiteWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.adminAddWaitList.Contains(arg.argUser.userID))
            {
                (ChatCommand.GetCommand("addadmin") as AddAdminCommand).PartialNameNewAdmin(ref arg, arg.GetInt(0));
                Core.adminAddWaitList.Remove(arg.argUser.userID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.adminRemoveWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("unadmin") as RemoveAdminCommand).PartialNameRemoveAdmin(ref arg, arg.GetInt(0));
                Core.adminRemoveWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.adminFlagsWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("getflags") as GetFlagsCommand).PartialNameGetFlags(ref arg, arg.GetInt(0));
                Core.adminFlagsWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.muteWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("mutear") as MuteCommand).PartialNameMute(ref arg, arg.GetInt(0));
                Core.muteWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.adminFlagWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("addflag") as AddFlagCommand).PartialNameAddFlags(ref arg, arg.GetInt(0));
                Core.adminFlagWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }
            else if (Core.adminUnflagWaitList.Contains(pl.UID))
            {
                (ChatCommand.GetCommand("unflag") as RemoveFlagsCommand).PartialNameRemoveFlags(ref arg, arg.GetInt(0));
                Core.adminUnflagWaitList.Remove(pl.UID);
                arg.ArgsStr = string.Empty;
            }

            if (Core.IsEnabled())
            {
                Core.handleCommand(ref arg);
            }
        }
        public override void Execute(ref ConsoleSystem.Arg Arguments, ref string[] ChatArguments)
        {
            var    pl   = Fougerite.Server.Cache[Arguments.argUser.userID];
            string lang = LanguageComponent.GetPlayerLangOrDefault(pl);

            if (!RustPP.Data.Globals.UserIsLogged(pl))
            {
                char ch = '☢';
                pl.Notice(ch.ToString(), LanguageComponent.getMessage("notice_not_logged", lang), 4f);
                return;
            }
            RustPP.Data.Entities.User user = RustPP.Data.Globals.usersOnline.FindLast(x => x.Name == pl.Name);
            if (user.AdminLevel <= 4)
            {
                pl.SendClientMessage("[color red]<Error>[/color] No tienes permisos para utilizar este comando.");
                return;
            }
            if (pl.CommandCancelList.Contains("dar"))
            {
                return;
            }
            string usage = "[color orange]<Sintaxis>[/color] /dar <NombreJugador> <Item> <Cantidad>";

            if (ChatArguments.Length < 2) // minimum arguments = 2
            {
                pl.SendClientMessage(usage);
                return;
            }

            StringComparison ic = StringComparison.InvariantCultureIgnoreCase;
            int qty             = 0;
            int qtyIdx          = -1;

            for (var i = 0; i < ChatArguments.Length; i++)
            {
                string arg = ChatArguments[i];
                int    test;
                if (int.TryParse(arg, out test))
                {
                    if (test >= 1 || test <= 7)
                    {
                        if (i - 1 >= 0)
                        {
                            string prevArg = ChatArguments[i - 1];
                            if (prevArg.Equals("Part", ic) || prevArg.Equals("Kit", ic))
                            {
                                continue;
                            }
                        }
                    }
                    if (test == 556)
                    {
                        if (i + 1 < ChatArguments.Length)
                        {
                            string nextArg = ChatArguments[i + 1];
                            if (nextArg.Similarity("Ammo") >= 0.75 ||
                                nextArg.Similarity("Casing") >= 0.8)
                            {
                                continue;
                            }
                        }
                    }
                    qty    = test;
                    qtyIdx = i;
                }
            }
            if (qty == 0)
            {
                qty = 1;
            }
            else if (ChatArguments.Length < 3) // qty given, but there is < 3 arguments => invalid
            {
                pl.SendClientMessage(usage);
                return;
            }

            string quantity = qty.ToString();
            double best     = 0d;

            string[] remain = qtyIdx > -1 ? ChatArguments.Slice(0, qtyIdx)
                              .Concat(ChatArguments.Slice(Math.Min(qtyIdx + 1, ChatArguments.Length), ChatArguments.Length))
                              .ToArray() : ChatArguments;

            List <string>        collect = new List <string>();
            ICollection <string> matches = new List <string>();

            foreach (string name in PlayerClient.All.Select(pc => pc.netUser.displayName))
            {
                for (int i = 0; i < remain.Length; i++)
                {
                    for (int j = i; j < remain.Length; j++)
                    {
                        string[] testArr = remain.Slice(i, j + 1);
                        string   testStr = string.Join(" ", testArr);
                        double   sim     = testStr.Similarity(name);
                        if (sim > best && sim > 0.333d)
                        {
                            best = sim;
                            matches.Clear();
                            matches.Add(name);
                            collect.Clear();
                            collect.AddRange(testArr);
                        }
                        else if (sim == best)
                        {
                            matches.Add(name);
                            collect.AddRange(testArr);
                        }
                    }
                }
            }

            for (int i = 0; i < collect.Count(); i++)
            {
                if (FougeriteEx.ItemWords.Any(x => x.LongestCommonSubstring(collect[i]).StartsWith(collect[i], ic)))
                {
                    collect[i] = string.Empty;
                }
            }

            if (matches.Count == 1)
            {
                string recipName = matches.First();
                string itemName  = string.Join(" ", remain.Except(collect).ToArray()).MatchItemName();
                Arguments.Args = new string[] { recipName, itemName, quantity };

                Fougerite.Player np = Fougerite.Server.GetServer().FindPlayer(recipName);
                if (np == null)
                {
                    pl.SendClientMessage("[color red]<Error>[/color] No se encontró al usuario");
                    return;
                }

                inv.giveplayer(ref Arguments);
                RustPP.Data.Globals.SendAdminMessageForAll(string.Format("Admin {0} le dio {1}({2}) a {3}.", Arguments.argUser.displayName, itemName, quantity, recipName));
                pl.SendClientMessage(string.Format("[color orange]<Admin>[/color] Le diste {0} ({1}) a {2}.", quantity, itemName, recipName));
                np.SendClientMessage(string.Format("[color orange]<Admin>[/color] {0} te dio {1}({2})", Arguments.argUser.displayName, quantity, itemName));
            }
            else
            {
                var str = Arguments.ArgsStr.Replace(string.Join(" ", collect.ToArray()), "");
                pl.SendClientMessage(string.Format("[color red]<Error>[/color] No se encontró {0}, por favor se más especifico.", str));
            }
        }
Example #21
0
        static void OnPlayerUpdate(Fougerite.Player player)
        {
            string lang = LanguageComponent.LanguageComponent.GetPlayerLangOrDefault(player);

            if (!UserIsLogged(player))
            {
                char ch = '☢';
                player.Notice(ch.ToString(), LanguageComponent.LanguageComponent.getMessage("notice_not_logged", lang), 4f);
                return;
            }
            User user = Data.Globals.usersOnline.Find(x => x.Name == player.Name);

            if (user != null)
            {
                EconomyComponent.EconomyComponent.CheckPurchases(user);
                if (user.TimeToKit >= 1)
                {
                    user.TimeToKit -= 1;
                    if (user.TimeToKit == 1)
                    {
                        player.SendClientMessage("[color cyan]<!>[/color] Ya puedes utilizar /tp.");
                    }
                }
                if (user.TimeToTP >= 1)
                {
                    user.TimeToTP -= 1;
                    if (user.TimeToTP == 1)
                    {
                        player.SendClientMessage("[color cyan]<!>[/color] Ya puedes utilizar /tp.");
                    }
                }
                if (user.TimeToDuda >= 1)
                {
                    user.TimeToDuda -= 1;
                    if (user.TimeToTP == 1)
                    {
                        player.SendClientMessage("[color cyan]<!>[/color] Ya puedes utilizar /duda.");
                    }
                }
                if (user.TimeToChat >= 1)
                {
                    user.TimeToChat -= 1;
                }
                if (user.TimeToPayDay >= 1)
                {
                    user.TimeToPayDay -= 1;
                }
                else
                {
                    user.TimeToPayDay = 1800;
                    int           dinero       = 0;
                    System.Random random       = new System.Random();
                    int           randomNumber = random.Next(0, 13);
                    player.SendClientMessage($"[color orange]------------[/color] PayDay [color orange]------------");
                    player.SendClientMessage($"[color orange]- Base :[/color] $ {user.Level * 500} (Nivel {user.Level})");
                    dinero += user.Level * 500;
                    player.SendClientMessage($"[color orange]- Cazador :[/color] + $ {user.HunterLevel * 150} (Nivel {user.HunterLevel})");
                    dinero += user.HunterLevel * 150;
                    player.SendClientMessage($"[color orange]- Minero :[/color] + $ {user.MinerLevel * 50} (Nivel {user.MinerLevel})");
                    dinero += user.MinerLevel * 50;
                    player.SendClientMessage($"[color orange]- Leñador :[/color] + $ {user.LumberjackLevel * 50} (Nivel {user.LumberjackLevel})");
                    dinero += user.LumberjackLevel * 50;
                    int commision = (dinero * 10) / 100;
                    if (user.ClanID != -1)
                    {
                        dinero -= commision;
                        player.SendClientMessage($"[color orange]- Comisión Clan :[/color] [color #ea6b11]- $ {commision}  ");
                    }
                    player.SendClientMessage($"[color orange]- Total :[/color] [color #ea6b11]$ {dinero}  ");
                    user.Cash += dinero;
                    player.SendClientMessage($"[color orange]- Balance :[/color] [color #ea6b11]$ {user.Cash} ");
                    string reward = RewardList[randomNumber];
                    player.SendClientMessage($"[color orange]- Recompensa :[/color] [color #ea6b11]{reward} ");

                    player.SendClientMessage($"[color orange]----------------------------------------------------");
                    user.GiveExp(1);


                    if (player.Inventory.FreeSlots >= 1)
                    {
                        player.Inventory.AddItem(reward);
                    }
                    else
                    {
                        player.SendClientMessage($"[color red]<PayDay>[/color] Perdiste la recompensa por no tener espacio en el inventario.");
                    }

                    if (user.ClanID != -1)
                    {
                        if (user.Clan != null)
                        {
                            user.Clan.addExp(1);
                            user.Clan.Cash += commision;
                        }
                    }
                }
            }
        }
Example #22
0
        public static void LoginPlayer(Fougerite.Player player, string steamid, string password, Boolean firstLogin = false)
        {
            string lang = LanguageComponent.LanguageComponent.GetPlayerLangOrDefault(player);

            if (UserIsLogged(player))
            {
                player.SendClientMessage("[color red]<Error>[color white] Ya te encuentras logueado.");
                return;
            }
            if (!CheckIfUserIsRegistered(player))
            {
                player.SendClientMessage("[color red]<Error>[color white] Este usuario no se encuentra registrado en la base de datos, usa /registro.");
                return;
            }

            using (MySqlConnection connection = new MySqlConnection(Data.Database.Connection.GetConnectionString()))
            {
                connection.Open();
                string       pEncrypt = BCrypt.Net.BCrypt.HashString(password);
                MySqlCommand command  = connection.CreateCommand();
                command.CommandText = "SELECT * FROM users WHERE steamId = @steamID";
                command.Parameters.AddWithValue("@steamID", steamid);
                MySqlDataReader reader = command.ExecuteReader();
                if (reader.HasRows)
                {
                    reader.Read();

                    if (!Crypter.CheckPassword(password, reader.GetString("password")))
                    {
                        connection.Close();
                        player.SendClientMessage($"[color red] <Error> [color white]Los datos ingresados son incorrectos, utiliza [color blue]/login[color white] para intentarlo nuevamente.");
                        return;
                    }
                    User newUser = new User
                    {
                        ID                = reader.GetInt32("id"),
                        Name              = reader.GetString("username"),
                        SteamID           = player.UID,
                        IP                = reader.GetString("ip"),
                        Level             = reader.GetInt32("level"),
                        Exp               = reader.GetInt32("exp"),
                        Kills             = reader.GetInt32("kills"),
                        Deaths            = reader.GetInt32("deaths"),
                        Cash              = reader.GetInt32("cash"),
                        LastKilled        = reader.GetString("lastKilled"),
                        MinerLevel        = reader.GetInt32("minerLevel"),
                        MinerExp          = reader.GetInt32("minerExp"),
                        LumberjackLevel   = reader.GetInt32("lumberjackLevel"),
                        LumberjackExp     = reader.GetInt32("lumberjackExp"),
                        WoodFarmed        = reader.GetInt32("woodFarmed"),
                        MetalFarmed       = reader.GetInt32("metalFarmed"),
                        SulfureFarmed     = reader.GetInt32("sulfureFarmed"),
                        HunterLevel       = reader.GetInt32("hunterLevel"),
                        HunterExp         = reader.GetInt32("hunterExp"),
                        AdminLevel        = reader.GetInt32("adminLevel"),
                        BannedPlayer      = reader.GetInt32("banned"),
                        InternalInventory = reader.GetString("inventoryItems"),
                        XPos              = reader.GetFloat("xPos"),
                        YPos              = reader.GetFloat("yPos"),
                        ZPos              = reader.GetFloat("zPos"),
                        TimeToPayDay      = reader.GetInt32("timeToPayDay"),
                        TimeToKit         = reader.GetInt32("timeToKit"),
                        Connected         = 1,
                        TimeToTP          = reader.GetInt32("timeToTP"),
                        Muted             = reader.GetInt32("muted"),
                        ClanID            = reader.GetInt32("clan"),
                        ClanRank          = reader.GetInt32("clanRank"),
                        Language          = reader.GetString("lang"),
                        Player            = player
                    };
                    newUser.GetClan();
                    if (firstLogin)
                    {
                        newUser.XPos = player.Location.x;
                        newUser.YPos = player.Location.y;
                        newUser.ZPos = player.Location.z;
                    }
                    Data.Globals.usersOnline.Add(newUser);
                    newUser.Connect();

                    player.SendClientMessage(string.Format(LanguageComponent.LanguageComponent.getMessage("login_message", lang), player.Name, newUser.Level));
                    //player.SendClientMessage($"¡Bienvenido! [color orange]{player.Name}[color white] - Nivel [color orange]{newUser.Level}");
                    player.SendClientMessage(LanguageComponent.LanguageComponent.getMessage("welcome_text_2", lang));
                    if (newUser.AdminLevel >= 1)
                    {
                        player.SendClientMessage($"- [color orange]Eres administrador nivel[/color] {newUser.AdminLevel}");
                    }
                    if (newUser.ClanID != -1)
                    {
                        player.SendClientMessage($"[color orange]<{newUser.Clan.Name}>[/color] {newUser.Clan.MOTD}");
                        if (newUser.Clan.Tag != "")
                        {
                            player.Name = $"[{newUser.Clan.Tag}] {newUser.Name}";
                        }
                    }
                    else
                    {
                        player.Name = newUser.Name;
                    }
                    connection.Close();
                    LoadPlayer(player, firstLogin);
                }
                else
                {
                    connection.Close();
                    player.SendClientMessage($"[color red] <Error> [color white]Los datos ingresados son incorrectos, utiliza [color blue]/login[color white] para intentarlo nuevamente.");
                    return;
                }
            }
        }