Summary
Hooks
cwSalesmen.salesmen.plugins/salesmen/<map>.Hooks
cwSalesmen:ClockworkInitPostEntity()
server gamemodes/catwork/plugins/salesmen/plugin/sv_hooks.lua:7Implements 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:352Builds 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
- entity Entity The
cw_salesmanentity
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:25Implements 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_salesmanentity
Returns
- Boolean
falsewhen the player may not trade with the salesman, otherwisenil
cwSalesmen:PlayerUseSalesman(player, entity)
server gamemodes/catwork/plugins/salesmen/plugin/sv_hooks.lua:65Implements 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_salesmanentity
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:291Removes a salesman entity from the map and from cwSalesmen.salesmen.
Does not save; call cwSalesmen:SaveSalesmen afterwards.
Parameters
- entity Entity The
cw_salesmanentity
cwSalesmen:SalesmanTargetID(entity, x, y, alpha)
client gamemodes/catwork/plugins/salesmen/plugin/cl_plugin.lua:15Implements 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_salesmanentity - 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
trueto draw the salesman's name and description
Saves every valid salesman on the map to the schema data file plugins/salesmen/<map>.