Hooks
server/hooks.lua is open (not escrowed) and empty by default. Its functions are called on the server when something
happens with a wallet, for your logs, your own ID screen or a CAD lookup. Every argument has been checked by the server
first. An error in a hook is caught and never breaks the wallet.
Hooks.OnCardShown
function Hooks.OnCardShown(src, target, item, meta, face)
end
A card was held out.
| Argument | What it is |
|---|---|
src |
The player holding the card out. |
target |
The player it is shown to: next to them and in the same routing bucket, already checked. 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). |
face holds kind ('id', 'dl', 'weapon', 'credit', 'plain'), item, firstname and lastname, and:
- for an ID, license, permit or plain card:
dob(MM/DD/YYYY),sex('M'/'F'),nationality,number,class,issuedandexpires(MM/DD/YYYY),title,height,weight; - for a bank card:
bank,number,expires(MM/YY) andholder. Itsnumberis already masked to the last 4 digits whenConfig.Show.maskNumberis on.
Return false to keep the wallet's own card viewer closed (because you showed your own screen). Return nothing
to let it open as normal.
function Hooks.OnCardShown(src, target, item, meta, face)
if not target or item ~= 'id_card' then return end
TriggerClientEvent('your_idcard:client:show', target, meta)
return false
end
Ready-made versions for popular ID scripts are in Your own ID and bank scripts.
Two helpers from the framework bridge are there for you:
Bridge.CardField(meta, 'dob'): one detail of a card, by itsConfig.CardFieldsnames (nilwhen the card does not carry it).Bridge.CardPhoto(meta): the card's photo as a usable image link (https://ordata:), ornil.
Hooks.OnCardHanded
function Hooks.OnCardHanded(src, target, item, meta)
end
A card was handed from src to target. It is in the target's inventory now. meta is its metadata.
Hooks.OnCash
function Hooks.OnCash(src, amount)
end
Cash went into a wallet (amount > 0) or came out (amount < 0).
function Hooks.OnCash(src, amount)
print(('[wallet] %s %s $%d'):format(GetPlayerName(src), amount > 0 and 'put in' or 'took out', math.abs(amount)))
end