Commands#
Trading Cards registers a single command. Everything players do goes through items and NPCs, and everything admins do goes through the window it opens.
Command | Where | Description |
|---|---|---|
| In game | Opens and closes the creator: Peds, Card Creator, Rarities and Customize theme. Only for players with the |
Config.CardCreator = {
command = 'cardcreator', -- the chat command
permission = 'command.cardcreator', -- the ace that grants it
adminGroups = { 'admin', 'superadmin', 'god' },
}Every creator action is checked again on the server, so a player who forces the window open without permission cannot save, delete or give anything.
Client Exports#
For opening the script's windows from your own resources — a radial menu, a phone app, a laptop prop.
OpenBoosterPack
Plays the pack opening for a booster the player holds. The server takes one pack from the inventory and hands out the cards, exactly as using the item does — a player who does not hold that pack gets an error and nothing else.
exports['qs-tradingcards']:OpenBoosterPack({ name = 'tradingcard_booster_pack' })OpenInterationMenu
Opens the Card Interaction panel (view, show, store in album) for a card item. Pass the inventory entry of the card, with its metadata in info or metadata.
local item = exports.ox_inventory:GetSlot(slot) -- or your inventory's equivalent
exports['qs-tradingcards']:OpenInterationMenu(item)OpenCreator
Opens the creator for a player who has access — the same as typing /cardcreator. Calling it again closes it.
exports['qs-tradingcards']:OpenCreator()Server Exports#
useItem (standalone)
With no framework, this runs the action registered for any of the script's items, after checking the player holds it. It is what an ox_inventory item points at, and can be called directly:
-- ox_inventory/data/items.lua
server = { export = 'qs-tradingcards.useItem' },
-- from another resource
exports['qs-tradingcards']:useItem(source, 'tradingcard_stash', slot)OpenInterationMenu and openAlbum (ox_inventory)
Handlers in the shape ox_inventory expects for an item's server.export, for servers that prefer to route the card and album items that way:
['tradingcard_basic'] = {
label = 'Basic Card',
stack = false,
server = { export = 'qs-tradingcards.OpenInterationMenu' },
},
['tradingcard_stash'] = {
label = 'Card Album',
stack = false,
server = { export = 'qs-tradingcards.openAlbum' },
},With ESX or QBCore the items are already usable through the framework, so the plain definitions from Installation are enough.
Events#
Server-to-client events the script listens to. Trigger them from your own server code to open a window for a player:
-- Open the card menu for a card item the player holds
TriggerClientEvent('tradingcards:client:openCardInteractionMenu', source, item)
-- Open an album, given the album item's metadata
TriggerClientEvent('tradingcards:client:OpenAlbum', source, item.metadata)
-- Open a booster pack (the server still checks the player holds it)
TriggerClientEvent('tradingcards:client:OpenBoosterPack', source, { name = 'tradingcard_booster_legends' })Giving Cards and Packs from Your Scripts#
Booster packs and albums are plain items: give them with your inventory's own AddItem, from a reward, a loot table, a job or a case opening.
A card is its rarity's item with the card's data as metadata. To hand out one particular card, read it from qs_tradingcards_cards and pass these fields:
local card = MySQL.single.await('SELECT * FROM qs_tradingcards_cards WHERE id = ?', { 5 })
exports.ox_inventory:AddItem(source, 'tradingcard_legendary', 1, {
cardId = card.id,
label = card.label,
rarity = card.rarity,
cardImage = card.image, -- the artwork; keep it out of `image`, which inventories use as the icon
term = card.term,
description = card.description,
health = card.health,
attack = card.attack,
height = card.height,
weight = card.weight,
quality = card.quality,
booster = card.booster,
theme = card.theme,
graded = false,
})Use the item that belongs to the card's rarity (the Inventory item on its rarity in the creator). An admin can also hand any card to any online player from the creator's Give button, with no code at all.



