Added ability to disable automatic respawn
Prepare for client side scripting.
This commit is contained in:
@ -11,14 +11,15 @@ namespace RageCoop.Client
|
||||
/// </summary>
|
||||
public static class COOPAPI
|
||||
{
|
||||
|
||||
#region DELEGATES
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
/// <param name="connected"></param>
|
||||
/// <param name="from">The Lidgren-Network net handle</param>
|
||||
/// <param name="from">The player's id</param>
|
||||
/// <param name="reason"></param>
|
||||
public delegate void ConnectEvent(bool connected, long from, string reason = null);
|
||||
public delegate void ConnectEvent(bool connected, int from, string reason = null);
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
@ -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
|
||||
/// </summary>
|
||||
/// <returns>PlayerID</returns>
|
||||
public static long GetPlayerID()
|
||||
public static int GetPlayerID()
|
||||
{
|
||||
return Main.LocalPlayerID;
|
||||
}
|
||||
|
@ -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++;
|
||||
}
|
||||
|
@ -78,10 +78,13 @@ namespace RageCoop.Client
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Client!=null)
|
||||
{
|
||||
Client.FlushSendQueue();
|
||||
ReceiveMessages();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Main.Logger.Error(ex);
|
||||
|
@ -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();
|
||||
|
@ -123,6 +123,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="DevTools\DevTool.cs" />
|
||||
<Compile Include="Menus\Sub\DevToolMenu.cs" />
|
||||
<Compile Include="Scripting\ClientScript.cs" />
|
||||
<Compile Include="Util\MathExtensions.cs" />
|
||||
<Compile Include="Util\Util.cs" />
|
||||
<Compile Include="Util\VehicleExtensions.cs" />
|
||||
|
17
Client/Scripting/ClientScript.cs
Normal file
17
Client/Scripting/ClientScript.cs
Normal file
@ -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();
|
||||
}
|
||||
}
|
@ -55,6 +55,10 @@ namespace RageCoop.Client
|
||||
/// </summary>
|
||||
public int WorldVehicleSoftLimit { get; set; } = 35;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Disable automatic respawn.
|
||||
/// </summary>
|
||||
public bool DisableAutoRespawn { get; set; } = true;
|
||||
public float HpRechargeMultiplier { get; set; } = 1;
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user