Summary

Hooks

Called after Catwork has loaded the map entities; restores the saved books.
Called when an entity's menu option is chosen; opens or picks up a book.
Called when an entity's menu options are needed; adds View and Take to books.
Spawns the books saved for the current map.
Called after data is saved; saves the books.
Saves every cw_book on the map to the schema data.
Gives a placed book's item to a player and removes the book, or tells the player why it failed.

Hooks

PLUGIN:ClockworkInitPostEntity()

server gamemodes/cwhl2rp/plugins/books/plugin/sv_hooks.lua:28

Implements hook ClockworkInitPostEntity

Called after Catwork has loaded the map entities; restores the saved books.

PLUGIN:EntityHandleMenuOption(player, entity, option, arguments)

server gamemodes/cwhl2rp/plugins/books/plugin/sv_hooks.lua:17

Implements hook EntityHandleMenuOption

Called when an entity's menu option is chosen; opens or picks up a book.

View sends the ViewBook Cable message to open the book on the player's screen. Take gives the player the book's item and removes the entity, or tells them why it failed.

Parameters

  • player Player The player who chose the option
  • entity Entity The entity the option was chosen on
  • option String The option's display text
  • arguments String The option value, cw_bookView or cw_bookTake

PLUGIN:GetEntityMenuOptions(entity, options)

client gamemodes/cwhl2rp/plugins/books/plugin/cl_hooks.lua:9

Implements hook GetEntityMenuOptions

Called when an entity's menu options are needed; adds View and Take to books.

Parameters

  • entity Entity The entity the menu is for
  • options Map The menu options, display text to option value, modified in place

Spawns the books saved for the current map.

Restores each book's owner, position and angles, skips books whose item no longer exists and freezes the ones that were frozen when saved.

Implements hook PostSaveData

Called after data is saved; saves the books.

Saves every cw_book on the map to the schema data.

Writes plugins/books/<map> with each book's item, owner, position, angles and whether it can move.

PLUGIN:TakeBook(player, entity)

server gamemodes/cwhl2rp/plugins/books/plugin/sv_plugin.lua:15

Gives a placed book's item to a player and removes the book, or tells the player why it failed.

A book can only be taken once, however many requests arrive before the entity is gone.

Parameters

  • player Player The player picking the book up
  • entity Entity The cw_book entity

Defined in