Small changes. New folder for menus added
This commit is contained in:
@ -70,6 +70,8 @@
|
|||||||
<Compile Include="Entities\EntitiesPlayer.cs" />
|
<Compile Include="Entities\EntitiesPlayer.cs" />
|
||||||
<Compile Include="Entities\EntitiesThread.cs" />
|
<Compile Include="Entities\EntitiesThread.cs" />
|
||||||
<Compile Include="Main.cs" />
|
<Compile Include="Main.cs" />
|
||||||
|
<Compile Include="Menus\MenusMain.cs" />
|
||||||
|
<Compile Include="Menus\Sub\Settings.cs" />
|
||||||
<Compile Include="Networking.cs" />
|
<Compile Include="Networking.cs" />
|
||||||
<Compile Include="Packets.cs" />
|
<Compile Include="Packets.cs" />
|
||||||
<Compile Include="PlayerList.cs" />
|
<Compile Include="PlayerList.cs" />
|
||||||
|
203
Client/Main.cs
203
Client/Main.cs
@ -4,13 +4,11 @@ using System.Windows.Forms;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using CoopClient.Entities;
|
using CoopClient.Entities;
|
||||||
|
using CoopClient.Menus;
|
||||||
|
|
||||||
using GTA;
|
using GTA;
|
||||||
using GTA.Native;
|
using GTA.Native;
|
||||||
|
|
||||||
using LemonUI;
|
|
||||||
using LemonUI.Menus;
|
|
||||||
|
|
||||||
namespace CoopClient
|
namespace CoopClient
|
||||||
{
|
{
|
||||||
public class Main : Script
|
public class Main : Script
|
||||||
@ -26,17 +24,8 @@ namespace CoopClient
|
|||||||
private static bool IsGoingToCar = false;
|
private static bool IsGoingToCar = false;
|
||||||
|
|
||||||
public static Settings MainSettings = Util.ReadSettings();
|
public static Settings MainSettings = Util.ReadSettings();
|
||||||
public static ObjectPool MainMenuPool = new ObjectPool();
|
|
||||||
public static NativeMenu MainMenu = new NativeMenu("GTACOOP:R", CurrentModVersion.Replace("_", "."))
|
public static MenusMain MainMenu = new MenusMain();
|
||||||
{
|
|
||||||
UseMouse = false,
|
|
||||||
Alignment = MainSettings.FlipMenu ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left
|
|
||||||
};
|
|
||||||
public static NativeMenu MainSettingsMenu = new NativeMenu("GTACOOP:R", "Settings", "Go to the settings")
|
|
||||||
{
|
|
||||||
UseMouse = false,
|
|
||||||
Alignment = MainSettings.FlipMenu ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left
|
|
||||||
};
|
|
||||||
public static Chat MainChat = new Chat();
|
public static Chat MainChat = new Chat();
|
||||||
public static PlayerList MainPlayerList = new PlayerList();
|
public static PlayerList MainPlayerList = new PlayerList();
|
||||||
|
|
||||||
@ -51,113 +40,6 @@ namespace CoopClient
|
|||||||
Function.Call((Hash)0x0888C3502DBBEEF5); // _LOAD_MP_DLC_MAPS
|
Function.Call((Hash)0x0888C3502DBBEEF5); // _LOAD_MP_DLC_MAPS
|
||||||
Function.Call((Hash)0x9BAE5AD2508DF078, true); // _ENABLE_MP_DLC_MAPS
|
Function.Call((Hash)0x9BAE5AD2508DF078, true); // _ENABLE_MP_DLC_MAPS
|
||||||
|
|
||||||
NativeItem usernameItem = new NativeItem("Username")
|
|
||||||
{
|
|
||||||
AltTitle = MainSettings.Username
|
|
||||||
};
|
|
||||||
usernameItem.Activated += (menu, item) =>
|
|
||||||
{
|
|
||||||
string newUsername = Game.GetUserInput(WindowTitle.EnterMessage20, usernameItem.AltTitle, 20);
|
|
||||||
if (!string.IsNullOrWhiteSpace(newUsername))
|
|
||||||
{
|
|
||||||
MainSettings.Username = newUsername;
|
|
||||||
Util.SaveSettings();
|
|
||||||
|
|
||||||
usernameItem.AltTitle = newUsername;
|
|
||||||
MainMenuPool.RefreshAll();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
NativeItem serverIpItem = new NativeItem("Server IP")
|
|
||||||
{
|
|
||||||
AltTitle = MainSettings.LastServerAddress
|
|
||||||
};
|
|
||||||
serverIpItem.Activated += (menu, item) =>
|
|
||||||
{
|
|
||||||
string newServerIp = Game.GetUserInput(WindowTitle.EnterMessage60, serverIpItem.AltTitle, 60);
|
|
||||||
if (!string.IsNullOrWhiteSpace(newServerIp) && newServerIp.Contains(":"))
|
|
||||||
{
|
|
||||||
MainSettings.LastServerAddress = newServerIp;
|
|
||||||
Util.SaveSettings();
|
|
||||||
|
|
||||||
serverIpItem.AltTitle = newServerIp;
|
|
||||||
MainMenuPool.RefreshAll();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
NativeItem serverConnectItem = new NativeItem("Connect");
|
|
||||||
serverConnectItem.Activated += (sender, item) =>
|
|
||||||
{
|
|
||||||
MainNetworking.DisConnectFromServer(MainSettings.LastServerAddress);
|
|
||||||
MainMenu.Visible = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
NativeCheckboxItem shareNpcsItem = new NativeCheckboxItem("Share Npcs", ShareNpcsWithPlayers);
|
|
||||||
shareNpcsItem.CheckboxChanged += (item, check) =>
|
|
||||||
{
|
|
||||||
ShareNpcsWithPlayers = shareNpcsItem.Checked;
|
|
||||||
};
|
|
||||||
shareNpcsItem.Enabled = false;
|
|
||||||
|
|
||||||
NativeSliderItem streamedNpcsItem = new NativeSliderItem(string.Format("Streamed Npcs ({0})", MainSettings.StreamedNpc), 20, MainSettings.StreamedNpc);
|
|
||||||
streamedNpcsItem.ValueChanged += (item, value) =>
|
|
||||||
{
|
|
||||||
MainSettings.StreamedNpc = streamedNpcsItem.Value;
|
|
||||||
Util.SaveSettings();
|
|
||||||
streamedNpcsItem.Title = string.Format("Streamed Npcs ({0})", MainSettings.StreamedNpc);
|
|
||||||
};
|
|
||||||
|
|
||||||
NativeCheckboxItem flipMenuItem = new NativeCheckboxItem("Flip menu", MainSettings.FlipMenu);
|
|
||||||
flipMenuItem.CheckboxChanged += (item, check) =>
|
|
||||||
{
|
|
||||||
MainMenu.Alignment = flipMenuItem.Checked ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left;
|
|
||||||
MainSettingsMenu.Alignment = flipMenuItem.Checked ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left;
|
|
||||||
|
|
||||||
MainSettings.FlipMenu = flipMenuItem.Checked;
|
|
||||||
Util.SaveSettings();
|
|
||||||
};
|
|
||||||
|
|
||||||
NativeItem aboutItem = new NativeItem("About", "~g~GTACOOP~s~:~b~R ~s~by EntenKoeniq")
|
|
||||||
{
|
|
||||||
LeftBadge = new LemonUI.Elements.ScaledTexture("commonmenu", "shop_new_star")
|
|
||||||
};
|
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
NativeCheckboxItem useDebugItem = new NativeCheckboxItem("Debug", UseDebug);
|
|
||||||
useDebugItem.CheckboxChanged += (item, check) =>
|
|
||||||
{
|
|
||||||
UseDebug = useDebugItem.Checked;
|
|
||||||
|
|
||||||
if (!useDebugItem.Checked && DebugSyncPed != null)
|
|
||||||
{
|
|
||||||
if (DebugSyncPed.Character.Exists())
|
|
||||||
{
|
|
||||||
DebugSyncPed.Character.Kill();
|
|
||||||
DebugSyncPed.Character.Delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
DebugSyncPed = null;
|
|
||||||
FullDebugSync = true;
|
|
||||||
Players.Remove("DebugKey");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
MainMenu.Add(usernameItem);
|
|
||||||
MainMenu.Add(serverIpItem);
|
|
||||||
MainMenu.Add(serverConnectItem);
|
|
||||||
MainMenu.AddSubMenu(MainSettingsMenu);
|
|
||||||
MainSettingsMenu.Add(shareNpcsItem);
|
|
||||||
MainSettingsMenu.Add(streamedNpcsItem);
|
|
||||||
MainSettingsMenu.Add(flipMenuItem);
|
|
||||||
#if DEBUG
|
|
||||||
MainSettingsMenu.Add(useDebugItem);
|
|
||||||
#endif
|
|
||||||
MainMenu.Add(aboutItem);
|
|
||||||
|
|
||||||
MainMenuPool.Add(MainMenu);
|
|
||||||
MainMenuPool.Add(MainSettingsMenu);
|
|
||||||
|
|
||||||
Tick += OnTick;
|
Tick += OnTick;
|
||||||
KeyDown += OnKeyDown;
|
KeyDown += OnKeyDown;
|
||||||
Aborted += OnAbort;
|
Aborted += OnAbort;
|
||||||
@ -176,12 +58,9 @@ namespace CoopClient
|
|||||||
{
|
{
|
||||||
RelationshipGroup = World.AddRelationshipGroup("SYNCPED");
|
RelationshipGroup = World.AddRelationshipGroup("SYNCPED");
|
||||||
Game.Player.Character.RelationshipGroup = RelationshipGroup;
|
Game.Player.Character.RelationshipGroup = RelationshipGroup;
|
||||||
|
|
||||||
Function.Call(Hash.SET_CAN_ATTACK_FRIENDLY, Game.Player.Character, true, true);
|
|
||||||
Function.Call(Hash.SET_PED_CAN_BE_TARGETTED, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainMenuPool.Process();
|
MainMenu.MenuPool.Process();
|
||||||
|
|
||||||
MainNetworking.ReceiveMessages();
|
MainNetworking.ReceiveMessages();
|
||||||
|
|
||||||
@ -196,7 +75,7 @@ namespace CoopClient
|
|||||||
}
|
}
|
||||||
|
|
||||||
MainChat.Tick();
|
MainChat.Tick();
|
||||||
if (!MainChat.Focused && !MainMenuPool.AreAnyVisible)
|
if (!MainChat.Focused && !MainMenu.MenuPool.AreAnyVisible)
|
||||||
{
|
{
|
||||||
MainPlayerList.Tick();
|
MainPlayerList.Tick();
|
||||||
}
|
}
|
||||||
@ -231,14 +110,14 @@ namespace CoopClient
|
|||||||
switch (e.KeyCode)
|
switch (e.KeyCode)
|
||||||
{
|
{
|
||||||
case Keys.F9:
|
case Keys.F9:
|
||||||
if (MainMenuPool.AreAnyVisible)
|
if (MainMenu.MenuPool.AreAnyVisible)
|
||||||
{
|
{
|
||||||
MainMenu.Visible = false;
|
MainMenu.MainMenu.Visible = false;
|
||||||
MainSettingsMenu.Visible = false;
|
MainMenu.SubSettings.MainMenu.Visible = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MainMenu.Visible = true;
|
MainMenu.MainMenu.Visible = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Keys.T:
|
case Keys.T:
|
||||||
@ -287,15 +166,73 @@ namespace CoopClient
|
|||||||
{
|
{
|
||||||
player.Value.Character?.AttachedBlip?.Delete();
|
player.Value.Character?.AttachedBlip?.Delete();
|
||||||
player.Value.Character?.CurrentVehicle?.Delete();
|
player.Value.Character?.CurrentVehicle?.Delete();
|
||||||
|
player.Value.Character?.Kill();
|
||||||
player.Value.Character?.Delete();
|
player.Value.Character?.Delete();
|
||||||
player.Value.PedBlip?.Delete();
|
player.Value.PedBlip?.Delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (KeyValuePair<string, EntitiesNpc> Npc in Npcs)
|
||||||
|
{
|
||||||
|
Npc.Value.Character?.CurrentVehicle?.Delete();
|
||||||
|
Npc.Value.Character?.Kill();
|
||||||
|
Npc.Value.Character?.Delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CleanUp()
|
||||||
|
{
|
||||||
|
foreach (KeyValuePair<string, EntitiesPlayer> player in Players)
|
||||||
|
{
|
||||||
|
player.Value.Character?.AttachedBlip?.Delete();
|
||||||
|
player.Value.Character?.CurrentVehicle?.Delete();
|
||||||
|
player.Value.Character?.Kill();
|
||||||
|
player.Value.Character?.Delete();
|
||||||
|
player.Value.PedBlip?.Delete();
|
||||||
|
}
|
||||||
|
Players.Clear();
|
||||||
|
|
||||||
|
foreach (KeyValuePair<string, EntitiesNpc> Npc in Npcs)
|
||||||
|
{
|
||||||
|
Npc.Value.Character?.CurrentVehicle?.Delete();
|
||||||
|
Npc.Value.Character?.Kill();
|
||||||
|
Npc.Value.Character?.Delete();
|
||||||
|
}
|
||||||
|
Npcs.Clear();
|
||||||
|
|
||||||
|
foreach (Ped entity in World.GetAllPeds())
|
||||||
|
{
|
||||||
|
if (entity.Handle != Game.Player.Character.Handle)
|
||||||
|
{
|
||||||
|
entity.Kill();
|
||||||
|
entity.Delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Game.Player.Character.IsInVehicle())
|
||||||
|
{
|
||||||
|
foreach (Vehicle vehicle in World.GetAllVehicles())
|
||||||
|
{
|
||||||
|
vehicle.Delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int? playerVehicleHandle = Game.Player.Character.CurrentVehicle?.Handle;
|
||||||
|
|
||||||
|
foreach (Vehicle vehicle in World.GetAllVehicles())
|
||||||
|
{
|
||||||
|
if (playerVehicleHandle != vehicle.Handle)
|
||||||
|
{
|
||||||
|
vehicle.Delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int ArtificialLagCounter;
|
private int ArtificialLagCounter;
|
||||||
private EntitiesPlayer DebugSyncPed;
|
public static EntitiesPlayer DebugSyncPed;
|
||||||
private bool FullDebugSync = true;
|
public static bool FullDebugSync = true;
|
||||||
private bool UseDebug = false;
|
public static bool UseDebug = false;
|
||||||
|
|
||||||
private void Debug()
|
private void Debug()
|
||||||
{
|
{
|
||||||
|
72
Client/Menus/MenusMain.cs
Normal file
72
Client/Menus/MenusMain.cs
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
using GTA;
|
||||||
|
|
||||||
|
using LemonUI;
|
||||||
|
using LemonUI.Menus;
|
||||||
|
|
||||||
|
namespace CoopClient.Menus
|
||||||
|
{
|
||||||
|
public class MenusMain
|
||||||
|
{
|
||||||
|
public ObjectPool MenuPool = new ObjectPool();
|
||||||
|
|
||||||
|
public NativeMenu MainMenu = new NativeMenu("GTACOOP:R", Main.CurrentModVersion.Replace("_", "."))
|
||||||
|
{
|
||||||
|
UseMouse = false,
|
||||||
|
Alignment = Main.MainSettings.FlipMenu ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left
|
||||||
|
};
|
||||||
|
#region ===== SUB =====
|
||||||
|
public Sub.Settings SubSettings = new Sub.Settings();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ===== ITEMS =====
|
||||||
|
private readonly NativeItem UsernameItem = new NativeItem("Username") { AltTitle = Main.MainSettings.Username };
|
||||||
|
private readonly NativeItem ServerIpItem = new NativeItem("Server IP") { AltTitle = Main.MainSettings.LastServerAddress };
|
||||||
|
private readonly NativeItem ServerConnectItem = new NativeItem("Connect");
|
||||||
|
private readonly NativeItem AboutItem = new NativeItem("About", "~g~GTACOOP~s~:~b~R ~s~by EntenKoeniq") { LeftBadge = new LemonUI.Elements.ScaledTexture("commonmenu", "shop_new_star") };
|
||||||
|
#endregion // !ITEMS
|
||||||
|
|
||||||
|
public MenusMain()
|
||||||
|
{
|
||||||
|
UsernameItem.Activated += UsernameActivated;
|
||||||
|
ServerIpItem.Activated += ServerIpActivated;
|
||||||
|
ServerConnectItem.Activated += (sender, item) => { Main.MainNetworking.DisConnectFromServer(Main.MainSettings.LastServerAddress); };
|
||||||
|
|
||||||
|
MainMenu.Add(UsernameItem);
|
||||||
|
MainMenu.Add(ServerIpItem);
|
||||||
|
MainMenu.Add(ServerConnectItem);
|
||||||
|
|
||||||
|
MainMenu.AddSubMenu(SubSettings.MainMenu);
|
||||||
|
|
||||||
|
MainMenu.Add(AboutItem);
|
||||||
|
|
||||||
|
MenuPool.Add(MainMenu);
|
||||||
|
MenuPool.Add(SubSettings.MainMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UsernameActivated(object a, System.EventArgs b)
|
||||||
|
{
|
||||||
|
string newUsername = Game.GetUserInput(WindowTitle.EnterMessage20, UsernameItem.AltTitle, 20);
|
||||||
|
if (!string.IsNullOrWhiteSpace(newUsername))
|
||||||
|
{
|
||||||
|
Main.MainSettings.Username = newUsername;
|
||||||
|
Util.SaveSettings();
|
||||||
|
|
||||||
|
UsernameItem.AltTitle = newUsername;
|
||||||
|
MenuPool.RefreshAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ServerIpActivated(object a, System.EventArgs b)
|
||||||
|
{
|
||||||
|
string newServerIp = Game.GetUserInput(WindowTitle.EnterMessage60, ServerIpItem.AltTitle, 60);
|
||||||
|
if (!string.IsNullOrWhiteSpace(newServerIp) && newServerIp.Contains(":"))
|
||||||
|
{
|
||||||
|
Main.MainSettings.LastServerAddress = newServerIp;
|
||||||
|
Util.SaveSettings();
|
||||||
|
|
||||||
|
ServerIpItem.AltTitle = newServerIp;
|
||||||
|
MenuPool.RefreshAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
69
Client/Menus/Sub/Settings.cs
Normal file
69
Client/Menus/Sub/Settings.cs
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
using LemonUI.Menus;
|
||||||
|
|
||||||
|
namespace CoopClient.Menus.Sub
|
||||||
|
{
|
||||||
|
public class Settings
|
||||||
|
{
|
||||||
|
public 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
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly NativeCheckboxItem ShareNpcsItem = new NativeCheckboxItem("Share Npcs", Main.ShareNpcsWithPlayers) { Enabled = false };
|
||||||
|
private readonly NativeSliderItem StreamedNpcsItem = new NativeSliderItem(string.Format("Streamed Npcs ({0})", Main.MainSettings.StreamedNpc), 20, Main.MainSettings.StreamedNpc);
|
||||||
|
private readonly NativeCheckboxItem FlipMenuItem = new NativeCheckboxItem("Flip menu", Main.MainSettings.FlipMenu);
|
||||||
|
private readonly NativeCheckboxItem UseDebugItem = new NativeCheckboxItem("Debug", Main.UseDebug);
|
||||||
|
|
||||||
|
public Settings()
|
||||||
|
{
|
||||||
|
ShareNpcsItem.CheckboxChanged += (item, check) => { Main.ShareNpcsWithPlayers = ShareNpcsItem.Checked; };
|
||||||
|
StreamedNpcsItem.ValueChanged += StreamedNpcsValueChanged;
|
||||||
|
FlipMenuItem.CheckboxChanged += FlipMenuCheckboxChanged;
|
||||||
|
#if DEBUG
|
||||||
|
UseDebugItem.CheckboxChanged += UseDebugCheckboxChanged;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
MainMenu.Add(ShareNpcsItem);
|
||||||
|
MainMenu.Add(StreamedNpcsItem);
|
||||||
|
MainMenu.Add(FlipMenuItem);
|
||||||
|
#if DEBUG
|
||||||
|
MainMenu.Add(UseDebugItem);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public 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)
|
||||||
|
{
|
||||||
|
Main.MainMenu.MainMenu.Alignment = FlipMenuItem.Checked ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left;
|
||||||
|
MainMenu.Alignment = FlipMenuItem.Checked ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left;
|
||||||
|
|
||||||
|
Main.MainSettings.FlipMenu = FlipMenuItem.Checked;
|
||||||
|
Util.SaveSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UseDebugCheckboxChanged(object a, System.EventArgs b)
|
||||||
|
{
|
||||||
|
Main.UseDebug = UseDebugItem.Checked;
|
||||||
|
|
||||||
|
if (!UseDebugItem.Checked && Main.DebugSyncPed != null)
|
||||||
|
{
|
||||||
|
if (Main.DebugSyncPed.Character.Exists())
|
||||||
|
{
|
||||||
|
Main.DebugSyncPed.Character.Kill();
|
||||||
|
Main.DebugSyncPed.Character.Delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
Main.DebugSyncPed = null;
|
||||||
|
Main.FullDebugSync = true;
|
||||||
|
Main.Players.Remove("DebugKey");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -80,9 +80,9 @@ namespace CoopClient
|
|||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
case NetConnectionStatus.InitiatedConnect:
|
case NetConnectionStatus.InitiatedConnect:
|
||||||
Main.MainMenu.Items[0].Enabled = false;
|
Main.MainMenu.MainMenu.Items[0].Enabled = false;
|
||||||
Main.MainMenu.Items[1].Enabled = false;
|
Main.MainMenu.MainMenu.Items[1].Enabled = false;
|
||||||
Main.MainMenu.Items[2].Enabled = false;
|
Main.MainMenu.MainMenu.Items[2].Enabled = false;
|
||||||
GTA.UI.Notification.Show("~y~Trying to connect...");
|
GTA.UI.Notification.Show("~y~Trying to connect...");
|
||||||
break;
|
break;
|
||||||
case NetConnectionStatus.Connected:
|
case NetConnectionStatus.Connected:
|
||||||
@ -100,31 +100,12 @@ namespace CoopClient
|
|||||||
Main.LocalPlayerID = handshakePacket.ID;
|
Main.LocalPlayerID = handshakePacket.ID;
|
||||||
Main.NpcsAllowed = handshakePacket.NpcsAllowed;
|
Main.NpcsAllowed = handshakePacket.NpcsAllowed;
|
||||||
|
|
||||||
foreach (Ped entity in World.GetAllPeds())
|
Main.CleanUp();
|
||||||
{
|
|
||||||
if (entity.Handle != Game.Player.Character.Handle)
|
|
||||||
{
|
|
||||||
entity.Kill();
|
|
||||||
entity.Delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (Vehicle vehicle in World.GetAllVehicles())
|
|
||||||
{
|
|
||||||
if (Game.Player.Character.CurrentVehicle?.Handle != vehicle.Handle)
|
|
||||||
{
|
|
||||||
vehicle.Delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Function.Call(Hash.SET_GARBAGE_TRUCKS, 0);
|
Function.Call(Hash.SET_GARBAGE_TRUCKS, 0);
|
||||||
Function.Call(Hash.SET_RANDOM_BOATS, 0);
|
Function.Call(Hash.SET_RANDOM_BOATS, 0);
|
||||||
Function.Call(Hash.SET_RANDOM_TRAINS, 0);
|
Function.Call(Hash.SET_RANDOM_TRAINS, 0);
|
||||||
|
|
||||||
Main.MainMenu.Items[2].Enabled = true;
|
|
||||||
Main.MainMenu.Items[2].Title = "Disconnect";
|
|
||||||
Main.MainSettingsMenu.Items[0].Enabled = Main.NpcsAllowed;
|
|
||||||
|
|
||||||
Main.MainChat.Init();
|
Main.MainChat.Init();
|
||||||
Main.MainPlayerList.Init(Main.MainSettings.Username);
|
Main.MainPlayerList.Init(Main.MainSettings.Username);
|
||||||
|
|
||||||
@ -140,6 +121,13 @@ namespace CoopClient
|
|||||||
Client.FlushSendQueue();
|
Client.FlushSendQueue();
|
||||||
|
|
||||||
GTA.UI.Notification.Show("~g~Connected!");
|
GTA.UI.Notification.Show("~g~Connected!");
|
||||||
|
|
||||||
|
Main.MainMenu.MainMenu.Items[2].Enabled = true;
|
||||||
|
Main.MainMenu.MainMenu.Items[2].Title = "Disconnect";
|
||||||
|
Main.MainMenu.SubSettings.MainMenu.Items[0].Enabled = Main.NpcsAllowed;
|
||||||
|
|
||||||
|
Main.MainMenu.MainMenu.Visible = false;
|
||||||
|
Main.MainMenu.MenuPool.RefreshAll();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NetConnectionStatus.Disconnected:
|
case NetConnectionStatus.Disconnected:
|
||||||
@ -157,35 +145,15 @@ namespace CoopClient
|
|||||||
|
|
||||||
Main.MainChat.Clear();
|
Main.MainChat.Clear();
|
||||||
|
|
||||||
Main.MainMenu.Items[0].Enabled = true;
|
Main.CleanUp();
|
||||||
Main.MainMenu.Items[1].Enabled = true;
|
|
||||||
Main.MainMenu.Items[2].Enabled = true;
|
|
||||||
Main.MainMenu.Items[2].Title = "Connect";
|
|
||||||
Main.MainSettingsMenu.Items[0].Enabled = false;
|
|
||||||
|
|
||||||
foreach (KeyValuePair<string, EntitiesPlayer> player in Main.Players)
|
Main.MainMenu.MainMenu.Items[0].Enabled = true;
|
||||||
{
|
Main.MainMenu.MainMenu.Items[1].Enabled = true;
|
||||||
if (player.Value.Character != null && player.Value.Character.Exists())
|
Main.MainMenu.MainMenu.Items[2].Enabled = true;
|
||||||
{
|
Main.MainMenu.MainMenu.Items[2].Title = "Connect";
|
||||||
player.Value.Character.Kill();
|
Main.MainMenu.SubSettings.MainMenu.Items[0].Enabled = false;
|
||||||
player.Value.Character.Delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
player.Value.PedBlip?.Delete();
|
Main.MainMenu.MenuPool.RefreshAll();
|
||||||
}
|
|
||||||
|
|
||||||
Main.Players.Clear();
|
|
||||||
|
|
||||||
foreach (KeyValuePair<string, EntitiesNpc> npc in Main.Npcs)
|
|
||||||
{
|
|
||||||
if (npc.Value.Character != null && npc.Value.Character.Exists())
|
|
||||||
{
|
|
||||||
npc.Value.Character.Kill();
|
|
||||||
npc.Value.Character.Delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Main.Npcs.Clear();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -21,6 +21,9 @@ namespace CoopClient
|
|||||||
}
|
}
|
||||||
|
|
||||||
Function.Call((Hash)0xB96B00E976BE977F, 0.0f); // _SET_WAVES_INTENSITY
|
Function.Call((Hash)0xB96B00E976BE977F, 0.0f); // _SET_WAVES_INTENSITY
|
||||||
|
|
||||||
|
Function.Call(Hash.SET_CAN_ATTACK_FRIENDLY, Game.Player.Character.Handle, true, false);
|
||||||
|
Function.Call(Hash.SET_PED_CAN_BE_TARGETTED, Game.Player.Character.Handle, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user