Exemple #1
0
        /// <summary>
        /// Allows the host of the plugin requests backup when or when not in a mission.
        /// </summary>
        private void NetworkGame_RequestBackupHandler()
        {
            // The codes below are taken from the latest pull of LCPDFR API on GitHub (or latest download from LCPDFR website).
            // If you are the developer feel free to have fun with this handler (or add one other handler and mod it your way).

            bool isNetworkingBackupSystemActive = SettingsIni.GetValueBool("EnableNetworkingBackupSys", "GlobalSettings", false);

            // Send RequestBackup message in network game.
            if (Functions.IsKeyDown(SettingsIni.GetValueKey("RequestBackupInNetworkKeybind", "GlobalSettings", Keys.Back))
                & isNetworkingBackupSystemActive == true)
            {
                if (Networking.IsInSession && Networking.IsConnected)
                {
                    if (Networking.IsHost)
                    {
                        Vector3 position = LPlayer.LocalPlayer.Ped.Position;

                        // Tell client we need backup.
                        DynamicData dynamicData = new DynamicData(Networking.GetServerInstance());
                        dynamicData.Write(position);
                        Networking.GetServerInstance().Send(this.ToString(), NetworkMessages.RequestBackup, dynamicData);
                        Log.Info("Server: Message sent to Client", this);
                    }
                }
            }
        }