Fixed client exceptions
This commit is contained in:
@ -8,14 +8,17 @@ using GTA.Native;
|
||||
|
||||
namespace CoopClient
|
||||
{
|
||||
internal class Chat
|
||||
/// <summary>
|
||||
/// Don't use it!
|
||||
/// </summary>
|
||||
public class Chat
|
||||
{
|
||||
private readonly Scaleform MainScaleForm;
|
||||
|
||||
public string CurrentInput { get; set; }
|
||||
internal string CurrentInput { get; set; }
|
||||
|
||||
private bool CurrentFocused { get; set; }
|
||||
public bool Focused
|
||||
internal bool Focused
|
||||
{
|
||||
get { return CurrentFocused; }
|
||||
set
|
||||
@ -55,23 +58,26 @@ namespace CoopClient
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Don't use it!
|
||||
/// </summary>
|
||||
public Chat()
|
||||
{
|
||||
MainScaleForm = new Scaleform("multiplayer_chat");
|
||||
}
|
||||
|
||||
public void Init()
|
||||
internal void Init()
|
||||
{
|
||||
MainScaleForm.CallFunction("SET_FOCUS", 2, 2, "ALL");
|
||||
MainScaleForm.CallFunction("SET_FOCUS", 1, 2, "ALL");
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
internal void Clear()
|
||||
{
|
||||
MainScaleForm.CallFunction("RESET");
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
internal void Tick()
|
||||
{
|
||||
if ((Util.GetTickCount64() - LastMessageTime) > 15000 && !Focused && !Hidden)
|
||||
{
|
||||
@ -91,14 +97,14 @@ namespace CoopClient
|
||||
Function.Call(Hash.DISABLE_ALL_CONTROL_ACTIONS, 0);
|
||||
}
|
||||
|
||||
public void AddMessage(string sender, string msg)
|
||||
internal void AddMessage(string sender, string msg)
|
||||
{
|
||||
MainScaleForm.CallFunction("ADD_MESSAGE", sender + ":", msg);
|
||||
LastMessageTime = Util.GetTickCount64();
|
||||
Hidden = false;
|
||||
}
|
||||
|
||||
public void OnKeyDown(Keys key)
|
||||
internal void OnKeyDown(Keys key)
|
||||
{
|
||||
if (key == Keys.Escape)
|
||||
{
|
||||
@ -151,12 +157,12 @@ namespace CoopClient
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern int ToUnicodeEx(uint virtualKeyCode, uint scanCode, byte[] keyboardState,
|
||||
internal static extern int ToUnicodeEx(uint virtualKeyCode, uint scanCode, byte[] keyboardState,
|
||||
[Out, MarshalAs(UnmanagedType.LPWStr, SizeConst = 64)]
|
||||
StringBuilder receivingBuffer,
|
||||
int bufferSize, uint flags, IntPtr kblayout);
|
||||
|
||||
public static string GetCharFromKey(Keys key, bool shift, bool altGr)
|
||||
internal static string GetCharFromKey(Keys key, bool shift, bool altGr)
|
||||
{
|
||||
StringBuilder buf = new StringBuilder(256);
|
||||
byte[] keyboardState = new byte[256];
|
||||
|
@ -6,8 +6,14 @@ using GTA;
|
||||
|
||||
namespace CoopClient.Entities
|
||||
{
|
||||
internal class EntitiesThread : Script
|
||||
/// <summary>
|
||||
/// Don't use it!
|
||||
/// </summary>
|
||||
public class EntitiesThread : Script
|
||||
{
|
||||
/// <summary>
|
||||
/// Don't use it!
|
||||
/// </summary>
|
||||
public EntitiesThread()
|
||||
{
|
||||
Tick += OnTick;
|
||||
|
@ -12,31 +12,49 @@ using GTA.Native;
|
||||
|
||||
namespace CoopClient
|
||||
{
|
||||
internal class Main : Script
|
||||
/// <summary>
|
||||
/// Don't use it!
|
||||
/// </summary>
|
||||
public class Main : Script
|
||||
{
|
||||
public static RelationshipGroup RelationshipGroup;
|
||||
internal static RelationshipGroup RelationshipGroup;
|
||||
|
||||
private bool GameLoaded = false;
|
||||
|
||||
public static readonly string CurrentVersion = "V0_8_0_1";
|
||||
internal static readonly string CurrentVersion = "V0_8_0_1";
|
||||
|
||||
public static bool ShareNpcsWithPlayers = false;
|
||||
public static bool DisableTraffic = false;
|
||||
public static bool NpcsAllowed = false;
|
||||
internal static bool ShareNpcsWithPlayers = false;
|
||||
internal static bool DisableTraffic = false;
|
||||
internal static bool NpcsAllowed = false;
|
||||
private static bool IsGoingToCar = false;
|
||||
|
||||
/// <summary>
|
||||
/// Don't use it!
|
||||
/// </summary>
|
||||
public static Settings MainSettings = Util.ReadSettings();
|
||||
/// <summary>
|
||||
/// Don't use it!
|
||||
/// </summary>
|
||||
public static Networking MainNetworking = new Networking();
|
||||
|
||||
#if !NON_INTERACTIVE
|
||||
/// <summary>
|
||||
/// Don't use it!
|
||||
/// </summary>
|
||||
public static MenusMain MainMenu = new MenusMain();
|
||||
#endif
|
||||
/// <summary>
|
||||
/// Don't use it!
|
||||
/// </summary>
|
||||
public static Chat MainChat = new Chat();
|
||||
|
||||
public static long LocalClientID = 0;
|
||||
public static readonly Dictionary<long, EntitiesPlayer> Players = new Dictionary<long, EntitiesPlayer>();
|
||||
public static readonly Dictionary<long, EntitiesNpc> Npcs = new Dictionary<long, EntitiesNpc>();
|
||||
internal static long LocalClientID = 0;
|
||||
internal static readonly Dictionary<long, EntitiesPlayer> Players = new Dictionary<long, EntitiesPlayer>();
|
||||
internal static readonly Dictionary<long, EntitiesNpc> Npcs = new Dictionary<long, EntitiesNpc>();
|
||||
|
||||
/// <summary>
|
||||
/// Don't use it!
|
||||
/// </summary>
|
||||
public Main()
|
||||
{
|
||||
Function.Call((Hash)0x0888C3502DBBEEF5); // _LOAD_MP_DLC_MAPS
|
||||
@ -184,7 +202,7 @@ namespace CoopClient
|
||||
}
|
||||
#endif
|
||||
|
||||
public static void CleanUp()
|
||||
internal static void CleanUp()
|
||||
{
|
||||
MainChat.Clear();
|
||||
|
||||
@ -209,9 +227,9 @@ namespace CoopClient
|
||||
|
||||
#if DEBUG
|
||||
private ulong ArtificialLagCounter;
|
||||
public static EntitiesPlayer DebugSyncPed;
|
||||
public static ulong LastFullDebugSync = 0;
|
||||
public static bool UseDebug = false;
|
||||
internal static EntitiesPlayer DebugSyncPed;
|
||||
internal static ulong LastFullDebugSync = 0;
|
||||
internal static bool UseDebug = false;
|
||||
|
||||
private void Debug()
|
||||
{
|
||||
|
@ -5,16 +5,22 @@ using LemonUI.Menus;
|
||||
|
||||
namespace CoopClient.Menus
|
||||
{
|
||||
internal class MenusMain
|
||||
/// <summary>
|
||||
/// Don't use it!
|
||||
/// </summary>
|
||||
public class MenusMain
|
||||
{
|
||||
public ObjectPool MenuPool = new ObjectPool();
|
||||
internal ObjectPool MenuPool = new ObjectPool();
|
||||
|
||||
public NativeMenu MainMenu = new NativeMenu("GTACOOP:R", "MAIN")
|
||||
internal NativeMenu MainMenu = new NativeMenu("GTACOOP:R", "MAIN")
|
||||
{
|
||||
UseMouse = false,
|
||||
Alignment = Main.MainSettings.FlipMenu ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left
|
||||
};
|
||||
#region SUB
|
||||
/// <summary>
|
||||
/// Don't use it!
|
||||
/// </summary>
|
||||
public Sub.Settings SubSettings = new Sub.Settings();
|
||||
#endregion
|
||||
|
||||
@ -28,6 +34,9 @@ namespace CoopClient.Menus
|
||||
Main.CurrentVersion.Replace("_", ".")) { LeftBadge = new LemonUI.Elements.ScaledTexture("commonmenu", "shop_new_star") };
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Don't use it!
|
||||
/// </summary>
|
||||
public MenusMain()
|
||||
{
|
||||
UsernameItem.Activated += UsernameActivated;
|
||||
@ -46,7 +55,7 @@ namespace CoopClient.Menus
|
||||
MenuPool.Add(SubSettings.MainMenu);
|
||||
}
|
||||
|
||||
public void UsernameActivated(object a, System.EventArgs b)
|
||||
internal void UsernameActivated(object a, System.EventArgs b)
|
||||
{
|
||||
string newUsername = Game.GetUserInput(WindowTitle.EnterMessage20, UsernameItem.AltTitle, 20);
|
||||
if (!string.IsNullOrWhiteSpace(newUsername))
|
||||
@ -59,7 +68,7 @@ namespace CoopClient.Menus
|
||||
}
|
||||
}
|
||||
|
||||
public void ServerIpActivated(object a, System.EventArgs b)
|
||||
internal void ServerIpActivated(object a, System.EventArgs b)
|
||||
{
|
||||
string newServerIp = Game.GetUserInput(WindowTitle.EnterMessage60, ServerIpItem.AltTitle, 60);
|
||||
if (!string.IsNullOrWhiteSpace(newServerIp) && newServerIp.Contains(":"))
|
||||
@ -72,14 +81,14 @@ namespace CoopClient.Menus
|
||||
}
|
||||
}
|
||||
|
||||
public void InitiateConnectionMenuSetting()
|
||||
internal void InitiateConnectionMenuSetting()
|
||||
{
|
||||
MainMenu.Items[0].Enabled = false;
|
||||
MainMenu.Items[1].Enabled = false;
|
||||
MainMenu.Items[2].Enabled = false;
|
||||
}
|
||||
|
||||
public void ConnectedMenuSetting()
|
||||
internal void ConnectedMenuSetting()
|
||||
{
|
||||
MainMenu.Items[2].Enabled = true;
|
||||
MainMenu.Items[2].Title = "Disconnect";
|
||||
@ -89,7 +98,7 @@ namespace CoopClient.Menus
|
||||
MenuPool.RefreshAll();
|
||||
}
|
||||
|
||||
public void DisconnectedMenuSetting()
|
||||
internal void DisconnectedMenuSetting()
|
||||
{
|
||||
MainMenu.Items[0].Enabled = true;
|
||||
MainMenu.Items[1].Enabled = true;
|
||||
|
@ -2,9 +2,12 @@
|
||||
|
||||
namespace CoopClient.Menus.Sub
|
||||
{
|
||||
internal class Settings
|
||||
/// <summary>
|
||||
/// Don't use it!
|
||||
/// </summary>
|
||||
public class Settings
|
||||
{
|
||||
public NativeMenu MainMenu = new NativeMenu("GTACOOP:R", "Settings", "Go to the settings")
|
||||
internal NativeMenu MainMenu = new NativeMenu("GTACOOP:R", "Settings", "Go to the settings")
|
||||
{
|
||||
UseMouse = false,
|
||||
Alignment = Main.MainSettings.FlipMenu ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left
|
||||
@ -19,6 +22,9 @@ namespace CoopClient.Menus.Sub
|
||||
private readonly NativeCheckboxItem ShowNetworkInfo = new NativeCheckboxItem("Show Network Info", Main.MainNetworking.ShowNetworkInfo);
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Don't use it!
|
||||
/// </summary>
|
||||
public Settings()
|
||||
{
|
||||
DisableTraffic.CheckboxChanged += DisableTrafficCheckboxChanged;
|
||||
@ -40,7 +46,7 @@ namespace CoopClient.Menus.Sub
|
||||
#endif
|
||||
}
|
||||
|
||||
public void DisableTrafficCheckboxChanged(object a, System.EventArgs b)
|
||||
internal void DisableTrafficCheckboxChanged(object a, System.EventArgs b)
|
||||
{
|
||||
Main.DisableTraffic = DisableTraffic.Checked;
|
||||
|
||||
@ -59,14 +65,14 @@ namespace CoopClient.Menus.Sub
|
||||
}
|
||||
}
|
||||
|
||||
public void StreamedNpcsValueChanged(object a, System.EventArgs b)
|
||||
internal void StreamedNpcsValueChanged(object a, System.EventArgs b)
|
||||
{
|
||||
Main.MainSettings.StreamedNpc = StreamedNpcsItem.Value;
|
||||
Util.SaveSettings();
|
||||
StreamedNpcsItem.Title = string.Format("Streamed Npcs ({0})", Main.MainSettings.StreamedNpc);
|
||||
}
|
||||
|
||||
public void FlipMenuCheckboxChanged(object a, System.EventArgs b)
|
||||
internal void FlipMenuCheckboxChanged(object a, System.EventArgs b)
|
||||
{
|
||||
#if !NON_INTERACTIVE
|
||||
Main.MainMenu.MainMenu.Alignment = FlipMenuItem.Checked ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left;
|
||||
@ -78,7 +84,7 @@ namespace CoopClient.Menus.Sub
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
public void UseDebugCheckboxChanged(object a, System.EventArgs b)
|
||||
internal void UseDebugCheckboxChanged(object a, System.EventArgs b)
|
||||
{
|
||||
Main.UseDebug = UseDebugItem.Checked;
|
||||
|
||||
@ -96,7 +102,7 @@ namespace CoopClient.Menus.Sub
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowNetworkInfoCheckboxChanged(object a, System.EventArgs b)
|
||||
internal void ShowNetworkInfoCheckboxChanged(object a, System.EventArgs b)
|
||||
{
|
||||
Main.MainNetworking.ShowNetworkInfo = ShowNetworkInfo.Checked;
|
||||
|
||||
|
@ -10,17 +10,20 @@ using GTA.Native;
|
||||
|
||||
namespace CoopClient
|
||||
{
|
||||
internal class Networking
|
||||
/// <summary>
|
||||
/// Don't use it!
|
||||
/// </summary>
|
||||
public class Networking
|
||||
{
|
||||
public NetClient Client;
|
||||
public float Latency;
|
||||
internal NetClient Client;
|
||||
internal float Latency;
|
||||
|
||||
public bool ShowNetworkInfo = false;
|
||||
internal bool ShowNetworkInfo = false;
|
||||
|
||||
public int BytesReceived = 0;
|
||||
public int BytesSend = 0;
|
||||
internal int BytesReceived = 0;
|
||||
internal int BytesSend = 0;
|
||||
|
||||
public void DisConnectFromServer(string address)
|
||||
internal void DisConnectFromServer(string address)
|
||||
{
|
||||
if (IsOnServer())
|
||||
{
|
||||
@ -66,12 +69,12 @@ namespace CoopClient
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsOnServer()
|
||||
internal bool IsOnServer()
|
||||
{
|
||||
return Client?.ConnectionStatus == NetConnectionStatus.Connected;
|
||||
}
|
||||
|
||||
public void ReceiveMessages()
|
||||
internal void ReceiveMessages()
|
||||
{
|
||||
if (Client == null)
|
||||
{
|
||||
@ -588,7 +591,7 @@ namespace CoopClient
|
||||
|
||||
#region -- SEND --
|
||||
private ulong LastPlayerFullSync = 0;
|
||||
public void SendPlayerData()
|
||||
internal void SendPlayerData()
|
||||
{
|
||||
Ped player = Game.Player.Character;
|
||||
|
||||
@ -760,7 +763,7 @@ namespace CoopClient
|
||||
#endif
|
||||
}
|
||||
|
||||
public void SendNpcData(Ped npc)
|
||||
internal void SendNpcData(Ped npc)
|
||||
{
|
||||
NetOutgoingMessage outgoingMessage = Client.CreateMessage();
|
||||
|
||||
@ -857,7 +860,7 @@ namespace CoopClient
|
||||
#endif
|
||||
}
|
||||
|
||||
public void SendChatMessage(string message)
|
||||
internal void SendChatMessage(string message)
|
||||
{
|
||||
NetOutgoingMessage outgoingMessage = Client.CreateMessage();
|
||||
new ChatMessagePacket()
|
||||
@ -876,7 +879,7 @@ namespace CoopClient
|
||||
#endif
|
||||
}
|
||||
|
||||
public void SendModData(long target, string mod, byte customID, byte[] bytes)
|
||||
internal void SendModData(long target, string mod, byte customID, byte[] bytes)
|
||||
{
|
||||
NetOutgoingMessage outgoingMessage = Client.CreateMessage();
|
||||
new ModPacket()
|
||||
|
@ -8,12 +8,18 @@ using GTA.Native;
|
||||
|
||||
namespace CoopClient
|
||||
{
|
||||
internal class PlayerList : Script
|
||||
/// <summary>
|
||||
/// Don't use it!
|
||||
/// </summary>
|
||||
public class PlayerList : Script
|
||||
{
|
||||
private readonly Scaleform MainScaleform = new Scaleform("mp_mm_card_freemode");
|
||||
private ulong LastUpdate = Util.GetTickCount64();
|
||||
public static ulong Pressed { get; set; }
|
||||
internal static ulong Pressed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Don't use it!
|
||||
/// </summary>
|
||||
public PlayerList()
|
||||
{
|
||||
Init();
|
||||
|
@ -1,10 +1,13 @@
|
||||
namespace CoopClient
|
||||
{
|
||||
internal class Settings
|
||||
/// <summary>
|
||||
/// Don't use it!
|
||||
/// </summary>
|
||||
public class Settings
|
||||
{
|
||||
public string Username { get; set; } = "Player";
|
||||
public string LastServerAddress { get; set; } = "127.0.0.1:4499";
|
||||
public bool FlipMenu { get; set; } = false;
|
||||
public int StreamedNpc { get; set; } = 10;
|
||||
internal string Username { get; set; } = "Player";
|
||||
internal string LastServerAddress { get; set; } = "127.0.0.1:4499";
|
||||
internal bool FlipMenu { get; set; } = false;
|
||||
internal int StreamedNpc { get; set; } = 10;
|
||||
}
|
||||
}
|
||||
|
@ -6,10 +6,16 @@ using GTA.Native;
|
||||
|
||||
namespace CoopClient
|
||||
{
|
||||
internal class WorldThread : Script
|
||||
/// <summary>
|
||||
/// Don't use it!
|
||||
/// </summary>
|
||||
public class WorldThread : Script
|
||||
{
|
||||
private static bool LastDisableTraffic = false;
|
||||
|
||||
/// <summary>
|
||||
/// Don't use it!
|
||||
/// </summary>
|
||||
public WorldThread()
|
||||
{
|
||||
Tick += OnTick;
|
||||
@ -23,7 +29,7 @@ namespace CoopClient
|
||||
};
|
||||
}
|
||||
|
||||
public static void OnTick(object sender, EventArgs e)
|
||||
internal static void OnTick(object sender, EventArgs e)
|
||||
{
|
||||
if (Game.IsLoading)
|
||||
{
|
||||
|
Reference in New Issue
Block a user