mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-03-12 17:16:29 +00:00
change mysql
This commit is contained in:
@@ -1,18 +1,23 @@
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using MySqlConnector;
|
||||
using Nexd.MySQL;
|
||||
|
||||
namespace WeaponPaints;
|
||||
public class WeaponPaints : BasePlugin
|
||||
{
|
||||
public override string ModuleName => "WeaponPaints";
|
||||
|
||||
public override string ModuleVersion => "0.0.1";
|
||||
public override string ModuleDescription => "Connector for web-based player chosen wepaon paints.";
|
||||
public override string ModuleAuthor => "Nereziel";
|
||||
public override string ModuleVersion => "0.2";
|
||||
MySqlDb? MySql = null;
|
||||
|
||||
public override void Load(bool hotReload)
|
||||
{
|
||||
new Cfg().CheckConfig(ModuleDirectory);
|
||||
MySql = new MySqlDb(Cfg.config.DatabaseHost!, Cfg.config.DatabaseUser!, Cfg.config.DatabasePassword!, Cfg.config.DatabaseName!, (int)Cfg.config.DatabasePort);
|
||||
RegisterListener<Listeners.OnEntitySpawned>(OnEntitySpawned);
|
||||
|
||||
}
|
||||
|
||||
private void OnEntitySpawned(CEntityInstance entity)
|
||||
{
|
||||
var designerName = entity.DesignerName;
|
||||
@@ -27,7 +32,7 @@ public class WeaponPaints : BasePlugin
|
||||
//Log($"AccountID {weapon.AttributeManager.Item.AccountID}");
|
||||
//Log($"playerSteam {playerId}");
|
||||
var playerId = ConvertToSteam64(weapon.AttributeManager.Item.AccountID);
|
||||
int weaponPaint = Queries.GetPlayersWeaponPaint(playerId.ToString(), weapon.AttributeManager.Item.ItemDefinitionIndex);
|
||||
int weaponPaint = GetPlayersWeaponPaint(playerId.ToString(), weapon.AttributeManager.Item.ItemDefinitionIndex);
|
||||
if (playerId == 0) return;
|
||||
if (weaponPaint == 0) return;
|
||||
weapon.AttributeManager.Item.AccountID = unchecked((uint)271098320);
|
||||
@@ -50,4 +55,21 @@ public class WeaponPaints : BasePlugin
|
||||
Console.WriteLine(message);
|
||||
Console.ResetColor();
|
||||
}
|
||||
public int GetPlayersWeaponPaint(string steamId, int weaponDefIndex)
|
||||
{
|
||||
try
|
||||
{
|
||||
MySqlQueryCondition conditions = new MySqlQueryCondition()
|
||||
.Add("steamid", "=", steamId)
|
||||
.Add("weapon_defindex", "=", weaponDefIndex);
|
||||
|
||||
MySqlQueryResult result = MySql!.Table("wp_player_skins").Where(conditions).Select();
|
||||
int weaponPaint = result.Get<int>(0, "weapon_paint_id");
|
||||
return weaponPaint;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user