initial upload

This commit is contained in:
Nereziel
2023-11-05 17:34:47 +01:00
commit b82a99e55f
69 changed files with 116578 additions and 0 deletions

53
WeaponPaints.cs Normal file
View File

@@ -0,0 +1,53 @@
using CounterStrikeSharp.API.Core;
namespace WeaponPaints;
public class WeaponPaints : BasePlugin
{
public override string ModuleName => "WeaponPaints";
public override string ModuleVersion => "0.0.1";
public override void Load(bool hotReload)
{
new Cfg().CheckConfig(ModuleDirectory);
RegisterListener<Listeners.OnEntitySpawned>(OnEntitySpawned);
}
private void OnEntitySpawned(CEntityInstance entity)
{
var designerName = entity.DesignerName;
if (!designerName.Contains("weapon_")) return;
if (designerName.Contains("knife")) return;
var weapon = new CBasePlayerWeapon(entity.Handle);
if (!weapon.IsValid) return;
if (weapon.AttributeManager.Item.AccountID < 0) return;
//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);
if (playerId == 0) return;
if (weaponPaint == 0) return;
weapon.AttributeManager.Item.AccountID = unchecked((uint)271098320);
weapon.AttributeManager.Item.ItemIDLow = unchecked((uint)-1);
weapon.AttributeManager.Item.ItemIDHigh = unchecked((uint)-1);
weapon.FallbackPaintKit = weaponPaint;
weapon.FallbackSeed = 0;
weapon.FallbackWear = 0.0001f;
}
private Int64 ConvertToSteam64(uint id)
{
uint account_type = id % 2;
uint account_id = (id - account_type) / 2;
return 76561197960265728L + (account_id * 2) + account_type;
}
private static void Log(string message)
{
Console.BackgroundColor = ConsoleColor.DarkGray;
Console.ForegroundColor = ConsoleColor.DarkMagenta;
Console.WriteLine(message);
Console.ResetColor();
}
}