Skip to content

Commit

Permalink
Back to onclientauthorized
Browse files Browse the repository at this point in the history
Thanks cssharp :D
  • Loading branch information
daffyyyy committed Nov 29, 2023
1 parent 393281e commit 73e3a05
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
29 changes: 21 additions & 8 deletions Events.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Entities;

namespace WeaponPaints
{
Expand All @@ -8,17 +9,17 @@ public partial class WeaponPaints
private void RegisterEvents()
{
RegisterListener<Listeners.OnEntitySpawned>(OnEntitySpawned);
/*RegisterListener<Listeners.OnClientAuthorized>(OnClientAuthorized);*/
RegisterListener<Listeners.OnClientAuthorized>(OnClientAuthorized);
RegisterListener<Listeners.OnClientDisconnect>(OnClientDisconnect);
RegisterListener<Listeners.OnMapStart>(OnMapStart);
RegisterEventHandler<EventPlayerConnectFull>(OnPlayerConnectFull);
//RegisterEventHandler<EventPlayerConnectFull>(OnPlayerConnectFull);
RegisterEventHandler<EventPlayerSpawn>(OnPlayerSpawn);
RegisterEventHandler<EventRoundStart>(OnRoundStart, HookMode.Pre);
RegisterEventHandler<EventItemPurchase>(OnEventItemPurchasePost);
RegisterEventHandler<EventItemPickup>(OnItemPickup);
}

private HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventInfo info)
/*private HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventInfo info)
{
CCSPlayerController? player = @event.Userid;
Expand All @@ -29,17 +30,16 @@ private HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventI
_ = weaponSync.GetWeaponPaintsFromDatabase(playerIndex);
if (Config.Additional.KnifeEnabled && weaponSync != null)
_ = weaponSync.GetKnifeFromDatabase(playerIndex);
/*
Task.Run(async () =>
{
if (Config.Additional.SkinEnabled && weaponSync != null)
if (Config.Additional.KnifeEnabled && weaponSync != null)
});
*/
return HookResult.Continue;
}

*/
private void OnMapStart(string mapName)
{
if (!Config.Additional.KnifeEnabled) return;
Expand All @@ -52,19 +52,32 @@ private void OnMapStart(string mapName)
NativeAPI.IssueServerCommand("mp_equipment_reset_rounds 0");
});
}
/*

private void OnClientAuthorized(int playerSlot, SteamID steamID)
{
int playerIndex = playerSlot + 1;

CCSPlayerController? player = Utilities.GetPlayerFromIndex(playerIndex);

if (player == null || !player.IsValid || player.IsHLTV) return;

if (Config.Additional.SkinEnabled && weaponSync != null)
_ = weaponSync.GetWeaponPaintsFromDatabase(playerIndex);
if (Config.Additional.KnifeEnabled && weaponSync != null)
_ = 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);
});
*/
}
*/

private void OnClientDisconnect(int playerSlot)
{
CCSPlayerController player = Utilities.GetPlayerFromSlot(playerSlot);
Expand Down
4 changes: 2 additions & 2 deletions WeaponPaints.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CounterStrikeSharp.API" Version="*" />
<PackageReference Include="Dapper" Version="2.1.21" />
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.80" />
<PackageReference Include="Dapper" Version="2.1.24" />
<PackageReference Include="MySqlConnector" Version="2.3.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
Expand Down

0 comments on commit 73e3a05

Please sign in to comment.