Player
Server exports for finding, reading and acting on players. Each takes a source and finds the player itself; for when players load and leave, see Character Lifecycle.
The player sheet#
GetPlayer and the other lookups return a plain copy of the sheet, with no methods; change the player through exports.
local player = exports.whip_core:GetPlayer(source) -- nil until the character is fully loaded
if not player then return end
-- source (server id), session (this load, for IsSessionCurrent), userId (account), charId
-- firstName, lastName, fullName ("First Last"), dateOfBirth ("YYYY-MM-DD"), gender
-- cash (on hand), position ({ x, y, z, w }), health (0-200, 200 full), armour, isDead
-- metadata (not on the sheet a SecureEvent handler gets)The client gets the same sheet, so identifiers stay off it (GetPlayerIdentifiers). Pockets and stats aren't on it either: use GetInventory and GetStats.
Finding players
Whether whip_core has finished starting. Whip.register doesn't need it (Your First Resource, step 3).
booleanA copy of the whole sheet, appearance included, or nil until the character has loaded. Online players only. For one number, GetCharId is cheaper.
| Param | Type | Description |
|---|---|---|
| who | number|table | A server id, { charId = }, { userId = } (the account), or { identifier = 'license:…' } (license, steam, discord or fivem) |
table|nillocal owner = exports.whip_core:GetPlayer({ charId = v.owner.charId }) -- nil when they are offline
Their charId, whether a character is loaded, and whether they're down. They copy nothing: use them on hot paths.
integer|nil · boolean · booleanWhether the sheet's session (new each load) is still current. After a long wait, check it before giving or taking: a player who switched character mid-wait would be charged on one and paid on the other. (Logout waits up to two seconds for running handlers.)
booleanWait(4000) -- after ChargePlayer
if not exports.whip_core:IsSessionCurrent(source, player.session) then
exports.whip_core:RefundPlayer(receipt)
return false, 'You left before the sale went through'
end
Every loaded player's sheet, keyed by server id. { light = true } returns light sheets (source, session, userId, charId, names, date of birth, gender, isDead): much cheaper.
table<number, table>The platform identifiers the sheet leaves out.
| Param | Type | Description |
|---|---|---|
| source | number | Server id |
{ discord, fivem, license, steam }, or nilPlayers within network range of a point. Send news about a place to these, not to -1.
| Param | Type | Description |
|---|---|---|
| coords | vector3|table | The point; height is ignored |
| range | number? | Metres; default Config.NetworkRange (424) |
number[] server ids; empty for bad inputThe ped's position and heading now (the saved position until it spawns).
vector4|nilWhether a character is deleted or never existed. Ask before removing data on whip_core:character:deleted, which any server resource can fire.
true, 'deleted' or true, 'no such character'; false for a live one, or false, why when it can't tellNames
The character's name without copying the sheet. Not FiveM's GetPlayerName, the account's name.
string|nilRename an online or offline character without changing their charId or anything owned by it. Uses the character editor's name rules: letters, spaces and hyphens, at least two letters and at most 30 characters per name. Online players receive the new name immediately; fires whip_core:character:renamed.
| Param | Type | Description |
|---|---|---|
| who | number|table | Online server id, or { charId = n } |
| firstName, lastName | string | The two names |
true, fullName, oldName, or false, reasonCheck permission in your server handler before calling; this export does not grant a player permission to rename another character.
Names for up to 200 characters, online or not: a job's staff, an account's users. Check CanSeePlayerName before showing a stranger's.
| Param | Type | Description |
|---|---|---|
| charIds | number[] | The characters |
{ [charId] = 'First Last' }, leaving out unknown idsWhat one name string can't carry, for up to 200 characters, online or not: an ID card, a licence, a records screen. Online characters come from their live sheet, the rest from one query. Deleted characters are left out. Check CanSeePlayerName before showing a stranger's.
| Param | Type | Description |
|---|---|---|
| charIds | number[] | The characters |
{ [charId] = { charId, firstName, lastName, fullName, dateOfBirth, gender, online } } (dateOfBirth as 'YYYY-MM-DD', gender 'male' or 'female'), leaving out unknown and deleted ids; or false, reason if the database failslocal info = exports.whip_core:GetCharacterInfo({ charId })
local c = info and info[charId]
if c then print(c.lastName, c.dateOfBirth) end
Whether viewer may see target's name under Config.ShowPlayerNames: 'nearby' (within PlayerNameRange, same world, not in the creator), 'always' or 'never' (only your own). Use it wherever you show a name.
| Param | Type | Description |
|---|---|---|
| viewer | person | Server id, or { charId = n } (online) |
| target | person | Server id, or { charId = n } |
true, or false, why ('Too far away', 'Names are hidden on this server', 'Player not loaded')Cash
Total cash in every container the character carries: loose notes only, not what is in a wallet.
number; 0, 'Player not loaded'What a cash payment can take now: loose notes plus the cash in the wallets the character carries (in the pockets or on the strip). ChargePlayer and HoldMoney with method = 'cash' take loose notes first, then wallet cash. Use this, not GetPlayerCash, to check a price before charging.
number; 0, 'Player not loaded'Messages, blips and props
Shows a player one of WHIP's toasts; -1 shows everyone.
| Param | Type | Description |
|---|---|---|
| text | string | Up to 300 characters |
| kind | string? | 'info' (default), 'success', 'warning' or 'error' |
| duration | number? | Milliseconds |
boolean: false for a player not on, or no textWords in the player's hint capsule, beside their game's own ShowText and any bar. A new one replaces it; HidePlayerText removes only yours, and it goes when your resource stops, your tag is released, or they log out. Up to 200 characters.
| Param | Type | Description |
|---|---|---|
| text | string | What it says |
| opts.position | string? | 'bottom' (default) or 'top' |
| opts.progress | number? | 0–100: fills its disc and a bar under the words |
| opts.countdown | number? | Seconds: a clock after the text (· 1:30), run by the player's game, stopping at 0:00 |
| opts.countdownTotal | number? | The clock's full length, if it started earlier |
| opts.tag | string? | Your run tag (see ReleaseTag) |
true, or false, reasonTell WHIP's pause map the label of a blip your resource made. GTA does not let WHIP read a blip's custom name back; without this registration the map uses the sprite's name, such as "Getaway Car" instead of "PDM". This does not change GTA's blip name, create a blip or remove one.
| Param | Type | Description |
|---|---|---|
| handle | integer | Positive client blip handle, such as the result of AddBlipForCoord. The blip must exist when registering a label |
| label | string|nil | Non-empty label, or nil to remove your registration, even after the blip has been deleted |
The same resource can update its label. Another running resource's registration and WHIP's own labels cannot be replaced. Only the registering resource can remove its label; removing an unregistered label succeeds. Labels are cleared when their resource stops.
true, handle when registered; true when removed; or false, reason for an invalid handle or label, a missing blip, or another resource's label. Does not wait.local blip = AddBlipForCoord(409.3, -1623.1, 29.3)
BeginTextCommandSetBlipName('STRING')
AddTextComponentSubstringPlayerName('PDM')
EndTextCommandSetBlipName(blip)
exports.whip_core:SetBlipLabel(blip, 'PDM')
-- When removing it:
exports.whip_core:SetBlipLabel(blip, nil)
RemoveBlip(blip)
Clear the registration whenever you remove the blip, so a reused handle does not inherit its old label. If whip_core restarts while your resource keeps running, register the labels of your surviving blips again from onClientResourceStart. For blips managed by WHIP, use ShowBlip with spec.label instead.
A blip for 'everyone', { people = { serverId | { charId = n } } } or { job = 'police', onDuty = true }. The same id updates it; it goes when your resource stops or your tag is released. SetPlayerWaypoint sets one player's GPS waypoint.
| spec | Type | Description |
|---|---|---|
| coords | vector3 | Where |
| label | string? | Map legend name (40 characters) |
| sprite | integer? | Blip icon; default 1, the dot. 0 for none |
| color | integer? | 5 yellow (default), 1 red, 2 green, 3 blue, 0 white |
| route | boolean? | Shows the GPS route |
| radius | number? | Metres: an area instead of a point |
| shortRange | boolean? | Only on the radar when near |
| scale · flash | number? · boolean? | Size (0.3–2, default 0.9) · flashing |
| number | integer? | 0–99, on the dot: a route's stops in order (1, 2, 3). On GTA's map and whip's pause map and minimap |
| tag | string? | Your run tag |
true, or false, reasonScenery each player's own game makes as they come near: crates, barriers, cash on a table. Not networked, frozen where placed, and can't be picked up. The same id replaces the set; it goes when your resource stops or your tag is released.
| spec | Type | Description |
|---|---|---|
| props | table | Up to Config.PropSetMaxProps (256) of { model, coords, rot?, heading?, interior?, light?, collision?, weapon?, attach?, attachOffset?, attachRot?, drawDistance? }. rot: vector3(tiltForward, tiltSideways, heading), rotation order 2. collision = false: walk through. interior = true waits for an MLO and files it in its room; light = true lets a lamp light it. drawDistance (m, up to 500): each game makes and draws it that far out instead of 150 m, past its model's own draw distance (a speaker heard from afar). Costs a little drawing, nothing on the network |
| props[n].weapon | string? | A firearm's world model ('WEAPON_RPG', or from Whip.weapons) |
| props[n].attach | table? | Rides on { net = netId }, { set = id, index = n } or { index = n }, offset by attachOffset (m) and attachRot (°). Back in place when the parent goes |
| audience | 'everyone'|table? | Default everyone, or { people = { … } } |
| tag | string? | Your run tag |
true, or false, reason. A model a game lacks is skipped thereMetadata
One metadata key, or the whole table. who is a person: a character who isn't playing is read from the database.
any; nil for nobodyWrites one key, saved with the character. who is a person: a character who isn't playing has their row written. Prefix yours ('myjob_licences'): the table is shared. WHIP's keys are refused: appearance, outfits, creatorPending, walk, mood, whipFlags, moneyHeldOwed, pourRefundOwed, lastSeat.
true, or false, reason: a WHIP key, no such person, unsaveable (a function, NaN), or a character logging in right now (try again)Flags#
Named facts about a character that outlive a restart ("met the fence", "jobs done: 3"), also used by Director scenarios. Kept in metadata: cheap, and visible to the player's game.
Set, read or list an online character's flags. Each change fires whip_core:flag:changed { source, charId, name, value, was }.
| Param | Type | Description |
|---|---|---|
| who | number|{ charId } | A server id or an online character |
| name | string | A letter, then letters, digits, _ . - :; at most 64. _ names are WHIP's |
| value | true|number|string|nil | Text up to 100 characters; nil or false clears. 256 flags per character at most |
true, or false, reason. Get: the value or nil. GetPlayerFlags: { [name] = value }, or nil when offlinelocal jobs = exports.whip_core:GetPlayerFlag(source, 'jobs_done') or 0
exports.whip_core:SetPlayerFlag(source, 'jobs_done', jobs + 1)
Saving and removing
Writes the character now, rarely needed (Save system): before your own write that follows an inventory change, or before something outside WHIP reads the rows.
boolean ok, string|nil errSaves the character and drops the player with the reason.
boolean ok, string|nil errSaves, tears down the character's server state, and returns them to character select. Unless you're building your own character select, you want KickPlayer.
boolean ok, string|nil err: false, 'Already leaving' while logging out or disconnectingAppearance
Runs an appearance through the character creator's validator, clamping every index. Optional tattoos ({ { collection, overlay }, … }, at most 40) and hairFade (one { collection, overlay }) are kept only if shared/tattoo_list.lua or shared/hair_fades.lua lists them for that body (once each, in the list's spelling); others are dropped, never refused.
| Param | Type | Description |
|---|---|---|
| appearance | table | Appearance data to validate |
boolean ok, table|string result: the cleaned appearance, or why it was refusedOpens a player's character editor on their own character, as /charedit does: Save keeps the new look and Cancel puts the old one back. It's refused for someone who isn't online, is still making their character or is down, and their game also refuses it while the editor is already open. A surgeon calls it once the player has paid; a store uses EditAppearance.
| Param | Type | Description |
|---|---|---|
| who | number|table | A server id, or { charId = n } for a character who is online |
true, or false, whylocal ok, why = exports.whip_core:OpenCharacterEditor(source)
if not ok then exports.whip_core:NotifyPlayer(source, why, 'error') end
A place in the spawn picker beside Config.SpawnPoints: a gang's hideout, a job's depot, a hotel. Your ids are your own; the same id again replaces it, and it goes when your resource stops. Picked, it is read again live, so one removed (or no longer allowed) since the list was sent is refused. At most 30 registered at once. An id is letters, digits, - and _, at most 24, and at most 92 with your resource's name.
| def | Type | Description |
|---|---|---|
| pos | vector4 | Where they arrive and the way they face (a vector3 faces north) |
| label | string? | Its name in the list (40 characters; the id when left out) |
| canUse | function? | (charId) → true for the characters who may pick it; checked for the list and again when picked. An error hides it |
true, or false, whyexports.whip_core:RegisterSpawnPoint('hideout', {
label = 'The Hideout', pos = vector4(-1150.2, -1520.4, 4.4, 35.0),
canUse = function(charId) return isMember(charId) end,
})
A store (clothes, a barber, tattoos) opens the editor with EditAppearance on the player's game: only its tabs, the price of what changed on Save. Its server counts the changes with GetAppearanceChanges, charges, and keeps the look with SetPlayerAppearance. The tabs are the editor's category ids (heritage features eyes hair eyebrows beard makeup skin chestHair, mask tops undershirt arms legs shoes accessory armor decal bag, hat glasses ear watch bracelet, tatHead tatTorso tatLeftArm tatRightArm tatLeftLeg tatRightLeg, outfits) or their groups (face apparel props tattoos outfits). Any tattoo tab lets every tattoo change. Saved outfits only put clothes on, so offer outfits with apparel and props.
Opens the character editor on this character's own look, as a store. Save shows the price of what changed and calls onSave(look), which charges and keeps it (on the server) and returns true, or false, why: the reason is shown on Save and the editor stays open. Cancel puts the old look back. Refused while dead, in a vehicle or holding a weapon. Waits for the fade.
| Field | Type | Description |
|---|---|---|
| only | table? | The tabs offered: category ids or groups. Left out, all of them |
| prices | table? | Dollars each, by category id, then group, then default: { apparel = 50, hat = 20 }. tattoos is per tattoo put on |
| methods | table? | { 'cash', 'bank' }: Save first opens a checkout, as whip_autos' basket: the total and a tile for each way to pay. One: no checkout, that way. Left out, Save pays your own way |
| wallet | table? | { cash = n, bank = n }: shown on the tiles; one that can't cover the total is greyed out. Read it on your server (GetSpendableCash, GetBalance) |
| title / sub | string? | The editor's heading |
| onSave | function(look, method) | Required. May wait. method is the tile chosen, or nil. Returns true, or false, why (60 characters) |
| onClose | function(saved)? | The editor shut: saved, or not (Cancel, a death, a logout) |
true, or false, whyexports.whip_core:EditAppearance({
only = { 'hair', 'beard', 'eyebrows' }, prices = { hair = 40, default = 15 }, title = 'Herr Kutz',
methods = { 'cash', 'bank' }, wallet = exports.whip_core:Callback('mybarber:wallet'),
onSave = function(look, method) return exports.whip_core:Callback('mybarber:buy', look, method) end,
})
What changed between a playing character's saved look and look, counted as the editor prices it: one per category id changed (makeup counts each of its three overlays), and tattoos per tattoo put on. Taking off an accessory or a tattoo counts nothing.
| Param | Type | Description |
|---|---|---|
| who | number|table | A server id, or { charId = n } |
| look | table | The look from the editor |
| only | table? | Count only these category ids or groups |
{ [id] = count, tattoos? }, or false, whyKeeps a look for a playing character, checked as the editor's Save is. opts.only takes only those tabs' parts from look and keeps the rest of their saved look, so a barber can't change a face. What they wear changes with the editor's Save (EditAppearance); called on its own, when they next load in.
true, look (as kept), or false, whySecureCallback('mybarber:buy', { params = { { 'look', 'any' }, { 'method', 'enum', { 'cash', 'bank' }, 'cash' } } },
function(source, player, look, method)
local only = { 'hair', 'beard', 'eyebrows' }
local changes, why = exports.whip_core:GetAppearanceChanges(source, look, only)
if not changes then return false, why end
local total = 0
for id, n in pairs(changes) do total = total + (id == 'hair' and 40 or 15) * n end
local receipt, err = exports.whip_core:ChargePlayer(source, total, { method = method, reason = 'Haircut' })
if not receipt then return false, err end
local ok, kept = exports.whip_core:SetPlayerAppearance(source, look, { only = only })
if not ok then exports.whip_core:RefundPlayer(receipt) return false, kept end
return true
end)