mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-06-09 23:57:32 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5f98077f3 | ||
|
|
3296055841 | ||
|
|
89de192c20 | ||
|
|
a1297b9cbe |
17
.github/workflows/build.yml
vendored
17
.github/workflows/build.yml
vendored
@@ -18,6 +18,21 @@ jobs:
|
|||||||
permissions: write-all
|
permissions: write-all
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
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 }}
|
||||||
|
|
||||||
|
publish:
|
||||||
|
permissions: write-all
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Setup .NET
|
- name: Setup .NET
|
||||||
@@ -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
|
||||||
@@ -127,29 +127,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 +220,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