mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-02-27 13:25:32 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21eccfb6d9 | ||
|
|
a6b193cd13 | ||
|
|
b992433d44 | ||
|
|
06559af230 | ||
|
|
dfe6b200d8 | ||
|
|
3edcb5e52f | ||
|
|
28936e9bb5 | ||
|
|
2772fb59b9 |
@@ -86,7 +86,7 @@ namespace WeaponPaints
|
|||||||
if (!Utility.IsPlayerValid(player) || !g_bCommandsAllowed) return;
|
if (!Utility.IsPlayerValid(player) || !g_bCommandsAllowed) return;
|
||||||
int playerIndex = (int)player!.Index;
|
int playerIndex = (int)player!.Index;
|
||||||
|
|
||||||
if (commandCooldown != null && DateTime.UtcNow >= commandCooldown[playerIndex].AddSeconds(Config.CmdRefreshCooldownSeconds) && playerIndex > 0 && playerIndex < commandCooldown.Length)
|
if (commandCooldown != null && DateTime.UtcNow >= commandCooldown[playerIndex].AddSeconds(Config.CmdRefreshCooldownSeconds))
|
||||||
{
|
{
|
||||||
commandCooldown[playerIndex] = DateTime.UtcNow;
|
commandCooldown[playerIndex] = DateTime.UtcNow;
|
||||||
ChatMenus.OpenMenu(player, giveItemMenu);
|
ChatMenus.OpenMenu(player, giveItemMenu);
|
||||||
@@ -130,7 +130,9 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
playerIndex = (int)p.Index;
|
playerIndex = (int)p.Index;
|
||||||
|
|
||||||
var steamId = new SteamID(p.SteamID);
|
if (p.AuthorizedSteamID == null) return;
|
||||||
|
|
||||||
|
string steamId = p.AuthorizedSteamID.SteamId64.ToString();
|
||||||
var firstSkin = skinsList?.FirstOrDefault(skin =>
|
var firstSkin = skinsList?.FirstOrDefault(skin =>
|
||||||
{
|
{
|
||||||
if (skin != null && skin.TryGetValue("weapon_name", out var weaponName))
|
if (skin != null && skin.TryGetValue("weapon_name", out var weaponName))
|
||||||
|
|||||||
80
Events.cs
80
Events.cs
@@ -6,13 +6,14 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
public partial class WeaponPaints
|
public partial class WeaponPaints
|
||||||
{
|
{
|
||||||
private void RegisterEvents()
|
private void RegisterListeners()
|
||||||
{
|
{
|
||||||
RegisterListener<Listeners.OnEntitySpawned>(OnEntitySpawned);
|
RegisterListener<Listeners.OnEntitySpawned>(OnEntitySpawned);
|
||||||
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);
|
||||||
@@ -51,38 +52,79 @@ namespace WeaponPaints
|
|||||||
NativeAPI.IssueServerCommand("mp_t_default_melee \"\"");
|
NativeAPI.IssueServerCommand("mp_t_default_melee \"\"");
|
||||||
NativeAPI.IssueServerCommand("mp_ct_default_melee \"\"");
|
NativeAPI.IssueServerCommand("mp_ct_default_melee \"\"");
|
||||||
NativeAPI.IssueServerCommand("mp_equipment_reset_rounds 0");
|
NativeAPI.IssueServerCommand("mp_equipment_reset_rounds 0");
|
||||||
|
|
||||||
|
if (Config.GlobalShare)
|
||||||
|
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.AuthorizedSteamID == null) 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)
|
||||||
{
|
{
|
||||||
int playerIndex = playerSlot + 1;
|
int playerIndex = playerSlot + 1;
|
||||||
|
|
||||||
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);
|
||||||
@@ -93,7 +135,7 @@ namespace WeaponPaints
|
|||||||
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
|
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
|
||||||
{
|
{
|
||||||
CCSPlayerController? player = @event.Userid;
|
CCSPlayerController? player = @event.Userid;
|
||||||
if (player == null || !player.IsValid || !player.PlayerPawn.IsValid)
|
if (player == null || !player.IsValid)
|
||||||
{
|
{
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
@@ -112,6 +154,7 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
|
private HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
|
||||||
{
|
{
|
||||||
NativeAPI.IssueServerCommand("mp_t_default_melee \"\"");
|
NativeAPI.IssueServerCommand("mp_t_default_melee \"\"");
|
||||||
@@ -143,7 +186,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);
|
||||||
/*
|
/*
|
||||||
@@ -216,6 +259,7 @@ namespace WeaponPaints
|
|||||||
catch (Exception) { }
|
catch (Exception) { }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private HookResult OnEventItemPurchasePost(EventItemPurchase @event, GameEventInfo info)
|
private HookResult OnEventItemPurchasePost(EventItemPurchase @event, GameEventInfo info)
|
||||||
{
|
{
|
||||||
CCSPlayerController? player = @event.Userid;
|
CCSPlayerController? player = @event.Userid;
|
||||||
|
|||||||
11
README.md
11
README.md
@@ -24,7 +24,7 @@ Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin
|
|||||||
|
|
||||||
## Plugin Configuration
|
## Plugin Configuration
|
||||||
<details>
|
<details>
|
||||||
<summary>Spoiler warning</summary>
|
<summary>Click to expand</summary>
|
||||||
<code><pre>{
|
<code><pre>{
|
||||||
"Version": 4, // Don't touch
|
"Version": 4, // Don't touch
|
||||||
"DatabaseHost": "", // MySQL host (required if GlobalShare = false)
|
"DatabaseHost": "", // MySQL host (required if GlobalShare = false)
|
||||||
@@ -43,8 +43,11 @@ Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin
|
|||||||
"CooldownRefreshCommand": "You can\u0027t refresh weapon paints right now.", // Cooldown information (!wp command) Set to empty to disable
|
"CooldownRefreshCommand": "You can\u0027t refresh weapon paints right now.", // Cooldown information (!wp command) Set to empty to disable
|
||||||
"SuccessRefreshCommand": "Refreshing weapon paints.", // Information about refreshing skins (!wp command) Set to empty to disable
|
"SuccessRefreshCommand": "Refreshing weapon paints.", // Information about refreshing skins (!wp command) Set to empty to disable
|
||||||
"ChosenKnifeMenu": "You have chosen {KNIFE} as your knife.", // Information about choosen knife (!knife command) Set to empty to disable
|
"ChosenKnifeMenu": "You have chosen {KNIFE} as your knife.", // Information about choosen knife (!knife command) Set to empty to disable
|
||||||
|
"ChosenSkinMenu": "You have chosen {SKIN} as your skin.", // Information about choosen skin (!skins command) Set to empty to disable
|
||||||
"ChosenKnifeMenuKill": "To correctly apply skin for knife, you need to type !kill.", // Information about suicide after knife selection (!knife command) Set to empty to disable
|
"ChosenKnifeMenuKill": "To correctly apply skin for knife, you need to type !kill.", // Information about suicide after knife selection (!knife command) Set to empty to disable
|
||||||
"KnifeMenuTitle": "Knife Menu." // Menu title (!knife menu)
|
"KnifeMenuTitle": "Knife Menu.", // Menu title (!knife menu)
|
||||||
|
"WeaponMenuTitle": "Weapon Menu.", // Menu title (!skins menu)
|
||||||
|
"SkinMenuTitle": "Select skin for {WEAPON}" // Menu title (!skins menu, after weapon select)
|
||||||
},
|
},
|
||||||
"Additional": {
|
"Additional": {
|
||||||
"SkinVisibilityFix": true, // Enable or disable fix for skin visibility
|
"SkinVisibilityFix": true, // Enable or disable fix for skin visibility
|
||||||
@@ -54,9 +57,11 @@ Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin
|
|||||||
"CommandKillEnabled": true, // Enable or disable kill command
|
"CommandKillEnabled": true, // Enable or disable kill command
|
||||||
"CommandKnife": "knife", // Name of knife menu command, u can change to for e.g, knives
|
"CommandKnife": "knife", // Name of knife menu command, u can change to for e.g, knives
|
||||||
"CommandSkin": "ws", // Name of skin information command, u can change to for e.g, skins
|
"CommandSkin": "ws", // Name of skin information command, u can change to for e.g, skins
|
||||||
|
"CommandSkinSelection": "skins", // Name of skins menu command, u can change to for e.g, weapons
|
||||||
"CommandRefresh": "wp", // Name of skin refreshing command, u can change to for e.g, refreshskins
|
"CommandRefresh": "wp", // Name of skin refreshing command, u can change to for e.g, refreshskins
|
||||||
"CommandKill": "kill", // Name of kill command, u can change to for e.g, suicide
|
"CommandKill": "kill", // Name of kill command, u can change to for e.g, suicide
|
||||||
"GiveRandomKnife": false // Give random knife to players if they didn't choose
|
"GiveRandomKnife": false, // Give random knife to players if they didn't choose
|
||||||
|
"GiveRandomSkins": false // Give random skins to players if they didn't choose
|
||||||
},
|
},
|
||||||
|
|
||||||
"ConfigVersion": 4 // Don't touch
|
"ConfigVersion": 4 // Don't touch
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
internal static bool IsPlayerValid(CCSPlayerController? player)
|
internal static bool IsPlayerValid(CCSPlayerController? player)
|
||||||
{
|
{
|
||||||
return (player != null && player.IsValid && !player.IsBot && !player.IsHLTV && player.SteamID.ToString() != "0");
|
return (player != null && player.IsValid && !player.IsBot && !player.IsHLTV && player.AuthorizedSteamID != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string BuildDatabaseConnectionString()
|
internal static string BuildDatabaseConnectionString()
|
||||||
|
|||||||
@@ -224,11 +224,18 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
Server.NextFrame(() =>
|
Server.NextFrame(() =>
|
||||||
{
|
{
|
||||||
newWeapon.Clip1 = clip1;
|
if (newWeapon == null) return;
|
||||||
newWeapon.ReserveAmmo[0] = reservedAmmo;
|
try
|
||||||
|
{
|
||||||
|
newWeapon.Clip1 = clip1;
|
||||||
|
newWeapon.ReserveAmmo[0] = reservedAmmo;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{ }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch(Exception ex)
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine("[WeaponPaints] Refreshing weapons exception");
|
Console.WriteLine("[WeaponPaints] Refreshing weapons exception");
|
||||||
Console.WriteLine(ex.Message);
|
Console.WriteLine(ex.Message);
|
||||||
@@ -244,16 +251,16 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
if (!_config.Additional.KnifeEnabled) return false;
|
if (!_config.Additional.KnifeEnabled) return false;
|
||||||
|
|
||||||
if (player == null || !player.IsValid)
|
if (player == null || !player.IsValid || !player.PlayerPawn.IsValid)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.PlayerPawn.Value == null || player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null)
|
if (player.PlayerPawn?.Value == null || player.PlayerPawn?.Value.WeaponServices == null || player.PlayerPawn?.Value.ItemServices == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var weapons = player.PlayerPawn.Value.WeaponServices.MyWeapons;
|
var weapons = player.PlayerPawn.Value.WeaponServices?.MyWeapons;
|
||||||
if (weapons == null || weapons.Count <= 0) return false;
|
if (weapons == null) return false;
|
||||||
foreach (var weapon in weapons)
|
foreach (var weapon in weapons)
|
||||||
{
|
{
|
||||||
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
|
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
|
||||||
|
|||||||
@@ -5,18 +5,20 @@ using CounterStrikeSharp.API.Modules.Cvars;
|
|||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace WeaponPaints;
|
namespace WeaponPaints;
|
||||||
[MinimumApiVersion(82)]
|
[MinimumApiVersion(90)]
|
||||||
public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
||||||
{
|
{
|
||||||
public override string ModuleName => "WeaponPaints";
|
public override string ModuleName => "WeaponPaints";
|
||||||
public override string ModuleDescription => "Skin and knife selector, standalone and web-based";
|
public override string ModuleDescription => "Skin and knife selector, standalone and web-based";
|
||||||
public override string ModuleAuthor => "Nereziel & daffyy";
|
public override string ModuleAuthor => "Nereziel & daffyy";
|
||||||
public override string ModuleVersion => "1.3a";
|
public override string ModuleVersion => "1.3b";
|
||||||
public WeaponPaintsConfig Config { get; set; } = new();
|
public WeaponPaintsConfig Config { get; set; } = new();
|
||||||
internal static WeaponPaintsConfig _config = new WeaponPaintsConfig();
|
internal static WeaponPaintsConfig _config = new 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();
|
||||||
@@ -101,10 +103,6 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
Utility.TestDatabaseConnection();
|
Utility.TestDatabaseConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.GlobalShare)
|
|
||||||
GlobalShareConnect();
|
|
||||||
|
|
||||||
|
|
||||||
weaponSync = new WeaponSynchronization(DatabaseConnectionString, Config, GlobalShareApi, GlobalShareServerId);
|
weaponSync = new WeaponSynchronization(DatabaseConnectionString, Config, GlobalShareApi, GlobalShareServerId);
|
||||||
|
|
||||||
if (hotReload)
|
if (hotReload)
|
||||||
@@ -128,7 +126,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
if (Config.Additional.SkinEnabled)
|
if (Config.Additional.SkinEnabled)
|
||||||
SetupSkinsMenu();
|
SetupSkinsMenu();
|
||||||
|
|
||||||
RegisterEvents();
|
RegisterListeners();
|
||||||
RegisterCommands();
|
RegisterCommands();
|
||||||
|
|
||||||
Utility.LoadSkinsFromFile(ModuleDirectory + "/skins.json");
|
Utility.LoadSkinsFromFile(ModuleDirectory + "/skins.json");
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.84" />
|
<PackageReference Include="CounterStrikeSharp.API" Version="*" />
|
||||||
<PackageReference Include="Dapper" Version="2.1.24" />
|
<PackageReference Include="Dapper" Version="2.1.24" />
|
||||||
<PackageReference Include="MySqlConnector" Version="2.3.1" />
|
<PackageReference Include="MySqlConnector" Version="2.3.1" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
|||||||
@@ -31,14 +31,15 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
CCSPlayerController player = Utilities.GetPlayerFromIndex(playerIndex);
|
CCSPlayerController player = Utilities.GetPlayerFromIndex(playerIndex);
|
||||||
if (!Utility.IsPlayerValid(player)) return;
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
var steamId = new SteamID(player.SteamID);
|
if (player.AuthorizedSteamID == null) return;
|
||||||
|
string steamId = player.AuthorizedSteamID.SteamId64.ToString();
|
||||||
|
|
||||||
if (_config.GlobalShare)
|
if (_config.GlobalShare)
|
||||||
{
|
{
|
||||||
var values = new Dictionary<string, string>
|
var values = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
{ "server_id", _globalShareServerId.ToString() },
|
{ "server_id", _globalShareServerId.ToString() },
|
||||||
{ "steamid", steamId.SteamId64.ToString() },
|
{ "steamid", steamId },
|
||||||
{ "knife", "1" }
|
{ "knife", "1" }
|
||||||
};
|
};
|
||||||
UriBuilder builder = new UriBuilder(_globalShareApi);
|
UriBuilder builder = new UriBuilder(_globalShareApi);
|
||||||
@@ -75,7 +76,7 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
await connection.OpenAsync();
|
await connection.OpenAsync();
|
||||||
string query = "SELECT `knife` FROM `wp_player_knife` WHERE `steamid` = @steamid";
|
string query = "SELECT `knife` FROM `wp_player_knife` WHERE `steamid` = @steamid";
|
||||||
string? PlayerKnife = await connection.QueryFirstOrDefaultAsync<string>(query, new { steamid = steamId.SteamId64.ToString() });
|
string? PlayerKnife = await connection.QueryFirstOrDefaultAsync<string>(query, new { steamid = steamId });
|
||||||
if (PlayerKnife != null)
|
if (PlayerKnife != null)
|
||||||
{
|
{
|
||||||
WeaponPaints.g_playersKnife[playerIndex] = PlayerKnife;
|
WeaponPaints.g_playersKnife[playerIndex] = PlayerKnife;
|
||||||
@@ -102,12 +103,13 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
CCSPlayerController player = Utilities.GetPlayerFromIndex(playerIndex);
|
CCSPlayerController player = Utilities.GetPlayerFromIndex(playerIndex);
|
||||||
if (player == null || !player.IsValid) return;
|
if (player == null || !player.IsValid) return;
|
||||||
var steamId = new SteamID(player.SteamID);
|
if (player.AuthorizedSteamID == null) return;
|
||||||
|
string steamId = player.AuthorizedSteamID.SteamId64.ToString();
|
||||||
|
|
||||||
using var connection = new MySqlConnection(_databaseConnectionString);
|
using var connection = new MySqlConnection(_databaseConnectionString);
|
||||||
await connection.OpenAsync();
|
await connection.OpenAsync();
|
||||||
string query = "INSERT INTO `wp_player_knife` (`steamid`, `knife`) VALUES(@steamid, @newKnife) ON DUPLICATE KEY UPDATE `knife` = @newKnife";
|
string query = "INSERT INTO `wp_player_knife` (`steamid`, `knife`) VALUES(@steamid, @newKnife) ON DUPLICATE KEY UPDATE `knife` = @newKnife";
|
||||||
await connection.ExecuteAsync(query, new { steamid = steamId.SteamId64.ToString(), newKnife = knife });
|
await connection.ExecuteAsync(query, new { steamid = steamId, newKnife = knife });
|
||||||
await connection.CloseAsync();
|
await connection.CloseAsync();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -124,7 +126,9 @@ namespace WeaponPaints
|
|||||||
CCSPlayerController player = Utilities.GetPlayerFromIndex(playerIndex);
|
CCSPlayerController player = Utilities.GetPlayerFromIndex(playerIndex);
|
||||||
if (!Utility.IsPlayerValid(player)) return;
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
var steamId = new SteamID(player.SteamID);
|
if (player.AuthorizedSteamID == null) return;
|
||||||
|
|
||||||
|
string steamId = player.AuthorizedSteamID.SteamId64.ToString();
|
||||||
|
|
||||||
if (!WeaponPaints.gPlayerWeaponsInfo.TryGetValue(playerIndex, out _))
|
if (!WeaponPaints.gPlayerWeaponsInfo.TryGetValue(playerIndex, out _))
|
||||||
{
|
{
|
||||||
@@ -137,7 +141,7 @@ namespace WeaponPaints
|
|||||||
var values = new Dictionary<string, string>
|
var values = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
{ "server_id", _globalShareServerId.ToString() },
|
{ "server_id", _globalShareServerId.ToString() },
|
||||||
{ "steamid", steamId.SteamId64.ToString() },
|
{ "steamid", steamId },
|
||||||
{ "skins", "1" }
|
{ "skins", "1" }
|
||||||
};
|
};
|
||||||
UriBuilder builder = new UriBuilder(_globalShareApi);
|
UriBuilder builder = new UriBuilder(_globalShareApi);
|
||||||
@@ -193,7 +197,7 @@ namespace WeaponPaints
|
|||||||
await connection.OpenAsync();
|
await connection.OpenAsync();
|
||||||
|
|
||||||
string query = "SELECT * FROM `wp_player_skins` WHERE `steamid` = @steamid";
|
string query = "SELECT * FROM `wp_player_skins` WHERE `steamid` = @steamid";
|
||||||
IEnumerable<dynamic> PlayerSkins = await connection.QueryAsync<dynamic>(query, new { steamid = steamId.SteamId64.ToString() });
|
IEnumerable<dynamic> PlayerSkins = await connection.QueryAsync<dynamic>(query, new { steamid = steamId });
|
||||||
|
|
||||||
if (PlayerSkins != null && PlayerSkins.AsList().Count > 0)
|
if (PlayerSkins != null && PlayerSkins.AsList().Count > 0)
|
||||||
{
|
{
|
||||||
@@ -232,7 +236,8 @@ namespace WeaponPaints
|
|||||||
if (player == null || !Utility.IsPlayerValid(player)) return;
|
if (player == null || !Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
int playerIndex = (int)player.Index;
|
int playerIndex = (int)player.Index;
|
||||||
string steamId = new SteamID(player.SteamID).SteamId64.ToString();
|
if (player.AuthorizedSteamID == null) return;
|
||||||
|
string steamId = player.AuthorizedSteamID.SteamId64.ToString();
|
||||||
|
|
||||||
using var connection = new MySqlConnection(_databaseConnectionString);
|
using var connection = new MySqlConnection(_databaseConnectionString);
|
||||||
await connection.OpenAsync();
|
await connection.OpenAsync();
|
||||||
|
|||||||
Reference in New Issue
Block a user