legacy-idcard
Integration
Exports and events for integrating legacy-idcard with other resources.
Integration
legacy-idcard exposes server-side exports for issuing, revoking, and querying cards, plus a set of internal lib.callbacks and net events used by its own UI. Below are the pieces you're expected to call from other resources.
Server exports
IssueCard(src, cardTypeName, serial)
Issues a card of cardTypeName to player src. Invalidates any existing valid card of that type first, generates a serial if none is given, inserts the DB row, gives the physical inventory item, notifies the player, and fires the CardIssued webhook. Returns the serial number string, or nil on failure.
-- any server-side file
local serial = exports['legacy-idcard']:IssueCard(source, 'id_card')
if serial then
print(('Issued card with serial %s'):format(serial))
end
RevokeCard(serialNumber)
Revokes a card by serial number: removes the DB row, syncs 'revoked' status to cityhall (if installed), and — if the owner is online — removes the physical item and clears any associated licence metadata. Fires the CardRevoked webhook. Returns true/false.
local ok = exports['legacy-idcard']:RevokeCard('LS-2024-00042')
HasCard(src, cardTypeName)
Returns true if the player has at least one card row (of any status) for cardTypeName.
if exports['legacy-idcard']:HasCard(source, 'weaponlicense') then
-- allow weapon purchase
end
GetPlayerCards(src)
Returns an array of all of the player's cards, joined with card type label/icon, ordered newest-first.
local cards = exports['legacy-idcard']:GetPlayerCards(source)
for _, card in ipairs(cards) do
print(card.card_type, card.serial_number, card.label)
end
useCard(event, item, inventory, slot)
The ox_inventory item-use export callback. You don't call this directly — bind it via your item definition's server.export field (see Installation). It's what triggers the internal legacy-idcard:itemUsed flow and ultimately legacy-idcard:showCard.
Server-side lib.callbacks (mostly internal / police NUI)
These are registered with lib.callback and are primarily used by legacy-idcard's own client code, but can be invoked from another resource's client via lib.callback.await if you build your own UI on top:
legacy-idcard:lookupSerial(source, serial)— looks up a card by serial, returns display data ornil.legacy-idcard:reportCard(source, serial, newStatus)— sets a card's status to'stolen','lost', or'valid'.legacy-idcard:revokeBySerial(source, serial)— wrapsRevokeCardfor NUI use.
-- client/some_police_script.lua
local card = lib.callback.await('legacy-idcard:lookupSerial', false, 'LS-2024-00042')
if card then
-- card.serialNumber, card.status, card.playerName, etc.
end
Net events
legacy-idcard:showCard(cardData) (server → client)
Fired by legacy-idcard internally to display a card. You generally won't fire this yourself — it's the output of the item-use flow — but you can listen for it if you want to react to a card being shown:
-- client/client.lua (or your own client script)
RegisterNetEvent('legacy-idcard:showCard', function(cardData)
-- cardData.serialNumber, cardData.cardType, cardData.status, cardData.mugshot, ...
end)
legacy-idcard:playAnimation() (server → client)
Plays the show-ID animation on the triggering player. Internal to the item-use flow.
Client-internal callbacks (registered by legacy-idcard, awaited by its own server code)
These are registered client-side and consumed by legacy-idcard's server code — you don't normally need to touch them, but they explain what data feeds card display:
legacy-idcard:getClosestPlayer()— returns the server ID of the closest player withinConfig.ShowDistance.legacy-idcard:captureMugshot()— returns a base64 mugshot viaMugShotBase64, ornilif that resource isn't running.legacy-idcard:getCharacterInfo()— returns{ dob, sex, nationality, citizenId }from the active framework (qb-core/qbx_core or es_extended), or{}if unsupported.
Command
/idadmin
Opens the admin panel NUI, gated server-side by Config.AdminGroups (checked via legacy-idcard:getAdminData). No client-side permission check exists — all authorization is server-side.