Getting Started (for Developers) - nosoop/SM-TFCustomWeaponsX GitHub Wiki

Since developers' needs vary, there isn't really any one-guide-fits-all for them.

Natives

Entity

  • CWX_GetItemUIDFromEntity returns the custom item UID attached to an weapon / wearable, if one exists. (It does not check the UID for validity.)
  • CWX_EquipPlayerItem immediately spawns and equips the given item UID.
    • ⚠️ This functionality is not intended for production use. Use CWX_SetPlayerLoadoutItem and regenerate the player instead.

Inventory

  • CWX_GetPlayerLoadoutItem returns the UID located in the given player's inventory for the specified class / loadout slot.
  • CWX_SetPlayerLoadoutItem adds the item with the given UID to the player's inventory.
    • If LOADOUT_FLAG_UPDATE_BACKEND is not present, the loadout item is applied temporarily — it will not replace any item the player has selected themselves.
  • CWX_RemovePlayerLoadoutItem clears out any existing UID on a player's inventory, restoring it to default.
  • CWX_CanPlayerAccessItem returns whether or not the given client is allowed to access the specified item UID. This only checks for access restrictions based on the access item key.

Schema

  • CWX_GetItemList returns an ArrayList containing all valid item UIDs.
  • CWX_IsItemUIDValid checks if the given item UID is valid.
  • CWX_GetItemLoadoutSlot returns the loadout slot that the custom item definition is assigned to for a given class.
  • CWX_GetItemExtData returns the extended data subsection for a custom item definition by name, if one exists. (You do not have to check the UID for validity.)

Item information: CWX module vs attribute

If it needs to be tied to a custom item definition and can't be used outside of CWX, it should be a module. Examples include:

  • Item descriptions
  • Defining resources to precache / mark for download

Otherwise, writing something as an attribute provides far greater flexibility.