diff --git a/Client/COOPAPI.cs b/Client/COOPAPI.cs index c4c63bb..9cf7e01 100644 --- a/Client/COOPAPI.cs +++ b/Client/COOPAPI.cs @@ -11,14 +11,15 @@ namespace RageCoop.Client /// public static class COOPAPI { + #region DELEGATES /// /// ? /// /// - /// The Lidgren-Network net handle + /// The player's id /// - public delegate void ConnectEvent(bool connected, long from, string reason = null); + public delegate void ConnectEvent(bool connected, int from, string reason = null); /// /// ? /// @@ -61,9 +62,9 @@ namespace RageCoop.Client OnConnection?.Invoke(true, playerID); } - public static void Disconnected(long netHandle) + public static void Disconnected(int playerID) { - OnConnection?.Invoke(false, netHandle); + OnConnection?.Invoke(false, playerID); } public static bool ChatMessageReceived(string from, string message) @@ -113,7 +114,7 @@ namespace RageCoop.Client /// Get the local player's ID /// /// PlayerID - public static long GetPlayerID() + public static int GetPlayerID() { return Main.LocalPlayerID; } diff --git a/Client/Main.cs b/Client/Main.cs index 925d8c7..3cfbd19 100644 --- a/Client/Main.cs +++ b/Client/Main.cs @@ -21,8 +21,7 @@ namespace RageCoop.Client { private bool _gameLoaded = false; - private static bool _isGoingToCar = false; - + private bool _lastDead = false; public static readonly string CurrentVersion = "V0_3"; public static int LocalPlayerID=0; @@ -108,11 +107,6 @@ namespace RageCoop.Client CoopMenu.MenuPool.Process(); #endif - - if (_isGoingToCar && Game.Player.Character.IsInVehicle()) - { - _isGoingToCar = false; - } DoQueuedActions(); if (!Networking.IsOnServer) { @@ -162,9 +156,32 @@ namespace RageCoop.Client MainChat.Tick(); PlayerList.Tick(); + if (Settings.DisableAutoRespawn) + { + Function.Call(Hash.PAUSE_DEATH_ARREST_RESTART, true); + Function.Call(Hash.FORCE_GAME_STATE_PLAYING); + var P = Game.Player.Character; + if (P.IsDead) + { + Function.Call(Hash.TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME, "respawn_controller"); + Function.Call(Hash.SET_FADE_OUT_AFTER_DEATH, false); + + if (P.Health!=1) + { + P.Health=1; + Game.Player.WantedLevel=0; + Main.Logger.Debug("Player died."); + } + GTA.UI.Screen.StopEffects(); + } + else + { + Function.Call(Hash.DISPLAY_HUD, true); + } + _lastDead=P.IsDead; - + } Ticked++; } diff --git a/Client/Networking/Networking.cs b/Client/Networking/Networking.cs index 400ce9f..045a742 100644 --- a/Client/Networking/Networking.cs +++ b/Client/Networking/Networking.cs @@ -79,8 +79,11 @@ namespace RageCoop.Client { try { - Client.FlushSendQueue(); - ReceiveMessages(); + if (Client!=null) + { + Client.FlushSendQueue(); + ReceiveMessages(); + } } catch (Exception ex) { diff --git a/Client/Networking/Send.cs b/Client/Networking/Send.cs index 5c0771a..88de41b 100644 --- a/Client/Networking/Send.cs +++ b/Client/Networking/Send.cs @@ -44,6 +44,11 @@ namespace RageCoop.Client Flag = p.GetPedFlags(), Heading=p.Heading, }; + if (packet.Health==1&&packet.ID==Main.LocalPlayerID) + { + // Fake death + packet.Health=0; + } if (packet.Flag.HasFlag(PedDataFlags.IsAiming)) { packet.AimCoords = p.GetAimCoord(); diff --git a/Client/RageCoop.Client.csproj b/Client/RageCoop.Client.csproj index 38558f9..2c22fa7 100644 --- a/Client/RageCoop.Client.csproj +++ b/Client/RageCoop.Client.csproj @@ -123,6 +123,7 @@ + diff --git a/Client/Scripting/ClientScript.cs b/Client/Scripting/ClientScript.cs new file mode 100644 index 0000000..dde0065 --- /dev/null +++ b/Client/Scripting/ClientScript.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RageCoop.Client.Scripting +{ + public abstract class ClientScript + { + public class Events + { + + } + public abstract void Main(); + } +} diff --git a/Client/Settings.cs b/Client/Settings.cs index 00f4801..fadd534 100644 --- a/Client/Settings.cs +++ b/Client/Settings.cs @@ -54,7 +54,11 @@ namespace RageCoop.Client /// The game won't spawn more NPC traffic if the limit is exceeded. -1 for unlimited (not recommended). /// public int WorldVehicleSoftLimit { get; set; } = 35; - - + + /// + /// Disable automatic respawn. + /// + public bool DisableAutoRespawn { get; set; } = true; + public float HpRechargeMultiplier { get; set; } = 1; } } diff --git a/Client/Sync/Entities/SyncedPed.cs b/Client/Sync/Entities/SyncedPed.cs index 1d8ed25..6b7818e 100644 --- a/Client/Sync/Entities/SyncedPed.cs +++ b/Client/Sync/Entities/SyncedPed.cs @@ -252,10 +252,8 @@ namespace RageCoop.Client MainPed.CanBeDraggedOutOfVehicle = true; MainPed.IsOnlyDamagedByPlayer = false; MainPed.RelationshipGroup=Main.SyncedPedsGroup; - if (IsPlayer) - { - MainPed.IsInvincible=true; - } + MainPed.IsFireProof=false; + MainPed.IsExplosionProof=false; SetClothes(); if (IsPlayer)