public IPacket ReadPacket(IMinecraftDataReader reader)
        {
            Action = (PlayerListAction)reader.ReadVarInt();
            Length = reader.ReadVarInt();
            UUID   = reader.ReadBigInteger();

            switch (Action)
            {
            case PlayerListAction.AddPlayer:
                PlayerList = new PlayerListActionAddPlayer().FromReader(reader);
                break;

            case PlayerListAction.UpdateGamemode:
                PlayerList = new PlayerListActionUpdateGamemode().FromReader(reader);
                break;

            case PlayerListAction.UpdateLatency:
                PlayerList = new PlayerListActionUpdateLatency().FromReader(reader);
                break;

            case PlayerListAction.UpdateDisplayName:
                PlayerList = new PlayerListActionUpdateDisplayName().FromReader(reader);
                break;

            case PlayerListAction.RemovePlayer:
                PlayerList = new PlayerListActionRemovePlayer().FromReader(reader);
                break;
            }

            return(this);
        }
Exemple #2
0
        public ServerSideClientFactory(Client.Factory clientFactory, IPlayerList playerList)
        {
            _playerList = playerList;
            _clientFactory = clientFactory;

            _playerList.Players.Clear();
        }
        public static void Main(string[] args)
        {
            CrearInfrastructuraRemoting();
            string destintatario;
            string mensaje;

            Console.WriteLine("Obtener referencia al server.");
            IPlayerList serverChat = (IPlayerList)Activator.GetObject(
                typeof(IPlayerList),
                "tcp://" + ConfigurationManager.AppSettings["serverip"] + ":" + ConfigurationManager.AppSettings["serverport"] + "/ServerChat");

            entries = new Stack <LogEntry>();
            bool exit = false;

            Console.WriteLine("Available Commands:");
            Console.WriteLine("log");
            Console.WriteLine("exit");
            while (!exit)
            {
                Console.WriteLine("Enter Command:");
                string cmd = Console.ReadLine();
                if (cmd.Equals("log"))
                {
                    ReadMessages();
                    ResendMessages();
                }
                else if (cmd.Equals("exit"))
                {
                    exit = true;
                }
            }
        }
Exemple #4
0
        public TcpServer(IConnect connection, IMessaging messaging, IPlayerList playerList)
        {
            _connection = connection;
            _messaging  = messaging;
            _playerList = playerList;

            StartServer(5678);
            Listen();
        }
Exemple #5
0
 // Remove disconnected players from game logic collections
 public void RemovePlayer(IPlayer player)
 {
     if (IPlayerList.IndexOf(player) != -1)
     {
         IPlayerList[IPlayerList.IndexOf(player)] = null;
     }
     playersStayed.Remove(player);
     playersCurrentPayments.Remove(player);
     connectedPlayers.Remove(player);
 }
Exemple #6
0
        public ScoreOverlayView(IPlayerList playerList, Rectangle scoreWindow, IFont font)
        {
            _playerList = playerList;
            this.Window = scoreWindow;
            _font = font;

            this.BackgroundColor = OverlaySetView.BACKGROUND_COLOR;

            SCORE_OFFSET = new Vector2(scoreWindow.Width / 2, 0);
            DEATHS_OFFSET = new Vector2(scoreWindow.Width * ((float)2 / 3), 0);
        }
Exemple #7
0
 public void SetServerState(IDictionary <string, object> data)
 {
     if (data.TryGetValue("IsInfinity", out var isInfinity))
     {
         if (isInfinity is bool isInfinityBool)
         {
             if (isInfinityBool)
             {
                 PlayersList = new InfinityPlayerList(Players);
             }
         }
     }
 }
Exemple #8
0
 public void SetUp()
 {
     stubPlayerController = MockRepository.GenerateStub<IPlayerController>();
     playerList = new PlayerList();
     playerList.Add(MockRepository.GenerateStub<IPlayer>());
     playerList.Players[0].Stub(me => me.Weapons).Return(MockRepository.GenerateStub<IWeapons>());
     playerList.Add(MockRepository.GenerateStub<IPlayer>());
     playerList.Players[1].Stub(me => me.Weapons).Return(MockRepository.GenerateStub<IWeapons>());
     weaponViews = new List<IWeaponView>();
     weaponViews.Add(MockRepository.GenerateStub<IWeaponView>());
     weaponViews.Add(MockRepository.GenerateStub<IWeaponView>());
     view = new WeaponDrawer(stubPlayerController, playerList, weaponViews);
 }
Exemple #9
0
 public void SetUp()
 {
     playerList = MockRepository.GenerateStub<IPlayerList>();
     playerList.Stub(me => me.Players).Return(new List<IPlayer>());
     stubTexture = MockRepository.GenerateStub<ITexture>();
     _stubTextureBank = MockRepository.GenerateStub<ITextureBank<PlayerTexture>>();
     _stubTextureBank.Stub(x => x[PlayerTexture.Ball]).Return(stubTexture);
     stubSpriteBatch = MockRepository.GenerateStub<ISpriteBatch>();
     stubCamera = MockRepository.GenerateStub<ICamera>();
     stubWeaponDrawer = MockRepository.GenerateStub<IWeaponDrawer>();
     stubBubbleText = MockRepository.GenerateStub<IBubbleTextDrawer>();
     player = MockRepository.GenerateStub<IPlayer>();
     player.Status = PlayerStatus.Alive;
     player.Stub(me => me.PlayerSettings).Return(new NetworkPlayerSettings());
     player.Stub(me => me.Weapons).Return(MockRepository.GenerateStub<IWeapons>());
     playerList.Players.Add(player);
     playerView = new PlayerView(playerList, _stubTextureBank, stubSpriteBatch, stubCamera, stubWeaponDrawer, stubBubbleText);
 }
Exemple #10
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public MainMenu()
        {
            PlayersList = new NativePlayerList(Players);

            #region cleanup unused kvps
            int           tmp_kvp_handle        = StartFindKvp("");
            bool          cleanupVersionChecked = false;
            List <string> tmp_kvp_names         = new List <string>();
            while (true)
            {
                string k = FindKvp(tmp_kvp_handle);
                if (string.IsNullOrEmpty(k))
                {
                    break;
                }
                if (k == "vmenu_cleanup_version")
                {
                    if (GetResourceKvpInt("vmenu_cleanup_version") >= currentCleanupVersion)
                    {
                        cleanupVersionChecked = true;
                    }
                }
                tmp_kvp_names.Add(k);
            }
            EndFindKvp(tmp_kvp_handle);

            if (!cleanupVersionChecked)
            {
                SetResourceKvpInt("vmenu_cleanup_version", currentCleanupVersion);
                foreach (string kvp in tmp_kvp_names)
                {
                    if (currentCleanupVersion == 1 || currentCleanupVersion == 2)
                    {
                        if (!kvp.StartsWith("settings_") && !kvp.StartsWith("vmenu") && !kvp.StartsWith("veh_") && !kvp.StartsWith("ped_") && !kvp.StartsWith("mp_ped_"))
                        {
                            DeleteResourceKvp(kvp);
                            Debug.WriteLine($"[vMenu] [cleanup id: 1] Removed unused (old) KVP: {kvp}.");
                        }
                    }
                    if (currentCleanupVersion == 2)
                    {
                        if (kvp.StartsWith("mp_char"))
                        {
                            DeleteResourceKvp(kvp);
                            Debug.WriteLine($"[vMenu] [cleanup id: 2] Removed unused (old) KVP: {kvp}.");
                        }
                    }
                }
                Debug.WriteLine("[vMenu] Cleanup of old unused KVP items completed.");
            }
            #endregion

            if (EnableExperimentalFeatures)
            {
                RegisterCommand("testped", new Action <dynamic, List <dynamic>, string>((dynamic source, List <dynamic> args, string rawCommand) =>
                {
                    PedHeadBlendData data = Game.PlayerPed.GetHeadBlendData();
                    Debug.WriteLine(JsonConvert.SerializeObject(data, Formatting.Indented));
                }), false);

                RegisterCommand("tattoo", new Action <dynamic, List <dynamic>, string>((dynamic source, List <dynamic> args, string rawCommand) =>
                {
                    if (args != null && args[0] != null && args[1] != null)
                    {
                        Debug.WriteLine(args[0].ToString() + " " + args[1].ToString());
                        TattooCollectionData d = Game.GetTattooCollectionData(int.Parse(args[0].ToString()), int.Parse(args[1].ToString()));
                        Debug.WriteLine("check");
                        Debug.Write(JsonConvert.SerializeObject(d, Formatting.Indented) + "\n");
                    }
                }), false);

                RegisterCommand("clearfocus", new Action <dynamic, List <dynamic>, string>((dynamic source, List <dynamic> args, string rawCommand) =>
                {
                    SetNuiFocus(false, false);
                }), false);
            }

            RegisterCommand("vmenuclient", new Action <dynamic, List <dynamic>, string>((dynamic source, List <dynamic> args, string rawCommand) =>
            {
                if (args != null)
                {
                    if (args.Count > 0)
                    {
                        if (args[0].ToString().ToLower() == "debug")
                        {
                            DebugMode = !DebugMode;
                            Notify.Custom($"Debug mode is now set to: {DebugMode}.");
                            // Set discord rich precense once, allowing it to be overruled by other resources once those load.
                            if (DebugMode)
                            {
                                SetRichPresence($"Debugging vMenu {Version}!");
                            }
                            else
                            {
                                SetRichPresence($"Enjoying FiveM!");
                            }
                        }
                        else if (args[0].ToString().ToLower() == "gc")
                        {
                            GC.Collect();
                            Debug.Write("Cleared memory.\n");
                        }
                        else if (args[0].ToString().ToLower() == "dump")
                        {
                            Notify.Info("A full config dump will be made to the console. Check the log file. This can cause lag!");
                            Debug.WriteLine("\n\n\n########################### vMenu ###########################");
                            Debug.WriteLine($"Running vMenu Version: {Version}, Experimental features: {EnableExperimentalFeatures}, Debug mode: {DebugMode}.");
                            Debug.WriteLine("\nDumping a list of all KVPs:");
                            int handle          = StartFindKvp("");
                            List <string> names = new List <string>();
                            while (true)
                            {
                                string k = FindKvp(handle);
                                if (string.IsNullOrEmpty(k))
                                {
                                    break;
                                }
                                //if (!k.StartsWith("settings_") && !k.StartsWith("vmenu") && !k.StartsWith("veh_") && !k.StartsWith("ped_") && !k.StartsWith("mp_ped_"))
                                //{
                                //    DeleteResourceKvp(k);
                                //}
                                names.Add(k);
                            }
                            EndFindKvp(handle);

                            Dictionary <string, dynamic> kvps = new Dictionary <string, dynamic>();
                            foreach (var kvp in names)
                            {
                                int type = 0; // 0 = string, 1 = float, 2 = int.
                                if (kvp.StartsWith("settings_"))
                                {
                                    if (kvp == "settings_voiceChatProximity") // float
                                    {
                                        type = 1;
                                    }
                                    else if (kvp == "settings_clothingAnimationType") // int
                                    {
                                        type = 2;
                                    }
                                    else if (kvp == "settings_miscLastTimeCycleModifierIndex") // int
                                    {
                                        type = 2;
                                    }
                                    else if (kvp == "settings_miscLastTimeCycleModifierStrength") // int
                                    {
                                        type = 2;
                                    }
                                }
                                else if (kvp == "vmenu_cleanup_version") // int
                                {
                                    type = 2;
                                }
                                switch (type)
                                {
                                case 0:
                                    var s = GetResourceKvpString(kvp);
                                    if (s.StartsWith("{") || s.StartsWith("["))
                                    {
                                        kvps.Add(kvp, JsonConvert.DeserializeObject(s));
                                    }
                                    else
                                    {
                                        kvps.Add(kvp, GetResourceKvpString(kvp));
                                    }
                                    break;

                                case 1:
                                    kvps.Add(kvp, GetResourceKvpFloat(kvp));
                                    break;

                                case 2:
                                    kvps.Add(kvp, GetResourceKvpInt(kvp));
                                    break;
                                }
                            }
                            Debug.WriteLine(@JsonConvert.SerializeObject(kvps, Formatting.None) + "\n");

                            Debug.WriteLine("\n\nDumping a list of allowed permissions:");
                            Debug.WriteLine(@JsonConvert.SerializeObject(Permissions, Formatting.None));

                            Debug.WriteLine("\n\nDumping vmenu server configuration settings:");
                            var settings = new Dictionary <string, string>();
                            foreach (var a in Enum.GetValues(typeof(Setting)))
                            {
                                settings.Add(a.ToString(), GetSettingsString((Setting)a));
                            }
                            Debug.WriteLine(@JsonConvert.SerializeObject(settings, Formatting.None));
                            Debug.WriteLine("\nEnd of vMenu dump!");
                            Debug.WriteLine("\n########################### vMenu ###########################");
                        }
                    }
                    else
                    {
                        Notify.Custom($"vMenu is currently running version: {Version}.");
                    }
                }
            }), false);

            // Set discord rich precense once, allowing it to be overruled by other resources once those load.
            if (DebugMode)
            {
                SetRichPresence($"Debugging vMenu {Version}!");
            }

            if (GetCurrentResourceName() != "vMenu")
            {
                Exception InvalidNameException = new Exception("\r\n\r\n[vMenu] INSTALLATION ERROR!\r\nThe name of the resource is not valid. Please change the folder name from '" + GetCurrentResourceName() + "' to 'vMenu' (case sensitive) instead!\r\n\r\n\r\n");
                try
                {
                    throw InvalidNameException;
                }
                catch (Exception e)
                {
                    Log(e.Message);
                }
                TriggerEvent("chatMessage", "^3IMPORTANT: vMenu IS NOT SETUP CORRECTLY. PLEASE CHECK THE SERVER LOG FOR MORE INFO.");
                MenuController.MainMenu           = null;
                MenuController.DontOpenAnyMenu    = true;
                MenuController.DisableMenuButtons = true;
            }
            else
            {
                Tick += OnTick;
            }
            try
            {
                SetClockDate(DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year);
            }
            catch (InvalidTimeZoneException timeEx)
            {
                Debug.WriteLine($"[vMenu] [Error] Could not set the in-game day, month and year because of an invalid timezone(?).");
                Debug.WriteLine($"[vMenu] [Error] InvalidTimeZoneException: {timeEx.Message}");
                Debug.WriteLine($"[vMenu] [Error] vMenu will continue to work normally.");
            }
        }
        public IPacket ReadPacket(IMinecraftDataReader reader)
        {
            Action = (PlayerListAction) reader.ReadVarInt();
            Length = reader.ReadVarInt();
            UUID = reader.ReadBigInteger();

            switch (Action)
            {
                case PlayerListAction.AddPlayer:
                    PlayerList = new PlayerListActionAddPlayer().FromReader(reader);
                    break;
                case PlayerListAction.UpdateGamemode:
                    PlayerList = new PlayerListActionUpdateGamemode().FromReader(reader);
                    break;
                case PlayerListAction.UpdateLatency:
                    PlayerList = new PlayerListActionUpdateLatency().FromReader(reader);
                    break;
                case PlayerListAction.UpdateDisplayName:
                    PlayerList = new PlayerListActionUpdateDisplayName().FromReader(reader);
                    break;
                case PlayerListAction.RemovePlayer:
                    PlayerList = new PlayerListActionRemovePlayer().FromReader(reader);
                    break;
            }

            return this;
        }
Exemple #12
0
 public Messaging(IPlayerList playerList)
 {
     _playerList = playerList;
 }
Exemple #13
0
 public ClientSideClientFactory(Client.Factory clientFactory, IPlayerList playerList, LocalClient localClient)
     : base(clientFactory, playerList)
 {
     _localClient = localClient;
 }
Exemple #14
0
 public PlayerUpdater(IPlayerList playerList)
 {
     this.PlayerList = playerList;
 }
Exemple #15
0
 public GuiManager()
 {
     m_player     = null;
     m_playerList = new WindowConfig();
     m_manager    = new PlayerManager();
 }
Exemple #16
0
 public WeaponDrawer(IPlayerController playerController, IPlayerList playerList, List<IWeaponView> weaponViews)
 {
     this.playerController = playerController;
     this.playerList = playerList;
     this.weaponViews = weaponViews;
 }
Exemple #17
0
 public Connect(IPlayerList playerList, IMessaging messaging)
 {
     _messaging  = messaging;
     _playerList = playerList;
 }