Character Lifecycle
A player connects, picks a character, plays, and logs out or leaves. Here's what your resource can rely on at each step, how WHIP saves, and the events it fires.
Connecting and loading
Joining needs a FiveM licence; banned players (by any identifier) are told the reason and when the ban ends. Everyone else gets an account (userId) and picks, makes or deletes a character, up to Config.MaxCharacters (4).
whip_core then loads the character, moves them to routing bucket 0, spawns the ped and syncs the world around them. The server's whip_core:player:loaded fires last: your "player ready" hook. The client's fires once the ped is in the world and the screen is back.
It isn't resent when your resource restarts, so also set up everyone already in from Whip.register (make setUp safe to run twice):
AddEventHandler('whip_core:player:loaded', function(e) setUp(e.source, e.player) end)
Whip.register(function()
for source, player in pairs(exports.whip_core:GetPlayers()) do setUp(source, player) end
end)Save system#
Changes take effect at once in memory and reach the database within about a second (Config.FlushInterval, 1000 ms). You write no saving code.
- One player action saves as one. A
SecureEventorSecureCallbackhandler is an action, and so is WHIP running your use handler, item action,onComplete, panel hook orAddActioncallback. All it saves lands in one transaction. - Move an item between players in one call,
StoreMove(fromAddr, toAddr);RemoveItemthenAddItemcan save as two. - Your own database writes join the transaction through
CommitWithAction. Before a plain oxmysql write, callSavePlayer(source).
| What | When it's written |
|---|---|
| Pockets, stashes, boots, health and armour, activity log | Within Config.FlushInterval, or when the action ends; both halves of a move together |
| Position, hunger, thirst, your saved stats | Every Config.PlayerPositionSaveInterval (30 s), if changed |
| Car stats (fuel, nitro…) and position | Every Config.VehicleStatsSaveInterval (15 s), or with the action |
| Car data, the bank, ground items | Immediately, with the running action's other saves |
| Logout and disconnect | At once; the next login waits for anything still owed |
restart whip_core | Every owed write is sent as it stops |
| txAdmin restart or shutdown | On txAdmin's warning, most important first. Set its Shutdown Notice Delay to 15 seconds |
A failed write isn't a failed action. The change stands and WHIP retries forever; after five failures it shows as stuck in /whipsaves, and that character can't load until it lands. If the database goes away, items lock until everything owed is written (BACK TO NORMAL in the console).
SetStat after payment and keep your own record. Hunger, thirst and your stats are the server's alone.Logging out and leaving
Logout (back to the character screen) and disconnect both save the character and any stash or boot they had open, close their panels (yours gets onClose if they were its last viewer), clock them off, end any escort, and fire whip_core:player:logout with why = 'logout' or 'disconnect'.
New characters
A new character starts with full needs, the other stats at their starting values, and Config.StartingBalance ($1000) in the bank, and loads into the appearance creator. Only that first load has e.newCharacter (and e.player.isNewCharacter) set, even if the creator reopens later: the hook for a starter car.
e.player.userId, or make it something that can't leave the character.Deleting a character
Only from the character screen. Nothing the character held is thrown away:
| What | After the delete |
|---|---|
| Homes they owned | For sale again with every key gone; furniture and stored items stay |
| Keys they held | Removed |
| Jobs | Left. A business they owned runs on unowned; reassign it in /whip → Economy → Jobs |
| Stashes locked to them | Contents stay; owner and lock are cleared |
| Cars and bank accounts | Unchanged; an admin can reassign them |
Clean up your own per-character data on whip_core:character:deleted, but any server resource can fire it, so first check if not exports.whip_core:IsCharacterDeleted(e.charId) then return end.
Events
| Server event | When | Payload |
|---|---|---|
whip_core:player:loaded | Character loaded and ready (same table on the client) | { source, charId, name, newCharacter, player } |
whip_core:player:logout | Logout or disconnect, after the save | { source, charId, player, why } |
whip_core:character:created | New character created | { source, charId } |
whip_core:character:deleted | Character deleted | { source, charId } |
whip_core:character:renamed | An admin renamed a character (source nil if offline) | { charId, source, firstName, lastName, name, oldName, by } |
The renamed player's game gets whip_core:player:renamed with { charId, firstName, lastName, name }.