Events and state

Client events

The local client events fx-pocketbook fires for other resources, with their arguments and when they fire.

These are local events on the player's client. Listen with AddEventHandler. They are not network events: the server does not receive them.

luaAddEventHandler('fx-pocketbook:opened', function()
    HideMyHud()
end)
AddEventHandler('fx-pocketbook:closed', function()
    ShowMyHud()
end)
Event Arguments When
fx-pocketbook:ready version The notebook's interface finished loading and re-added the custom apps. version is the extension API version, 1.
fx-pocketbook:opened theme The notebook opened. theme is the colour number (0 to 14) of the book, or nil.
fx-pocketbook:closed none The notebook closed.
fx-pocketbook:customAppOpened id, owner A custom app came on screen. owner is the resource that registered it.
fx-pocketbook:customAppClosed id, owner A custom app left the screen, was removed, or the book closed while it was open.
fx-pocketbook:signalChanged bars The signal bars changed (0 to 5). It fires when the bars or the town change and once after the book opens, not on every update.

#Notes

  • Register your custom app again on fx-pocketbook:ready. It fires after a restart of fx-pocketbook, and the notebook forgets apps whose resource stopped.
  • customAppOpened and customAppClosed fire for every custom app. Always compare id with your own.
  • signalChanged fires when the bars or the town change and once after the book opens, not on every check. Keep the handler light.
lualocal MY_APP = 'ranch_ledger'
AddEventHandler('fx-pocketbook:customAppOpened', function(id)
    if id ~= MY_APP then return end
    -- start your timers
end)
AddEventHandler('fx-pocketbook:customAppClosed', function(id)
    if id ~= MY_APP then return end
    -- stop them
end)

The resource fires other events too (between its own client and server files). They are internal and may change without notice. Use the exports instead.