API and integration
Commands, permissions, events and an integration example.
The resource declares no exports. Integration with other resources works through commands and the notification event.
Commands
Names can be changed in Config.Commands. The id is the passport on vRP (TargetId = 'passport') and the server id elsewhere.
| Command | Who | What it does |
|---|---|---|
/armario | Player | Opens the wardrobe. Does not open inside a vehicle or while dead. |
/skinmenu | Player | Opens the skin menu. |
/aceitarroupa | Player | Accepts a shared outfit invitation. |
/recusarroupa | Player | Declines a shared outfit invitation. |
/addskinplayer <id> <model> | Admin or console | Unlocks the skin for the player. The model must be in Config.Skins. |
/resetarmario <id> | Admin or console | Deletes the player's saved outfits. Purchased slots, skins and earnings are untouched. |
/armariosaldo <id> <amount> | Admin or console | Sets the internal wallet balance. Standalone mode only. |
Permissions
| Permission | What for |
|---|---|
rvt_clothes.admin | Admin commands (Config.AdminAce). The server console can always use them. |
rvt_clothes.premium | Extra slots defined in Config.PremiumSlots. Create as many permissions as you need. |
Besides ACE, QBCore and ESX accept groups listed per permission in Config.FrameworkPermissions (for example ['rvt_clothes.admin'] = { 'admin' } inside qb or esx), and vRP uses Config.Creative.Permissions. These lists ship empty: no admin access is granted by group name. QBox uses ACE. Never grant the admin permission to builtin.everyone.
Events
| Event | Side | Use |
|---|---|---|
rvt_clothes:notify | Server to client | Shows a notification: (message, kind), where kind is success, error or inform. Other resources may trigger it. |
rvt_clothes:request / response | Internal | Interface to server communication. Do not use. |
rvt_clothes:shareOffer / shareReply | Internal | Shared outfit invitation. Do not use. |
rvt_clothes:creativeSession | Internal | Active vRP character. Do not use. |
The resource does not emit events to other resources, such as outfit saved or purchase completed. To know when the character has loaded, it listens to the events in Config.ClientEvents and, on vRP, Config.Creative.LoadedEvent and UnloadedEvent.
Example
-- server: unlock a skin for a player (ExecuteCommand on the server runs as console)
ExecuteCommand(('addskinplayer %d %s'):format(12, 'my_custom_ped'))
-- server: show a notification through the wardrobe notifier
-- kind: 'success' | 'error' | 'inform'
TriggerClientEvent('rvt_clothes:notify', source, 'Outfit saved', 'success')
-- client: open the wardrobe from another resource
ExecuteCommand('armario')Read the saved data
For reports, read the state in read-only mode. Never write to the file.
-- server: read-only inspection of the saved data from another resource.
-- Never write this file: the wardrobe keeps its own copy in memory and would overwrite it.
local raw = LoadResourceFile('rvt_clothes', 'data/state.json')
local state = raw and json.decode(raw)
if state then
local count = 0
for _ in pairs(state.listings) do count = count + 1 end
print(('Market listings stored: %d'):format(count))
endInternal methods (interface protocol)
Reference for anyone changing the interface. They are called through the rvt_clothes:request event and answered on rvt_clothes:response with ok = true, or ok = false and error.
- Wardrobe: getInfos, addOutfit, editOutfit, deleteOutfit, selectOutfit, getSavedAppearance, getSession, buySlot, shareOutfit.
- Skins: getSkinsInfos, selectSkin.
- Marketplace: marketList, marketCreate, marketEdit, marketUpdateClothes, marketDelete, marketBuy, marketMine, marketPurchases, marketRestore, claimProceeds, marketPhotoConfig.
