mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-02-22 11:42:26 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e92635231 | ||
|
|
6923295cb6 | ||
|
|
e5f98077f3 | ||
|
|
3296055841 | ||
|
|
89de192c20 | ||
|
|
a1297b9cbe |
17
.github/workflows/build.yml
vendored
17
.github/workflows/build.yml
vendored
@@ -28,6 +28,21 @@ jobs:
|
|||||||
run: dotnet restore
|
run: dotnet restore
|
||||||
- name: Build
|
- name: Build
|
||||||
run: dotnet build ${{ env.PROJECT_PATH }} -c WeaponPaints -o ${{ env.OUTPUT_PATH }}
|
run: dotnet build ${{ env.PROJECT_PATH }} -c WeaponPaints -o ${{ env.OUTPUT_PATH }}
|
||||||
|
|
||||||
|
publish:
|
||||||
|
permissions: write-all
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Setup .NET
|
||||||
|
uses: actions/setup-dotnet@v3
|
||||||
|
with:
|
||||||
|
dotnet-version: 7.0.x
|
||||||
|
- name: Restore
|
||||||
|
run: dotnet restore
|
||||||
|
- name: Build
|
||||||
|
run: dotnet build ${{ env.PROJECT_PATH }} -c WeaponPaints -o ${{ env.OUTPUT_PATH }}
|
||||||
- name: Clean files
|
- name: Clean files
|
||||||
run: |
|
run: |
|
||||||
rm -f \
|
rm -f \
|
||||||
@@ -57,4 +72,4 @@ jobs:
|
|||||||
name: "Build ${{ env.BUILD_NUMBER }}"
|
name: "Build ${{ env.BUILD_NUMBER }}"
|
||||||
tag: "build-${{ env.BUILD_NUMBER }}"
|
tag: "build-${{ env.BUILD_NUMBER }}"
|
||||||
body: |
|
body: |
|
||||||
Place the plugin in game/csgo/addons/counterstrikesharp/plugins/WeaponPaints
|
Place the plugin in game/csgo/addons/counterstrikesharp/plugins/WeaponPaints
|
||||||
@@ -32,26 +32,16 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
private Dictionary<int, string> g_playersKnife = new();
|
private Dictionary<int, string> g_playersKnife = new();
|
||||||
private static readonly Dictionary<string, string> knifeTypes = new()
|
private static readonly Dictionary<string, string> knifeTypes = new()
|
||||||
{
|
{
|
||||||
{ "m9", "weapon_knife_m9_bayonet" },
|
{ "m9", "weapon_knife_m9_bayonet" }, { "karambit", "weapon_knife_karambit" },
|
||||||
{ "karambit", "weapon_knife_karambit" },
|
{ "bayonet", "weapon_bayonet" }, { "bowie", "weapon_knife_survival_bowie" },
|
||||||
{ "bayonet", "weapon_bayonet" },
|
{ "butterfly", "weapon_knife_butterfly" }, { "falchion", "weapon_knife_falchion" },
|
||||||
{ "bowie", "weapon_knife_survival_bowie" },
|
{ "flip", "weapon_knife_flip" }, { "gut", "weapon_knife_gut" },
|
||||||
{ "butterfly", "weapon_knife_butterfly" },
|
{ "tactical", "weapon_knife_tactical" }, { "shadow", "weapon_knife_push" },
|
||||||
{ "falchion", "weapon_knife_falchion" },
|
{ "navaja", "weapon_knife_gypsy_jackknife" }, { "stiletto", "weapon_knife_stiletto" },
|
||||||
{ "flip", "weapon_knife_flip" },
|
{ "talon", "weapon_knife_widowmaker" }, { "ursus", "weapon_knife_ursus" },
|
||||||
{ "gut", "weapon_knife_gut" },
|
{ "css", "weapon_knife_css" }, { "paracord", "weapon_knife_cord" },
|
||||||
{ "tactical", "weapon_knife_tactical" },
|
{ "survival", "weapon_knife_canis" }, { "nomad", "weapon_knife_outdoor" },
|
||||||
{ "shadow", "weapon_knife_push" },
|
{ "skeleton", "weapon_knife_skeleton" }, { "default", "weapon_knife" }
|
||||||
{ "navaja", "weapon_knife_gypsy_jackknife" },
|
|
||||||
{ "stiletto", "weapon_knife_stiletto" },
|
|
||||||
{ "talon", "weapon_knife_widowmaker" },
|
|
||||||
{ "ursus", "weapon_knife_ursus" },
|
|
||||||
{ "css", "weapon_knife_css" },
|
|
||||||
{ "paracord", "weapon_knife_cord" },
|
|
||||||
{ "survival", "weapon_knife_canis" },
|
|
||||||
{ "nomad", "weapon_knife_outdoor" },
|
|
||||||
{ "skeleton", "weapon_knife_skeleton" },
|
|
||||||
{ "default", "weapon_knife" }
|
|
||||||
};
|
};
|
||||||
private static readonly List<string> weaponList = new()
|
private static readonly List<string> weaponList = new()
|
||||||
{
|
{
|
||||||
@@ -67,7 +57,6 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
};
|
};
|
||||||
public override void Load(bool hotReload)
|
public override void Load(bool hotReload)
|
||||||
{
|
{
|
||||||
base.Load(hotReload);
|
|
||||||
BuildDatabaseConnectionString();
|
BuildDatabaseConnectionString();
|
||||||
TestDatabaseConnection();
|
TestDatabaseConnection();
|
||||||
SetGlobalExceptionHandler();
|
SetGlobalExceptionHandler();
|
||||||
@@ -77,11 +66,23 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
RegisterListener<Listeners.OnClientDisconnect>(OnClientDisconnect);
|
RegisterListener<Listeners.OnClientDisconnect>(OnClientDisconnect);
|
||||||
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
||||||
RegisterEventHandler<EventPlayerSpawn>(OnPlayerSpawn);
|
RegisterEventHandler<EventPlayerSpawn>(OnPlayerSpawn);
|
||||||
//RegisterEventHandler<EventRoundPrestart>(OnRoundPreStart);
|
|
||||||
if (Config.Additional.KnifeEnabled)
|
if (Config.Additional.KnifeEnabled)
|
||||||
SetupMenus();
|
SetupMenus();
|
||||||
|
|
||||||
RegisterCommands();
|
RegisterCommands();
|
||||||
|
if (hotReload)
|
||||||
|
{
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
for (int i = 1; i <= Server.MaxPlayers; i++)
|
||||||
|
{
|
||||||
|
if (Config.Additional.KnifeEnabled)
|
||||||
|
await GetKnifeFromDatabase(i);
|
||||||
|
if (Config.Additional.SkinEnabled)
|
||||||
|
await GetWeaponPaintsFromDatabase(i);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void OnConfigParsed(WeaponPaintsConfig config)
|
public void OnConfigParsed(WeaponPaintsConfig config)
|
||||||
{
|
{
|
||||||
@@ -127,29 +128,29 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
CheckDatabaseTables();
|
CheckDatabaseTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckDatabaseTables()
|
async private void CheckDatabaseTables()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new MySqlConnection(DatabaseConnectionString);
|
using var connection = new MySqlConnection(DatabaseConnectionString);
|
||||||
connection.OpenAsync();
|
await connection.OpenAsync();
|
||||||
|
|
||||||
using var transaction = connection.BeginTransaction();
|
using var transaction = await connection.BeginTransactionAsync();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string createTable1 = "CREATE TABLE IF NOT EXISTS `wp_player_skins` (`steamid` varchar(64) NOT NULL, `weapon_defindex` int(6) NOT NULL, `weapon_paint_id` int(6) NOT NULL, `weapon_wear` float NOT NULL DEFAULT 0.0001, `weapon_seed` int(16) NOT NULL DEFAULT 0) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;";
|
string createTable1 = "CREATE TABLE IF NOT EXISTS `wp_player_skins` (`steamid` varchar(64) NOT NULL, `weapon_defindex` int(6) NOT NULL, `weapon_paint_id` int(6) NOT NULL, `weapon_wear` float NOT NULL DEFAULT 0.0001, `weapon_seed` int(16) NOT NULL DEFAULT 0) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci";
|
||||||
string createTable2 = "CREATE TABLE IF NOT EXISTS `wp_player_knife` (`steamid` varchar(64) NOT NULL, `knife` varchar(64) NOT NULL, UNIQUE (`steamid`)) ENGINE = InnoDB;";
|
string createTable2 = "CREATE TABLE IF NOT EXISTS `wp_player_knife` (`steamid` varchar(64) NOT NULL, `knife` varchar(64) NOT NULL, UNIQUE (`steamid`)) ENGINE = InnoDB";
|
||||||
|
|
||||||
connection.ExecuteAsync(createTable1);
|
await connection.ExecuteAsync(createTable1, transaction: transaction);
|
||||||
connection.ExecuteAsync(createTable2);
|
await connection.ExecuteAsync(createTable2, transaction: transaction);
|
||||||
|
|
||||||
transaction.Commit();
|
await transaction.CommitAsync();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
transaction.RollbackAsync();
|
await transaction.RollbackAsync();
|
||||||
throw new Exception("Unable to create tables!");
|
throw new Exception("Unable to create tables!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -220,12 +221,12 @@ public override void Unload(bool hotReload)
|
|||||||
private void OnClientDisconnect(int playerSlot)
|
private void OnClientDisconnect(int playerSlot)
|
||||||
{
|
{
|
||||||
CCSPlayerController player = Utilities.GetPlayerFromSlot(playerSlot);
|
CCSPlayerController player = Utilities.GetPlayerFromSlot(playerSlot);
|
||||||
// TODO: Clean up after player
|
if (!player.IsValid || player.IsBot) return;
|
||||||
if (Config.Additional.KnifeEnabled)
|
|
||||||
g_playersKnife.Remove(playerSlot+1);
|
if (Config.Additional.KnifeEnabled)
|
||||||
if (Config.Additional.SkinEnabled)
|
g_playersKnife.Remove(playerSlot+1);
|
||||||
gPlayerWeaponPaints.Remove(new SteamID(player.SteamID).SteamId64);
|
if (Config.Additional.SkinEnabled)
|
||||||
|
gPlayerWeaponPaints.Remove(new SteamID(player.SteamID).SteamId64);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
|
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
|
||||||
|
|||||||
Reference in New Issue
Block a user