mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-02-18 02:41:54 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c594cd534e | ||
|
|
5aaf0e6f62 | ||
|
|
942e776688 |
15
Database.cs
15
Database.cs
@@ -1,15 +1,11 @@
|
||||
using MySqlConnector;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MySqlConnector;
|
||||
|
||||
namespace WeaponPaints
|
||||
{
|
||||
public class Database
|
||||
public class Database(string dbConnectionString)
|
||||
{
|
||||
private readonly string _dbConnectionString;
|
||||
|
||||
public Database(string dbConnectionString)
|
||||
{
|
||||
_dbConnectionString = dbConnectionString;
|
||||
}
|
||||
private readonly string _dbConnectionString = dbConnectionString;
|
||||
|
||||
public async Task<MySqlConnection> GetConnectionAsync()
|
||||
{
|
||||
@@ -19,8 +15,9 @@ namespace WeaponPaints
|
||||
await connection.OpenAsync();
|
||||
return connection;
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
WeaponPaints.Instance.Logger.LogError($"Unable to connect to database: {ex.Message}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
32
Events.cs
32
Events.cs
@@ -2,6 +2,8 @@
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Core.Attributes.Registration;
|
||||
using CounterStrikeSharp.API.Modules.Entities;
|
||||
using CounterStrikeSharp.API.Modules.Memory;
|
||||
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
|
||||
|
||||
namespace WeaponPaints
|
||||
{
|
||||
@@ -105,7 +107,7 @@ namespace WeaponPaints
|
||||
private void GivePlayerWeaponSkin(CCSPlayerController player, CBasePlayerWeapon weapon)
|
||||
{
|
||||
if (!Config.Additional.SkinEnabled) return;
|
||||
if (!gPlayerWeaponsInfo.ContainsKey(player.Slot)) return;
|
||||
if (!gPlayerWeaponsInfo.TryGetValue(player.Slot, out System.Collections.Concurrent.ConcurrentDictionary<int, WeaponInfo>? _value)) return;
|
||||
|
||||
bool isKnife = weapon.DesignerName.Contains("knife") || weapon.DesignerName.Contains("bayonet");
|
||||
|
||||
@@ -244,23 +246,27 @@ namespace WeaponPaints
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
public HookResult OnGiveNamedItemPost(DynamicHook hook)
|
||||
{
|
||||
var itemServices = hook.GetParam<CCSPlayer_ItemServices>(0);
|
||||
var weapon = hook.GetReturn<CBasePlayerWeapon>(0);
|
||||
if (!weapon.DesignerName.Contains("weapon"))
|
||||
return HookResult.Continue;
|
||||
try
|
||||
{
|
||||
var itemServices = hook.GetParam<CCSPlayer_ItemServices>(0);
|
||||
var weapon = hook.GetReturn<CBasePlayerWeapon>();
|
||||
if (!weapon.DesignerName.Contains("weapon"))
|
||||
return HookResult.Continue;
|
||||
|
||||
var player = GetPlayerFromItemServices(itemServices);
|
||||
if (player != null)
|
||||
GivePlayerWeaponSkin(player, weapon);
|
||||
var player = GetPlayerFromItemServices(itemServices);
|
||||
if (player != null)
|
||||
GivePlayerWeaponSkin(player, weapon);
|
||||
}
|
||||
catch { }
|
||||
|
||||
return HookResult.Continue;
|
||||
}
|
||||
*/
|
||||
|
||||
public void OnEntitySpawned(CEntityInstance entity)
|
||||
|
||||
public void OnEntityCreated(CEntityInstance entity)
|
||||
{
|
||||
var designerName = entity.DesignerName;
|
||||
|
||||
@@ -331,12 +337,12 @@ namespace WeaponPaints
|
||||
RegisterEventHandler<EventPlayerSpawn>(OnPlayerSpawn);
|
||||
RegisterEventHandler<EventRoundStart>(OnRoundStart);
|
||||
RegisterEventHandler<EventRoundEnd>(OnRoundEnd);
|
||||
RegisterListener<Listeners.OnEntitySpawned>(OnEntitySpawned);
|
||||
RegisterListener<Listeners.OnEntityCreated>(OnEntityCreated);
|
||||
|
||||
if (Config.Additional.ShowSkinImage)
|
||||
RegisterListener<Listeners.OnTick>(OnTick);
|
||||
|
||||
//VirtualFunctions.GiveNamedItemFunc.Hook(OnGiveNamedItemPost, HookMode.Post);
|
||||
VirtualFunctions.GiveNamedItemFunc.Hook(OnGiveNamedItemPost, HookMode.Post);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
||||
public override string ModuleAuthor => "Nereziel & daffyy";
|
||||
public override string ModuleDescription => "Skin, gloves, agents and knife selector, standalone and web-based";
|
||||
public override string ModuleName => "WeaponPaints";
|
||||
public override string ModuleVersion => "2.4a";
|
||||
public override string ModuleVersion => "2.4b";
|
||||
|
||||
public static WeaponPaintsConfig GetWeaponPaintsConfig()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user