mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-03-10 00:22:30 +00:00
Workaround for long player authorization
This commit is contained in:
66
Events.cs
66
Events.cs
@@ -12,7 +12,7 @@ namespace WeaponPaints
|
|||||||
RegisterListener<Listeners.OnClientAuthorized>(OnClientAuthorized);
|
RegisterListener<Listeners.OnClientAuthorized>(OnClientAuthorized);
|
||||||
RegisterListener<Listeners.OnClientDisconnect>(OnClientDisconnect);
|
RegisterListener<Listeners.OnClientDisconnect>(OnClientDisconnect);
|
||||||
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
||||||
//RegisterEventHandler<EventPlayerConnectFull>(OnPlayerConnectFull);
|
RegisterEventHandler<EventPlayerConnectFull>(OnPlayerConnectFull);
|
||||||
RegisterEventHandler<EventPlayerSpawn>(OnPlayerSpawn);
|
RegisterEventHandler<EventPlayerSpawn>(OnPlayerSpawn);
|
||||||
RegisterEventHandler<EventRoundStart>(OnRoundStart, HookMode.Pre);
|
RegisterEventHandler<EventRoundStart>(OnRoundStart, HookMode.Pre);
|
||||||
RegisterEventHandler<EventRoundEnd>(OnRoundEnd);
|
RegisterEventHandler<EventRoundEnd>(OnRoundEnd);
|
||||||
@@ -55,6 +55,23 @@ namespace WeaponPaints
|
|||||||
if (Config.GlobalShare)
|
if (Config.GlobalShare)
|
||||||
GlobalShareConnect();
|
GlobalShareConnect();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
g_hTimerCheckSkinsData = AddTimer(10.0f, () =>
|
||||||
|
{
|
||||||
|
List<CCSPlayerController> players = Utilities.GetPlayers();
|
||||||
|
|
||||||
|
foreach (CCSPlayerController player in players)
|
||||||
|
{
|
||||||
|
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV || player.SteamID == 0) continue;
|
||||||
|
if (gPlayerWeaponsInfo.ContainsKey((int)player.Index)) continue;
|
||||||
|
|
||||||
|
if (Config.Additional.SkinEnabled && weaponSync != null)
|
||||||
|
_ = weaponSync.GetWeaponPaintsFromDatabase((int)player.Index);
|
||||||
|
if (Config.Additional.KnifeEnabled && weaponSync != null)
|
||||||
|
_ = weaponSync.GetKnifeFromDatabase((int)player.Index);
|
||||||
|
|
||||||
|
}
|
||||||
|
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE | CounterStrikeSharp.API.Modules.Timers.TimerFlags.REPEAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClientAuthorized(int playerSlot, SteamID steamID)
|
private void OnClientAuthorized(int playerSlot, SteamID steamID)
|
||||||
@@ -63,29 +80,50 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
CCSPlayerController? player = Utilities.GetPlayerFromIndex(playerIndex);
|
CCSPlayerController? player = Utilities.GetPlayerFromIndex(playerIndex);
|
||||||
|
|
||||||
if (player == null || !player.IsValid || player.IsHLTV) return;
|
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV) return;
|
||||||
|
|
||||||
if (Config.Additional.SkinEnabled && weaponSync != null)
|
if (Config.Additional.SkinEnabled && weaponSync != null)
|
||||||
_ = weaponSync.GetWeaponPaintsFromDatabase(playerIndex);
|
_ = weaponSync.GetWeaponPaintsFromDatabase(playerIndex);
|
||||||
if (Config.Additional.KnifeEnabled && weaponSync != null)
|
if (Config.Additional.KnifeEnabled && weaponSync != null)
|
||||||
_ = weaponSync.GetKnifeFromDatabase(playerIndex);
|
_ = weaponSync.GetKnifeFromDatabase(playerIndex);
|
||||||
|
|
||||||
/*
|
|
||||||
Task.Run(async () =>
|
|
||||||
{
|
|
||||||
if (Config.Additional.SkinEnabled && weaponSync != null)
|
|
||||||
await weaponSync.GetWeaponPaintsFromDatabase(playerIndex);
|
|
||||||
if (Config.Additional.KnifeEnabled && weaponSync != null)
|
|
||||||
await weaponSync.GetKnifeFromDatabase(playerIndex);
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* WORKAROUND FOR CLIENTS WITHOUT STEAMID ON AUTHORIZATION */
|
||||||
|
private HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventInfo info)
|
||||||
|
{
|
||||||
|
CCSPlayerController? player = @event.Userid;
|
||||||
|
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV) return HookResult.Continue;
|
||||||
|
|
||||||
|
if (!gPlayerWeaponsInfo.ContainsKey((int)player.Index))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"[WeaponPaints] Retrying to retrieve player {player.PlayerName} skins");
|
||||||
|
if (Config.Additional.SkinEnabled && weaponSync != null)
|
||||||
|
_ = weaponSync.GetWeaponPaintsFromDatabase((int)player.Index);
|
||||||
|
if (Config.Additional.KnifeEnabled && weaponSync != null)
|
||||||
|
_ = weaponSync.GetKnifeFromDatabase((int)player.Index);
|
||||||
|
|
||||||
|
/*
|
||||||
|
AddTimer(2.0f, () =>
|
||||||
|
{
|
||||||
|
if (!gPlayerWeaponsInfo.ContainsKey((int)player.Index))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"[WeaponPaints] Last try to retrieve player {player.PlayerName} skins");
|
||||||
|
if (Config.Additional.SkinEnabled && weaponSync != null)
|
||||||
|
_ = weaponSync.GetWeaponPaintsFromDatabase((int)player.Index);
|
||||||
|
if (Config.Additional.KnifeEnabled && weaponSync != null)
|
||||||
|
_ = weaponSync.GetKnifeFromDatabase((int)player.Index);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
return HookResult.Continue;
|
||||||
|
}
|
||||||
private void OnClientDisconnect(int playerSlot)
|
private void OnClientDisconnect(int playerSlot)
|
||||||
{
|
{
|
||||||
CCSPlayerController player = Utilities.GetPlayerFromSlot(playerSlot);
|
CCSPlayerController player = Utilities.GetPlayerFromSlot(playerSlot);
|
||||||
|
|
||||||
if (player == null || !player.IsValid || player.IsHLTV) return;
|
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV) return;
|
||||||
|
|
||||||
if (Config.Additional.KnifeEnabled)
|
if (Config.Additional.KnifeEnabled)
|
||||||
g_playersKnife.Remove((int)player.Index);
|
g_playersKnife.Remove((int)player.Index);
|
||||||
@@ -146,7 +184,7 @@ namespace WeaponPaints
|
|||||||
g_knifePickupCount[(int)player.Index]++;
|
g_knifePickupCount[(int)player.Index]++;
|
||||||
|
|
||||||
RemovePlayerKnife(player, true);
|
RemovePlayerKnife(player, true);
|
||||||
AddTimer(0.3f, ()=> GiveKnifeToPlayer(player));
|
AddTimer(0.3f, () => GiveKnifeToPlayer(player));
|
||||||
|
|
||||||
//RefreshPlayerKnife(player);
|
//RefreshPlayerKnife(player);
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
|
|
||||||
internal static WeaponSynchronization? weaponSync;
|
internal static WeaponSynchronization? weaponSync;
|
||||||
|
|
||||||
|
private CounterStrikeSharp.API.Modules.Timers.Timer? g_hTimerCheckSkinsData = null;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
private Dictionary<int, Dictionary<int, int>> gPlayerWeaponPaints = new();
|
private Dictionary<int, Dictionary<int, int>> gPlayerWeaponPaints = new();
|
||||||
private Dictionary<int, Dictionary<int, int>> gPlayerWeaponSeed = new();
|
private Dictionary<int, Dictionary<int, int>> gPlayerWeaponSeed = new();
|
||||||
|
|||||||
Reference in New Issue
Block a user