You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/lootbox/configuration.mdx
+185Lines changed: 185 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -121,6 +121,11 @@ Each item in the `items` array follows this format:
121
121
|`amount`|`number`| Yes | Quantity of item to give |
122
122
|`metadata`|`table`| No | Custom metadata to attach to item |
123
123
|`rarity`|`string`| No | Override auto-calculated rarity |
124
+
|`label`|`string`| No | Custom display label (auto-fetched from inventory if not provided) |
125
+
|`image`|`string`| No | Custom image URL (auto-fetched from inventory if not provided) |
126
+
|`bonusItems`|`table`| No | Additional items to award alongside the main reward (not shown in UI) |
127
+
|`rewardType`|`string`| No | Custom reward type for non-item rewards (e.g., `'vehicle'`, `'bank'`) |
128
+
|`rewardData`|`table`| No | Custom data passed to reward hooks (e.g., vehicle model, garage) |
124
129
125
130
### Complete Example
126
131
@@ -197,6 +202,186 @@ Include custom metadata that will be attached to the item when given:
197
202
When using metadata, ensure your inventory system supports the metadata fields you're using.
198
203
</Callout>
199
204
205
+
### Bonus Items
206
+
207
+
Award additional items alongside the main reward. Bonus items are **not displayed in the UI** - players only see the main item during the roll animation, but receive all bonus items when the reward is claimed.
208
+
209
+
```lua
210
+
{ 40, {
211
+
name='WEAPON_PISTOL',
212
+
amount=1,
213
+
bonusItems= {
214
+
{ name='ammo-9', amount=50 },
215
+
{ name='armour', amount=1 },
216
+
}
217
+
} }
218
+
```
219
+
220
+
Each bonus item has the following properties:
221
+
222
+
| Property | Type | Required | Description |
223
+
|----------|------|----------|-------------|
224
+
|`name`|`string`| Yes | Item spawn name |
225
+
|`amount`|`number`| Yes | Quantity to give |
226
+
|`metadata`|`table`| No | Optional item metadata |
227
+
228
+
<Callouttype="info">
229
+
Bonus items are great for giving ammo with weapons, or adding extra consumables as a surprise bonus without cluttering the UI.
230
+
</Callout>
231
+
232
+
### Custom Reward Types
233
+
234
+
For rewards that aren't standard inventory items (vehicles, bank deposits, etc.), use the `rewardType` and `rewardData` fields along with the reward hook system.
235
+
236
+
<Callouttype="info">
237
+
For custom reward types, the `name` field is just a **unique identifier** used for internal tracking and logging - it doesn't need to be an actual item in your inventory. Since custom rewards aren't real items, you must also provide `label` and `image` explicitly.
238
+
</Callout>
239
+
240
+
```lua
241
+
{ 0.26, {
242
+
name='vehicle_adder', -- Unique identifier, not an actual item
Custom reward types require a registered reward hook to handle them. If no hook is registered, the system will fall back to default item behavior and log a warning.
254
+
</Callout>
255
+
256
+
#### How Custom Rewards Work
257
+
258
+
1. When a player wins an item with a custom `rewardType`, the system looks for a registered hook for that type
259
+
2. If a hook exists and returns `true`, the hook handled the reward
260
+
3. If a hook returns `false`/`nil`, the system falls back to default item behavior
261
+
4. If no hook exists, a warning is logged and the system falls back to default item behavior
262
+
263
+
This ensures rewards are never silently lost - if something isn't configured correctly, players still receive items.
264
+
265
+
#### Registering Reward Hooks
266
+
267
+
Register hooks from your own resource to handle custom reward types:
268
+
269
+
```lua
270
+
-- In your server script (e.g., a vehicle management resource)
Award additional items alongside the main reward without showing them in the UI. Useful for giving ammo with weapons.
113
+
114
+
```lua
115
+
-- In config.lua
116
+
config.lootboxes= {
117
+
['gun_case'] = {
118
+
label='Gun Case',
119
+
description='Contains various firearms with ammo',
120
+
items= {
121
+
{ 40, {
122
+
name='WEAPON_PISTOL',
123
+
amount=1,
124
+
-- Bonus items are awarded but NOT shown in the UI
125
+
bonusItems= {
126
+
{ name='ammo-9', amount=50 },
127
+
}
128
+
} },
129
+
{ 0.1, {
130
+
name='WEAPON_CARBINERIFLE',
131
+
amount=1,
132
+
bonusItems= {
133
+
{ name='ammo-rifle', amount=250 },
134
+
{ name='armour', amount=2 },
135
+
{ name='money', amount=5000 },
136
+
}
137
+
} },
138
+
},
139
+
},
140
+
}
141
+
```
142
+
143
+
<Callouttype="info">
144
+
Bonus items are given server-side when the reward is claimed. Players will see them appear in their inventory but won't see them during the roll animation.
145
+
</Callout>
146
+
147
+
## Custom Reward Types with Hooks
148
+
149
+
Use custom reward types to handle non-item rewards like vehicles or bank deposits. Register hooks in your own resource to handle these reward types.
name='bank_deposit_10k', -- Unique identifier (used for logging, not an actual item)
230
+
label='$10,000 Bank Deposit', -- Required: display label since this isn't a real item
231
+
amount=1,
232
+
image='nui://ox_inventory/web/images/money.webp',
233
+
rewardType='bank',
234
+
rewardData= { amount=10000 },
235
+
} },
236
+
{ 1, {
237
+
name='bank_deposit_100k', -- Unique identifier
238
+
label='$100,000 Bank Deposit', -- Display label
239
+
amount=1,
240
+
image='nui://ox_inventory/web/images/money.webp',
241
+
rarity='legendary',
242
+
rewardType='bank',
243
+
rewardData= { amount=100000 },
244
+
} },
245
+
},
246
+
},
247
+
}
248
+
```
249
+
250
+
<Callouttype="warning">
251
+
If a custom `rewardType` is set but no hook is registered, the system will log a warning and fall back to treating it as a regular item. This prevents rewards from being lost but may not give the intended reward.
252
+
</Callout>
253
+
254
+
### Removing a Hook
255
+
256
+
You can remove a previously registered hook if needed:
0 commit comments