Theme
Exports & events
Return convention
Server exports return the value on success, or false and an error code when a rule refuses the call. Codes are stable strings (insufficient_funds, too_heavy, …); a French text for each is in wf_core/client/locale.lua.
lua
local ok, err = exports.wf_inventory:AddItem(source, "water", 2)
if not ok then print("refused: " .. err) endIn inventory exports, ref is either a player id (that player's loaded character) or an inventory id string ("stash:police_armory", "trunk:ABC_123", "char:12").
wf_core server exports
| Export | Returns |
|---|---|
GetPlayer(source) | character view (below) or nil |
GetPlayers() | ids of players with a loaded character |
GetPlayerByCharacter(charId) | player id or nil |
GetIdentifier(source) | "wfx:…" / "guest:…" |
GetMoney(source, account) | balance (account = "cash" or "bank") |
AddMoney(source, account, amount, reason?) | new balance |
RemoveMoney(source, account, amount, reason?) | new balance |
SetMoney(source, account, amount, reason?) | new balance |
TransferBank(from, to, amount, reason?) | true |
SetJob(source, job, grade?) | true |
GetJobs() | the jobs table |
GetStatus(source, name?) | one need (0–100) or all of them |
SetStatus(source, name, value) / AddStatus(source, name, delta) | new value |
SetDuty(source, onDuty) | new state (false, "no_job" when unemployed) |
IsOnDuty(source) | boolean |
SetGroup(source, name, grade?) / RemoveGroup(source, name) | true |
HasPermission(source, permission) | boolean — WFramework groups or server ACE |
AddAccountGroup(source, group) / RemoveAccountGroup(source, group) | true |
SavePlayer(source) | true if the position was saved |
GetAppearance(source) | appearance object |
SetAppearance(source, appearance, merge?) | true |
AllowAppearanceEdit(source, on?) | true — lets the client send its appearance once |
Notify(source, text, type?) | true |
Character view:
lua
{
id = 12, firstname = "Ana", lastname = "Lopez", dob = "1991-02-03", sex = "f",
money = { cash = 500, bank = 2500 },
job = { name = "police", label = "Police de Bolivie", grade = 1, gradeLabel = "Agent", salary = 300, boss = false },
groups = { cartel_sb = 2 },
coords = { x = 0.0, y = 0.0, z = 0.0, h = 0.0 },
}wf_inventory server exports
| Export | Returns |
|---|---|
Items(name?) | one item definition, or all |
AddItem(ref, name, count, metadata?, slot?) | true |
RemoveItem(ref, name, count, metadata?, slot?) | true |
CanCarryItem(ref, name, count, metadata?) | boolean |
GetItemCount(ref, name, metadata?) | number |
Search(ref, name) | list of slots holding the item |
GetSlot(ref, slot) | slot data or nil |
SetMetadata(ref, slot, metadata) | true |
ClearInventory(ref) | true |
GetInventory(ref) | inventory view { id, type, label, slots, maxWeight, weight, items } |
RegisterStash({ id, label?, slots?, maxWeight?, owner?, groups?, coords? }) | "stash:<id>" |
GetTrunk(plate) | "trunk:<PLATE>" |
OpenInventory(source, type, id) | true — opens it on the player's screen |
CloseInventory(source) | true |
RegisterUsableItem(name, function(source, item, slot) end) | true |
GetLoadout(source) | equipped weapons [{ slot, name, label, weapon, ammo, serial }] |
ToggleWeapon(source, slot) | true if now equipped |
Slot data: { slot, name, label, count, weight, metadata, image, stack, usable } (weight = total of the stack).
Server events (for Lua server scripts)
| Event | Arguments |
|---|---|
wf:playerLoaded | source, character |
wf:playerUnloaded | source, charId |
wf:moneyChanged | source, account, balance, delta, reason |
wf:jobChanged | source, job, old |
wf:dutyChanged | source, onDuty |
wf:statusChanged | source, status, changedNames |
wf:statusEmpty | source, name — a need reached 0 |
wf:groupChanged | source, name, grade (nil = removed) |
wf:appearanceChanged | source, appearance |
wf_inventory:loadoutChanged | source, loadout |
wf_inventory:usedItem | source, name, slot, data |
Client events (for Lua client scripts)
| Event | Arguments |
|---|---|
wf:client:playerLoaded | character |
wf:client:playerUnloaded | — |
wf:client:moneyChanged | account, balance, delta |
wf:client:jobChanged | job |
wf:client:dutyChanged | onDuty |
wf:client:statusChanged | status |
wf:client:loadoutChanged | loadout |
Client exports
They read the client's copy and are for display only: decisions belong to the server.
| Export | Returns |
|---|---|
wf_core:GetPlayerData() | character view (as on the server) or nil |
wf_core:IsLoaded() | boolean |
wf_core:IsOnDuty() | boolean |
wf_core:GetStatus(name?) | one need or all of them |
wf_core:GetLoadout() | equipped weapons |
wf_core:GetAppearance() | appearance object |
wf_core:UI() | the WFramework UI layer (notify(text), list(scene, def), available()) |
wf_core:ErrorText(code) | French text for an error code |
wf_inventory:GetPlayerItems() | non-empty slots of the player's inventory |
wf_inventory:GetItemCount(name) | number |
wf_inventory:GetDrops() | [{ id, coords }] |
Network messages
Client → server (intentions, all validated):
| Event | Arguments |
|---|---|
wf:requestCharacters · wf:logout | — |
wf:selectCharacter · wf:deleteCharacter | charId |
wf:createCharacter | { firstname, lastname, dob, sex } |
wf:giveCash | target, amount |
wf:saveAppearance | appearance (only after AllowAppearanceEdit) |
wf_inventory:ammo | serial, rounds (only a decrease is accepted) |
wf_inventory:move | { from = "player"|"secondary", fromSlot, to, toSlot, count? } |
wf_inventory:give | target (0 = nearest player, chosen by the server), slot, count? |
wf_inventory:drop | slot, count? |
wf_inventory:use | slot |
wf_inventory:openNearby · wf_inventory:close · wf_inventory:refresh | — |
Server → client:
| Event | Arguments |
|---|---|
wf:characters | list, maxCharacters |
wf:playerLoaded · wf:playerUnloaded | character / — |
wf:spawn | { coords, appearance, loadout } — strip campaign gear, apply outfit, teleport |
wf:applyAppearance · wf:applyLoadout | appearance / loadout |
wf:setMoney · wf:setJob · wf:setGroup · wf:setDuty · wf:setStatus | { account, delta, balance } / job / name, grade / onDuty / { hunger, thirst… } |
wf:notify | { type, text? , code? } |
wf_inventory:init | { inventory, items, drops } |
wf_inventory:update | { side, id, weight, maxWeight, slots } — only the changed slots |
wf_inventory:open · wf_inventory:closed | { player, secondary } / id |
wf_inventory:drops | [{ id, coords }] |