Summary

Hooks

Called after Catwork has loaded all map entities; spawns the salesmen saved for the current map.
Builds the saveable settings table of a salesman entity.
Spawns every salesman saved for the current map.
Called when a player attempts to use a salesman.
Called when a player uses a salesman; opens the trade menu on the player's client.
Called just after data is saved; saves the current map's salesmen.
Removes a salesman entity from the map and from cwSalesmen.salesmen.
Called when a salesman's target ID is painted; does nothing here.
Saves every valid salesman on the map to the schema data file plugins/salesmen/<map>.

Hooks

cwSalesmen:ClockworkInitPostEntity()

server gamemodes/catwork/plugins/salesmen/plugin/sv_hooks.lua:7

Implements hook ClockworkInitPostEntity

Called after Catwork has loaded all map entities; spawns the salesmen saved for the current map.

cwSalesmen:GetTableFromEntity(entity)

server gamemodes/catwork/plugins/salesmen/plugin/sv_plugin.lua:352

Builds the saveable settings table of a salesman entity.

The keys are name, cash, stock, model, angles, buyRate, factions, buyTab, sellTab, textTab, classes, position, physDesc, animation, priceScale, buyInShipments, showChatBubble and flags. cwSalesmen:LoadSalesmen and the SalesmanEdit command read this format.

Parameters

Returns

  • Map The salesman's settings

Spawns every salesman saved for the current map.

Reads plugins/salesmen/<map> from the schema data, creates a cw_salesman entity for each entry, restores its trade settings and makes it safe from removal. Replaces cwSalesmen.salesmen with the spawned entities; entries without a position, angles or model are skipped.

See also

cwSalesmen:PlayerCanUseSalesman(player, entity)

server gamemodes/catwork/plugins/salesmen/plugin/sv_hooks.lua:25

Implements hook PlayerCanUseSalesman

Called when a player attempts to use a salesman.

The player is refused when the salesman restricts factions or classes and the player's faction or class is not among them. When the salesman has flags set, having those flags (with - characters stripped) always allows use, and a flag string containing - refuses players without them. A refused player hears the salesman's noSale line. Return false to block the use.

Parameters

  • player Player The player using the salesman
  • entity Entity The cw_salesman entity

Returns

  • Boolean false when the player may not trade with the salesman, otherwise nil

cwSalesmen:PlayerUseSalesman(player, entity)

server gamemodes/catwork/plugins/salesmen/plugin/sv_hooks.lua:65

Implements hook PlayerUseSalesman

Called when a player uses a salesman; opens the trade menu on the player's client.

Sends the salesman's stock, prices, cash and restrictions with the Salesmenu Cable message and makes the salesman say its start line.

Parameters

  • player Player The player using the salesman
  • entity Entity The cw_salesman entity

Implements hook PostSaveData

Called just after data is saved; saves the current map's salesmen.

cwSalesmen:RemoveSalesman(entity)

server gamemodes/catwork/plugins/salesmen/plugin/sv_plugin.lua:291

Removes a salesman entity from the map and from cwSalesmen.salesmen.

Does not save; call cwSalesmen:SaveSalesmen afterwards.

Parameters

cwSalesmen:SalesmanTargetID(entity, x, y, alpha)

client gamemodes/catwork/plugins/salesmen/plugin/cl_plugin.lua:15

Implements hook SalesmanTargetID

Called when a salesman's target ID is painted; does nothing here.

The salesman draws its name and physical description only when a hook returns a true value.

Parameters

  • entity Entity The cw_salesman entity
  • x Number Horizontal position of the target ID
  • y Number Vertical position of the target ID
  • alpha Number Opacity of the target ID, from 0 to 255

Returns

  • Boolean Return true to draw the salesman's name and description

Saves every valid salesman on the map to the schema data file plugins/salesmen/<map>.

See also

Defined in