Real Wallet / Guides

Using your own ID and bank scripts

This guide is for server owners whose ID cards, licences or bank cards come from another script (an ID card script, a DMV / city hall script, a bank or ATM script). Follow the steps in order. Steps 1 to 3 are all most servers need.

Everything you edit here is open (not escrowed): config.lua, server/hooks.lua, bridge/ and install/.


How the wallet works with your cards

  • A card is an ox_inventory item. Any item you list in Config.Cards can go in a wallet. Your ID script keeps giving out its items exactly as before. Nothing in it has to change for cards to work in the wallet.
  • What a card shows (name, birth date, number, dates, photo) is read from the item's own metadata, the data your ID script stored on it.
  • The one thing to know: a card that is IN a wallet is in the wallet's own storage, not in the player's inventory. A script that looks for the item in the player's inventory does not find it while it is in a wallet. Step 6 covers it.

Step 1: Check your cards are inventory items

Open your inventory in game. Your ID card, licences and bank cards should be items in it. Note each one's item name (not its label), for example id_card, driver_license, weaponlicense, visa, mastercard.

  • The item names are in ox_inventory/data/items.lua (the key of each entry), or in your ID script's config.

If your cards are not items (a script that keeps documents only in its own menu or database), the wallet can not hold them.


Step 2: List them in Config.Cards

In config.lua, add one line per card item. Only label is needed.

Lua
Config.Cards = {
    id_card        = { label = 'ID card',        design = 'id' },
    driver_license = { label = 'Driver license', design = 'license' },
    weaponlicense  = { label = 'Weapon license', design = 'weapon' },
    visa           = { label = 'Visa card',      design = 'credit', bank = 'Fleeca', kind = 'Debit' },
    gym_pass       = { label = 'Gym pass' },       -- any other card: the neutral placeholder design
}
Option What it does
label The card's name on the wallet's tag and in messages.
design The built-in look: 'id', 'license', 'weapon', 'credit' (a bank card), 'plain' (the placeholder, the default).
bank, kind, brand, colors For design = 'credit': the bank name, the word top right ('Debit' / 'Credit'), the word bottom right, the colours { from, to, text }.
title The words across the top of an id / license / weapon / plain card.
art, photo, text Your own card image (Step 4).
show = false It can not be held out to someone.
hand = false It can not be handed over.
enabled = false Not a card any more (it stays a normal item).

Restart ryan-wallet after changing the config.


Step 3: Make the card's details read right

The wallet looks for each detail in the item's metadata under every name listed in Config.CardFields, in order, and uses the first one it finds. Many common names are already listed:

Detail Names it already looks for
owner (whose card it is) citizenid, identifier, owner, cid, charid, charId, citizenId, id
first name firstname, firstName, first_name, fname, forename, PlayerName
last name lastname, lastName, last_name, lname, surname, PlayerSurname
full name (split when there is no first / last) fullname, fullName, full_name, firstAndLastName, name, holder
birth date birthdate, dob, dateofbirth, dateOfBirth, date_of_birth, birthDate, birthday, PlayerDob
sex sex, gender, PlayerSex
card number number, cardNumber, cardnumber, card_number, cardId, license_id, licenseId, licenseNumber, document_id, IdCard, serial, cref
issued / expires issued, issueDate, issued_at ... / expires, expiry, expiration, expirationDate ...
licence class class, licenseClass, license_class
photo mugShot, mugshot, photo, photoUrl, photo_url, imageURL, imageUrl, Screen, picture, headshot

How to check yours:

  1. Open your ID script's server code where it gives the card (search for AddItem(): the table after the item name is the metadata, for example AddItem(source, 'id_card', 1, { firstname = ..., lastname = ..., birthdate = ... }). Its config or documentation often lists the fields too. (The inventory tooltip does not show every field.)
  2. For every detail whose name is NOT in the table above, add the name to that list in config.lua:
Lua
Config.CardFields = {
    -- ...
    firstname = { 'firstname', 'firstName', 'first_name', 'fname', 'forename', 'PlayerName', 'nombre' },   -- 'nombre' added
    photo     = { 'mugShot', 'mugshot', 'photo', 'photoUrl', 'photo_url', 'imageURL', 'imageUrl', 'Screen', 'picture', 'headshot', 'faceUrl' },
    -- ...
}

Good to know:

  • Dates can be YYYY-MM-DD, MM/DD/YYYY, DD/MM/YYYY or a timestamp; they all print as MM/DD/YYYY.
  • Sex can be 0 / 1, 'm' / 'f', 'male' / 'female'.
  • A photo can be an https:// link, a data: image or plain base64.
  • A detail your card does not carry: on the player's own card it comes from their character; on someone else's card it is left out. A missing number or dates are made up from the card itself, the same every time.
  • Metadata layouts already checked against the wallet: QBCore / Qbox ID items, bl_idcard, LGF_DocumentSystem and Quasar's licence items.

Step 4 (optional): Your own card design

Put the front of your card as a PNG in ryan-wallet/cards/ (any size, it is stretched to the card), then point the item at it and say where the photo and the text go. Positions are on a 1024 x 646 card.

Lua
id_card = {
    label = 'ID card', art = 'cards/id_card.png',
    photo = { x = 40, y = 150, w = 260, h = 330, r = 8 },                -- false = no photo
    text  = {
        { 'fullname', x = 340, y = 250, size = 40, bold = true, upper = true, max = 620 },
        { 'dob',      x = 340, y = 300, size = 28 },
        { 'number',   x = 340, y = 350, size = 30, color = '#b8202a' },
    },
},

Fields you can write: firstname, lastname, fullname, signature, dob, sex, height, weight, eyes, hair, number, issued, expires, class, issuer, nationality, state, title, holder, bank. Up to 12 card items can have their own art.


Step 5 (optional): Show cards on your ID script's own screen

By default a card held out to someone opens the wallet's own card viewer on their screen. To open your ID script's screen instead, you write a few lines in server/hooks.lua.

How it works

When a card is held out, the wallet calls Hooks.OnCardShown(src, target, item, meta, face) on the server:

Argument What it is
src The player holding the card out.
target The player it is shown to (already checked: next to them, same routing bucket). nil = nobody was close.
item The item name ('id_card' ...).
meta The item's own metadata, exactly as your ID script stored it. A stolen card is the owner's card, not the thief's.
face What the card prints, already read for you (or nil if it could not be read): kind ('id', 'dl', 'weapon', 'credit', 'plain'), firstname, lastname, dob (MM/DD/YYYY), sex ('M' / 'F'), nationality, number, class, issued, expires.

Return false to keep the wallet's viewer closed (you showed your own screen). Return nothing to let the wallet's viewer open as normal. Two helpers are there too: Bridge.CardField(meta, 'dob') (a detail by its Config.CardFields names) and Bridge.CardPhoto(meta) (the card's photo as a usable image link, or nil).

Find your ID script's "show" event

Your ID script already has a way to put a card on someone's screen: whatever its own /showid command or item use triggers. Open its server code, find where it shows a card to a nearby player, and note the TriggerClientEvent(...) name and the data it sends. Copy that, with the data built from meta / face.

Your own script: the pattern

Lua
-- recipe: your own
function Hooks.OnCardShown(src, target, item, meta, face)
    if not target then return end                                      -- nobody close: nothing to show
    if item ~= 'id_card' and item ~= 'driver_license' then return end  -- only these go to your script (others: the wallet's viewer)
    TriggerClientEvent('your_idcard:client:show', target, meta)       -- your script's event, with the data it expects
    return false                                                       -- the wallet's viewer stays closed
end

Ready-made recipes

These match each script's public source code at the time of writing. Event names and data can change between versions: if a screen does not open, check the event name in your copy (Step 5, "Find your ID script's show event"). Paste ONE recipe into server/hooks.lua, replacing the empty Hooks.OnCardShown. Bank cards and other cards keep using the wallet's viewer.

um-idcard

Lua
-- recipe: um-idcard
function Hooks.OnCardShown(src, target, item, meta, face)
    if not target or not face or face.kind == 'credit' or face.kind == 'plain' then return end
    local m = {}
    for k, v in pairs(meta) do m[k] = v end
    m.cardtype = m.cardtype or item
    m.firstname, m.lastname = m.firstname or face.firstname, m.lastname or face.lastname
    m.birthdate = Bridge.CardField(meta, 'dob') or face.dob
    m.sex, m.nationality = m.sex or face.sex, m.nationality or face.nationality
    m.mugShot = Bridge.CardPhoto(meta) or 'none'
    m.badge = m.badge or 'none'
    TriggerClientEvent('um-idcard:client:sendData', target, m)
    return false
end

qbx_idcard (Qbox)

Lua
-- recipe: qbx_idcard
function Hooks.OnCardShown(src, target, item, meta, face)
    if not target or not face or face.kind == 'credit' or face.kind == 'plain' then return end
    TriggerClientEvent('um-idcard:client:sendData', target, {
        cardtype = meta.cardtype or item, citizenid = meta.citizenid,
        firstname = face.firstname, lastname = face.lastname, birthdate = Bridge.CardField(meta, 'dob') or face.dob,
        sex = face.sex == 'F' and 'Female' or 'Male', nationality = face.nationality or meta.nationality,
        mugShot = Bridge.CardPhoto(meta), badge = meta.badge or 'none',
    })
    return false
end

bl_idcard

Lua
-- recipe: bl_idcard
function Hooks.OnCardShown(src, target, item, meta, face)
    if not target or not face or face.kind == 'credit' or face.kind == 'plain' then return end
    TriggerClientEvent('bl_idcard:open', target, {
        firstName = face.firstname, lastName = face.lastname, dob = Bridge.CardField(meta, 'dob') or face.dob,
        sex = face.sex == 'F' and 'female' or 'male', id = meta.citizenid or meta.id, idType = meta.idType or item,
        cardId = meta.cardId, nationality = face.nationality or meta.nationality,
        issued = meta.issued or face.issued, expires = meta.expires or face.expires, class = meta.class or face.class,
        dd = meta.dd, imageURL = Bridge.CardPhoto(meta),
    })
    return false
end

five-idcard

Lua
-- recipe: five-idcard
function Hooks.OnCardShown(src, target, item, meta, face)
    if not target or not face or face.kind == 'credit' or face.kind == 'plain' then return end
    TriggerClientEvent('identity:client:showIdCard', target, {
        firstName = face.firstname, lastName = face.lastname, dob = Bridge.CardField(meta, 'dob') or face.dob,
        sex = face.sex == 'F' and 'f' or 'm', exp = face.expires, cref = face.number, class = face.class, pref = meta.pref,
    })
    return false
end

LGF_DocumentSystem (TypeDocs must be one of its document types; its own cards carry it)

Lua
-- recipe: LGF_DocumentSystem
function Hooks.OnCardShown(src, target, item, meta, face)
    if not target or not face or face.kind == 'credit' or face.kind == 'plain' then return end
    TriggerClientEvent('LGF_DocumentSystem.OpenDocsForNearby.response', target, {
        Name = face.firstname, Surname = face.lastname, Sex = face.sex == 'F' and 'f' or 'm',
        Dob = Bridge.CardField(meta, 'dob') or face.dob, Avatar = Bridge.CardPhoto(meta),
        IdCard = meta.IdCard or face.number, Expiration = meta.Expiration or face.expires,
        Released = meta.Released or face.issued, TypeDocs = meta.TypeDocument or item,
    })
    return false
end

jsfour-idcard / esx_idcard (ESX)

Lua
-- recipe: jsfour-idcard
function Hooks.OnCardShown(src, target, item, meta, face)
    if not target or not face or face.kind == 'credit' or face.kind == 'plain' then return end
    TriggerClientEvent('jsfour-idcard:open', target, {
        user = { { firstname = face.firstname, lastname = face.lastname, dateofbirth = Bridge.CardField(meta, 'dob') or face.dob,
                   sex = face.sex == 'F' and 'f' or 'm', height = Bridge.CardField(meta, 'height') } },
        licenses = face.kind == 'dl' and { { type = 'drive' } } or face.kind == 'weapon' and { { type = 'weapon' } } or {},
    }, face.kind == 'dl' and 'driver' or face.kind == 'weapon' and 'weapon' or nil)
    return false
end

qb-idcard (QBCore)

Lua
-- recipe: qb-idcard
function Hooks.OnCardShown(src, target, item, meta, face)
    if not target or not face or face.kind == 'credit' or face.kind == 'plain' then return end
    TriggerClientEvent('qb-idcard:client:open', target, {
        name = face.firstname, lastname = face.lastname, gender = face.sex == 'F' and '1' or '0',
        dob = Bridge.CardField(meta, 'dob') or face.dob, nationality = face.nationality, type = meta.type,
    }, face.kind == 'dl' and 'driverlicense' or face.kind == 'weapon' and 'weaponlicense' or 'idcard')
    return false
end

QBCore chat card (the card qb-inventory prints in the chat)

Lua
-- recipe: qb-chat
function Hooks.OnCardShown(src, target, item, meta, face)
    if not target or not face or face.kind == 'credit' or face.kind == 'plain' then return end
    local rows = {
        ('<strong>%s</strong>'):format(Config.Cards[item] and Config.Cards[item].label or 'Card'),
        ('First Name: %s'):format(face.firstname or ''), ('Last Name: %s'):format(face.lastname or ''),
        ('Birthdate: %s'):format(Bridge.CardField(meta, 'dob') or face.dob or ''), ('Gender: %s'):format(face.sex == 'F' and 'Female' or 'Male'),
    }
    if meta.citizenid then table.insert(rows, 2, ('Civ ID: %s'):format(meta.citizenid)) end
    TriggerClientEvent('chat:addMessage', target, { template = '<div class="chat-message advert"><div class="chat-message-body">{0}</div></div>', args = { table.concat(rows, '<br>') } })
    return false
end

Scripts that can only show a card to people near the HOLDER from the holder's own inventory (for example some escrowed document scripts) can not be pointed at one player from here. With those, the wallet's own viewer shows the card (their cards still read right, Step 3).

Also available: Hooks.OnCardHanded(src, target, item, meta) (a card changed hands, it is in the target's inventory now) and Hooks.OnCash(src, amount) (cash in, or out when negative), for logs or your own records.


Step 6: Let your scripts find cards that are in a wallet

Anything that checks "does this player have the item?" in the player's inventory does not see a card while it is in a wallet. That includes an ID script's own /showid command or item use, a police "check ID" or search, and ATMs or bank scripts that need a bank card.

Option A (best): ask the wallet

The wallet's HasCard export looks in the player's pockets and in every wallet they carry.

Server

Lua
-- before (only the pockets):
local hasId = exports.ox_inventory:Search(source, 'count', 'id_card') > 0

-- after (pockets + wallets):
local hasId, card = exports['ryan-wallet']:HasCard(source, 'id_card')
-- card = { name, metadata, inv, slot, inWallet }   (card.metadata = what your ID script stored)

Several item names at once, and only the player's OWN card:

Lua
local Player = exports.qbx_core:GetPlayer(source)
local hasBankCard = exports['ryan-wallet']:HasCard(source, { 'visa', 'mastercard' }, { citizenid = Player.PlayerData.citizenid })

The third argument is metadata the card must have (every key must match).

Client (it asks the server, so call it from a thread / a function that can wait):

Lua
CreateThread(function()
    local hasCard, card = exports['ryan-wallet']:HasCard({ 'visa', 'mastercard' })
    if not hasCard then return lib.notify({ description = 'You need a bank card', type = 'error' }) end
    -- open your ATM ...
end)

Every card instead of the first: exports['ryan-wallet']:SearchCards(source, { 'id_card', 'driver_license' }) returns a list { { name, metadata, inv, slot, inWallet }, ... }, pockets first.

Option B: keep that item out of the wallet

Leave the item out of Config.Cards and it stays an ordinary inventory item that every script finds. A common choice for bank cards your ATMs need.

Option C: take it out first

The player takes the card out of the wallet and presses F (pocket it). It is back in their inventory.

If your ID or bank script is escrowed and you can not change its item check, use B or C.


Step 7: Choose how cards get into wallets

  • Config.AutoCollect = false (the default): a card only goes into a wallet when the player puts it there (F with the wallet out). Until then everything you already have keeps working as before.
  • Config.AutoCollect = true: taking the wallet out moves the player's own cards from their pockets into it. Turn this on only after Step 6, or once you are happy that your scripts do not need those items in the inventory.
  • Config.Starter.moveCards = true also moves a new character's cards into their first wallet.

Step 8: Test it

Do these on your server with two players. The expected result is next to each.

# Do this You should see
1 Restart ryan-wallet. With your ID card in your pockets, use the wallet item, then press F. Your hand takes the card from your pocket: it is now in the wallet, held in your hand. Click the wallet (or X) to slide it into its place.
2 Click the card in the wallet to take it out. Your name, number and photo on the card in your hand. A detail missing: Step 3.
3 Hold it out (click it / E) to the second player. They see the card: the wallet's viewer, or your ID script's screen if you did Step 5.
4 With the card IN the wallet, use your ID script's /showid, a police check or an ATM. It works if you did Step 6 option A. If it says "no card", that script still checks only the inventory.
5 Hand the card over (H). The second player gets the real item (same metadata); your ID script still recognises it.
6 Put the wallet away, drop it, let the second player pick it up and open it. The cards and cash are still inside (a stolen wallet keeps its contents).

Troubleshooting

Problem Fix
A card does not go in the wallet ("There is no card in your pockets.") Its item name is not in Config.Cards, or it has enabled = false.
The card shows the wrong name / no name The metadata uses a name not in Config.CardFields (Step 3).
No photo on the card Add the metadata's photo field name to Config.CardFields.photo, or set Config.RealCards.photo = 'headshot'.
Your ID script's screen does not open (Step 5) The event name or data differs in your version: check its server code for the event it sends to show a card. Errors print in the server console.
An ATM / /showid says you have no card while it is in the wallet That script checks only the inventory: Step 6.
"Your wallet is full." A wallet holds Config.Storage.slots items (8 by default).
Nothing at all happens when using the wallet Check the server console for [ryan-wallet] lines: a wallet item missing in ox_inventory, stack = false missing, or the wallet turned off in the config.

Reference

Server exports

  • exports['ryan-wallet']:HasCard(source, names, match) returns true, card or false
  • exports['ryan-wallet']:SearchCards(source, names) returns { card, ... }
  • exports['ryan-wallet']:GetWalletStash(source, slot) returns the stash id of the wallet in that inventory slot, or nil
  • exports['ryan-wallet']:IsWallet(itemName) returns true / false

Client exports

  • exports['ryan-wallet']:HasCard(names, match) returns true, { name, metadata, inWallet } or false (call from a thread)
  • exports['ryan-wallet']:IsOut() returns true while the wallet is out
  • LocalPlayer.state.ryanWalletOut is true while the wallet has the player's hands

Hooks (server/hooks.lua)

  • Hooks.OnCardShown(src, target, item, meta, face): return false to show your own screen instead of the wallet's viewer
  • Hooks.OnCardHanded(src, target, item, meta)
  • Hooks.OnCash(src, amount)
Still stuck? Open a ticket in the Ryan Studios Discord and we'll help you out.