Esc to clear, Enter to open the best match, click an export to open it in its page
Players

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

IsReady()SERVER#

Whether whip_core has finished starting. Whip.register doesn't need it (Your First Resource, step 3).

Returns: boolean
GetPlayer(who)SERVER#

A copy of the whole sheet, appearance included, or nil until the character has loaded. Online players only. For one number, GetCharId is cheaper.

ParamTypeDescription
whonumber|tableA server id, { charId = }, { userId = } (the account), or { identifier = 'license:…' } (license, steam, discord or fivem)
Returns: table|nil
local owner = exports.whip_core:GetPlayer({ charId = v.owner.charId })   -- nil when they are offline
GetCharId(source) · IsPlayerLoaded(source) · IsPlayerDead(source)SERVER#

Their charId, whether a character is loaded, and whether they're down. They copy nothing: use them on hot paths.

Returns: integer|nil · boolean · boolean
IsSessionCurrent(source, session)SERVER#

Whether 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.)

Returns: boolean
Wait(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
GetPlayers(opts?)SERVER#

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.

Returns: table<number, table>
GetPlayerIdentifiers(source)SERVER#

The platform identifiers the sheet leaves out.

ParamTypeDescription
sourcenumberServer id
Returns: { discord, fivem, license, steam }, or nil
GetPlayersInRange(coords, range?)SERVER#

Players within network range of a point. Send news about a place to these, not to -1.

ParamTypeDescription
coordsvector3|tableThe point; height is ignored
rangenumber?Metres; default Config.NetworkRange (424)
Returns: number[] server ids; empty for bad input
GetPlayerCoords(source)SERVER#

The ped's position and heading now (the saved position until it spawns).

Returns: vector4|nil
IsCharacterDeleted(charId)SERVERWAITS#

Whether a character is deleted or never existed. Ask before removing data on whip_core:character:deleted, which any server resource can fire.

Returns: true, 'deleted' or true, 'no such character'; false for a live one, or false, why when it can't tell

Names

GetPlayerFullName(source)SERVER#

The character's name without copying the sheet. Not FiveM's GetPlayerName, the account's name.

Returns: string|nil
RenameCharacter(who, firstName, lastName)SERVERWAITS#

Rename 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.

ParamTypeDescription
whonumber|tableOnline server id, or { charId = n }
firstName, lastNamestringThe two names
Returns: true, fullName, oldName, or false, reason

Check permission in your server handler before calling; this export does not grant a player permission to rename another character.

GetCharacterNames(charIds)SERVERWAITS#

Names for up to 200 characters, online or not: a job's staff, an account's users. Check CanSeePlayerName before showing a stranger's.

ParamTypeDescription
charIdsnumber[]The characters
Returns: { [charId] = 'First Last' }, leaving out unknown ids
GetCharacterInfo(charIds)SERVERWAITS#

What 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.

ParamTypeDescription
charIdsnumber[]The characters
Returns: { [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 fails
local info = exports.whip_core:GetCharacterInfo({ charId })
local c = info and info[charId]
if c then print(c.lastName, c.dateOfBirth) end
CanSeePlayerName(viewer, target)SERVER#

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.

ParamTypeDescription
viewerpersonServer id, or { charId = n } (online)
targetpersonServer id, or { charId = n }
Returns: true, or false, why ('Too far away', 'Names are hidden on this server', 'Player not loaded')

Cash

GetPlayerCash(source)SERVER#

Total cash in every container the character carries: loose notes only, not what is in a wallet.

Returns: number; 0, 'Player not loaded'
GetSpendableCash(source)SERVER#

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.

Returns: number; 0, 'Player not loaded'

Messages, blips and props

NotifyPlayer(source, text, kind?, duration?)SERVER#

Shows a player one of WHIP's toasts; -1 shows everyone.

ParamTypeDescription
textstringUp to 300 characters
kindstring?'info' (default), 'success', 'warning' or 'error'
durationnumber?Milliseconds
Returns: boolean: false for a player not on, or no text
ShowPlayerText(source, text, opts?) · HidePlayerText(source)SERVER#

Words 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.

ParamTypeDescription
textstringWhat it says
opts.positionstring?'bottom' (default) or 'top'
opts.progressnumber?0–100: fills its disc and a bar under the words
opts.countdownnumber?Seconds: a clock after the text (· 1:30), run by the player's game, stopping at 0:00
opts.countdownTotalnumber?The clock's full length, if it started earlier
opts.tagstring?Your run tag (see ReleaseTag)
Returns: true, or false, reason
SetBlipLabel(handle, label)CLIENT#

Tell 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.

ParamTypeDescription
handleintegerPositive client blip handle, such as the result of AddBlipForCoord. The blip must exist when registering a label
labelstring|nilNon-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.

Returns: 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.

ShowBlip(audience, id, spec) · HideBlip(id) · SetPlayerWaypoint(source, coords)SERVER#

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.

specTypeDescription
coordsvector3Where
labelstring?Map legend name (40 characters)
spriteinteger?Blip icon; default 1, the dot. 0 for none
colorinteger?5 yellow (default), 1 red, 2 green, 3 blue, 0 white
routeboolean?Shows the GPS route
radiusnumber?Metres: an area instead of a point
shortRangeboolean?Only on the radar when near
scale · flashnumber? · boolean?Size (0.3–2, default 0.9) · flashing
numberinteger?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
tagstring?Your run tag
Returns: true, or false, reason
ShowPropSet(id, spec) · HidePropSet(id)SERVER#

Scenery 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.

specTypeDescription
propstableUp 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].weaponstring?A firearm's world model ('WEAPON_RPG', or from Whip.weapons)
props[n].attachtable?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 = { … } }
tagstring?Your run tag
Returns: true, or false, reason. A model a game lacks is skipped there

Metadata

GetPlayerMetadata(who, key?)SERVERWAITS#

One metadata key, or the whole table. who is a person: a character who isn't playing is read from the database.

Returns: any; nil for nobody
SetPlayerMetadata(who, key, value)SERVERWAITS#

Writes 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.

Returns: true, or false, reason: a WHIP key, no such person, unsaveable (a function, NaN), or a character logging in right now (try again)
Metadata isn't secret. The player's game gets every value: keep codes and cheat flags server-side.

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.

SetPlayerFlag(who, name, value) · GetPlayerFlag(who, name) · GetPlayerFlags(who)SERVER#

Set, read or list an online character's flags. Each change fires whip_core:flag:changed { source, charId, name, value, was }.

ParamTypeDescription
whonumber|{ charId }A server id or an online character
namestringA letter, then letters, digits, _ . - :; at most 64. _ names are WHIP's
valuetrue|number|string|nilText up to 100 characters; nil or false clears. 256 flags per character at most
Returns: Set: true, or false, reason. Get: the value or nil. GetPlayerFlags: { [name] = value }, or nil when offline
local jobs = exports.whip_core:GetPlayerFlag(source, 'jobs_done') or 0
exports.whip_core:SetPlayerFlag(source, 'jobs_done', jobs + 1)

Saving and removing

SavePlayer(source)SERVERWAITS#

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.

Returns: boolean ok, string|nil err
KickPlayer(source, reason)SERVER#

Saves the character and drops the player with the reason.

Returns: boolean ok, string|nil err
LogoutPlayer(source)SERVER#

Saves, tears down the character's server state, and returns them to character select. Unless you're building your own character select, you want KickPlayer.

Returns: boolean ok, string|nil err: false, 'Already leaving' while logging out or disconnecting

Appearance

SanitizeAppearance(appearance)SERVER#

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.

ParamTypeDescription
appearancetableAppearance data to validate
Returns: boolean ok, table|string result: the cleaned appearance, or why it was refused
OpenCharacterEditor(who)SERVER#

Opens 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.

ParamTypeDescription
whonumber|tableA server id, or { charId = n } for a character who is online
Returns: true, or false, why
local ok, why = exports.whip_core:OpenCharacterEditor(source)
if not ok then exports.whip_core:NotifyPlayer(source, why, 'error') end
RegisterSpawnPoint(id, def) · RemoveSpawnPoint(id)SERVER#

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.

defTypeDescription
posvector4Where they arrive and the way they face (a vector3 faces north)
labelstring?Its name in the list (40 characters; the id when left out)
canUsefunction?(charId) → true for the characters who may pick it; checked for the list and again when picked. An error hides it
Returns: true, or false, why
exports.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.

EditAppearance(opts)CLIENTWAITS#

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.

FieldTypeDescription
onlytable?The tabs offered: category ids or groups. Left out, all of them
pricestable?Dollars each, by category id, then group, then default: { apparel = 50, hat = 20 }. tattoos is per tattoo put on
methodstable?{ '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
wallettable?{ 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 / substring?The editor's heading
onSavefunction(look, method)Required. May wait. method is the tile chosen, or nil. Returns true, or false, why (60 characters)
onClosefunction(saved)?The editor shut: saved, or not (Cancel, a death, a logout)
Returns: true, or false, why
exports.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,
})
GetAppearanceChanges(who, look, only?)SERVER#

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.

ParamTypeDescription
whonumber|tableA server id, or { charId = n }
looktableThe look from the editor
onlytable?Count only these category ids or groups
Returns: { [id] = count, tattoos? }, or false, why
SetPlayerAppearance(who, look, opts?)SERVER#

Keeps 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.

Returns: true, look (as kept), or false, why
SecureCallback('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)