Nereziel / cs2-WeaponPaints

GNU General Public License v3.0
174 stars 43 forks source link

[REQ] Stickers and their customization #238

Open TropieRi opened 2 months ago

TropieRi commented 2 months ago

By using the already defined function "CAttributeList_SetOrAddAttributeValueByName" we can put stickers on the weapons and customize their wear, rotation, and position. Below is the code for doing mentioned stuff, do whatever you please with the info:

public float ViewAsFloat(uint value)
{
    byte[] bytes = BitConverter.GetBytes(value);
    return BitConverter.ToSingle(bytes, 0);
}

CAttributeList_SetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, $"sticker slot {x} id", ViewAsFloat((uint)60));

CAttributeList_SetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, $"sticker slot {x} rotation", 180f);

CAttributeList_SetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, $"sticker slot {x} offset x", 0.08f);

CAttributeList_SetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, $"sticker slot {x} offset y", 0.04f);

CAttributeList_SetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, $"sticker slot {x} wear", 0.0001f);

The position is calculated from the sticker slot x + or - the offset

Which results to do this: 20240413104014_1

Kaysharp42 commented 3 days ago

I tried your solution and it works fine except when I try to change the stickers. They stay the same until I restart the server or rejoin the server.