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

Return values

Every export follows one rule: the first value is the result or false; the second is why. Exports don't throw, and never return nil, 'reason', because an export's return values are cut off at the first nil.

local ok, why = exports.whip_core:RemoveItem(source, 'mycafe_coffee', 1)
if not ok then return false, why end
Kind of callSuccessFailure
Change somethingtrue, or something more useful (AddItem returns 'inventory' or 'ground', StoreGive the slot). Still truthy, so if not ok worksfalse, why
Read about a playerThe valueA list, count or yes/no returns its empty form and why: {}, why · 0, why · false, why. A single value (a stat, coordinates, the player sheet) returns nil
Check (may they?)truefalse, why: CanUseBankAccount, HasPropertyAccess, HasJobPermission, CanUseDoor
CreateThe new thing as a table; a vehicle returns its vehicleId (CreateOwnedVehicle, SpawnTempVehicle, AdoptVehicle)false, why
Deletetruefalse, why
Look upA tablenil when there's nothing; false, why when the question is wrong (a bad address)
Return an idThe id: AddAction, AddPoint, HoldMoney, WatchVehicleStatfalse, why. Where there's a third value (the warnings of AddAction, UpdateAction, AddPoint), the second is false on success so the third gets through

Skipping an optional value: pass false, not nil, when more values follow it. On FiveM for GTAV Enhanced every value after a nil is lost on its way to another resource, so AddItem(source, 'drink', 2, nil, 'quest reward') arrives without its reason. Every whip export reads false there as not given: AddItem(source, 'drink', 2, false, 'quest reward'). Do the same in your own exports, events and callbacks. A listener whip calls in your resource gets false for a value that is not there (the old value of a first change).

Codes and sentences#

The reason isLooks likeFromDo
A code'busy', 'cancelled', 'too far', 'failed'Progress, SkillCheckBranch on it (if why == 'cancelled') and write your own words for the player
A sentence'Not enough cash'Everything elseShow it to the player, or return it from a SecureEvent. Don't compare it: the words may change

Naming a person#

Wherever an export takes a person, a bare number is a server id (the source you already hold) and { charId = n } is a character, online or not. A bare number is never a charId, except in exports whose name says so (GetCharacterProperties(charId)).

exports.whip_core:GivePropertyKey(propertyId, source)              -- the player in front of you
exports.whip_core:GivePropertyKey(propertyId, { charId = 42 })   -- a character, online or not
A server id must be online. To reach someone who may be offline, pass { charId = n }. Some calls need the person online either way (giving a car key, for example); their cards say so. A parameter named source is always a server id.

Finding one thing#

A lookup is one call, GetX(ref): an id, or a table with one key that says what you hold. A list is GetXs(filter?).

exports.whip_core:GetVehicle({ plate = 'ABC123' })
exports.whip_core:GetShop({ key = 'burgershot' })
exports.whip_core:GetPlayer({ charId = 42 })          -- online players only
exports.whip_core:GetShops({ job = 'burgershot' })

Two export gotchas#

Both come from FiveM, and neither errors where the mistake is.

1. A function passed through an export isn't type() == 'function'. It arrives as a callable reference. Calling it works; type-checking it rejects every caller. Matters when you write an export that takes a callback.

if type(fn) == 'function' then ... end   -- WRONG: false for every callback through an export
if fn ~= nil then pcall(fn, ...) end     -- RIGHT

2. A nil returned through an export arrives as no value at all. Nesting the call inside another call then passes no argument. Assign export results to a local first.

if type(exports.whip_core:GetVehicleData(id, 'key')) == 'table' then ... end   -- WRONG: errors when nil

local data = exports.whip_core:GetVehicleData(id, 'key')                       -- RIGHT
if type(data) == 'table' then ... end