Small changes

This commit is contained in:
EntenKoeniq
2022-03-28 14:49:26 +02:00
parent 214aed68ad
commit a6167528dd
5 changed files with 18 additions and 37 deletions

View File

@ -182,7 +182,7 @@ namespace CoopClient
/// </summary>
public static bool IsPlayerListVisible()
{
return Util.GetTickCount64() - PlayerList.Pressed < 5000;
return Main.MainPlayerList != null && Util.GetTickCount64() - Main.MainPlayerList.Pressed < 5000;
}
/// <summary>
@ -277,7 +277,10 @@ namespace CoopClient
/// <param name="leftAlign">true to move the player list to the left</param>
public static void SetPlayerListLeftAlign(bool leftAlign)
{
PlayerList.LeftAlign = leftAlign;
if (Main.MainPlayerList != null)
{
Main.MainPlayerList.LeftAlign = leftAlign;
}
}
#if DEBUG

View File

@ -27,7 +27,7 @@ namespace CoopClient
private void Ontick(object sender, EventArgs e)
{
if (!Main.MainNetworking.IsOnServer())
if (!Main.MainNetworking.IsOnServer() || ScriptEngines == null || ScriptEngines.Count == 0)
{
return;
}
@ -90,6 +90,8 @@ namespace CoopClient
ScriptEngines.ForEach(engine => engine.Script.API.InvokeStop());
ScriptEngines.Clear();
}
ScriptEngines = null;
}
internal static void InvokePlayerConnect(string username, long nethandle)

View File

@ -36,6 +36,7 @@ namespace CoopClient
internal static MenusMain MainMenu = null;
#endif
internal static Chat MainChat = null;
internal static PlayerList MainPlayerList = null;
internal static long LocalNetHandle = 0;
internal static Dictionary<long, EntitiesPlayer> Players = null;
@ -140,6 +141,7 @@ namespace CoopClient
#endif
MainChat.Tick();
MainPlayerList.Tick();
#if DEBUG
if (UseDebug)
@ -208,7 +210,7 @@ namespace CoopClient
if (MainNetworking.IsOnServer())
{
ulong currentTimestamp = Util.GetTickCount64();
PlayerList.Pressed = (currentTimestamp - PlayerList.Pressed) < 5000 ? (currentTimestamp - 6000) : currentTimestamp;
MainPlayerList.Pressed = (currentTimestamp - MainPlayerList.Pressed) < 5000 ? (currentTimestamp - 6000) : currentTimestamp;
}
}
else if (Game.IsControlJustPressed(GTA.Control.MpTextChatAll))

View File

@ -122,6 +122,7 @@ namespace CoopClient
Main.NPCsAllowed = handshakePacket.NPCsAllowed;
Main.MainChat.Init();
Main.MainPlayerList = new PlayerList();
#if !NON_INTERACTIVE
Main.MainMenu.ConnectedMenuSetting();
@ -147,6 +148,7 @@ namespace CoopClient
Main.MainChat.Focused = false;
}
Main.MainPlayerList = null;
Main.CleanUp();
#if !NON_INTERACTIVE

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using CoopClient.Entities.Player;
@ -8,36 +7,17 @@ using GTA.Native;
namespace CoopClient
{
/// <summary>
/// Don't use it!
/// </summary>
public class PlayerList : Script
internal class PlayerList
{
private const float LEFT_POSITION = 0.122f;
private const float RIGHT_POSITION = 0.9f;
private readonly Scaleform MainScaleform = new Scaleform("mp_mm_card_freemode");
private ulong LastUpdate = Util.GetTickCount64();
internal static ulong Pressed { get; set; }
internal ulong Pressed { get; set; }
internal static bool LeftAlign = true;
internal bool LeftAlign = true;
/// <summary>
/// Don't use it!
/// </summary>
public PlayerList()
{
// Required for some synchronization!
if (Game.Version < GameVersion.v1_0_1290_1_Steam)
{
return;
}
Init();
Tick += OnTick;
}
private void OnTick(object sender, EventArgs e)
public void Tick()
{
if (!Main.MainNetworking.IsOnServer())
{
@ -62,14 +42,6 @@ namespace CoopClient
}
}
private void Init()
{
MainScaleform.CallFunction("SET_DATA_SLOT_EMPTY", 0);
MainScaleform.CallFunction("SET_DATA_SLOT", 0, "", "Me", 116, 0, 0, "", "", 2, "", "", ' ');
MainScaleform.CallFunction("SET_TITLE", "Player list", "1 players");
MainScaleform.CallFunction("DISPLAY_VIEW");
}
private void Update(Dictionary<long, EntitiesPlayer> players, string localUsername)
{
LastUpdate = Util.GetTickCount64();