In the context of RDR3 discoveries, Composites are scenarios used to handle herb pickup. They allow you to spawn a herb entity and an associated scenario at specific coordinates.
Workflow for using Composites:
- Identify the Composite Name: Use a string identifier like
"COMPOSITE_LOOTABLE_EVERGREEN_HUCKLEBERRY_DEF" and convert it to a hash using GetHashKey(). - Request the Composite: Use the native
0x73F0D0327BFA0812 to request the specific composite hash. - Wait for Loading: Poll the native
0x5E5D96BE25E9DF68 to ensure the composite has successfully loaded before attempting to spawn it. - Create the Composite: Once loaded, use the native
0x5B4BBE80AD5972DC to spawn the herb entity and scenario at the desired coordinates. This returns a composite_scenario_id.
Important Performance Note:
Creating too many composites can crash the game. To prevent this, you must manually delete unnecessary scenarios when they are no longer needed (e.g., when the player moves a certain distance away) using the native 0x5758B1EE0C3FD4AC.
-- Example of creating a composite
local composite_name = "COMPOSITE_LOOTABLE_EVERGREEN_HUCKLEBERRY_DEF"
local composite_name_hash = GetHashKey(composite_name)
-- Request COMPOSITE
Citizen.InvokeNative(0x73F0D0327BFA0812, composite_name_hash)
-- Wait for load (polling native 0x5E5D96BE25E9DF68)
-- ... (wait logic) ...
-- Create COMPOSITE
composite_scenario_id = Citizen.InvokeNative(0x5B4BBE80AD5972DC, composite_name_hash, x, y, z, 0.0, 0, Citizen.PointerValueInt(), -1, Citizen.ReturnResultAnyway())
-- Delete COMPOSITE scenario when done
Citizen.InvokeNative(0x5758B1EE0C3FD4AC, composite_scenario_id, 0)