Summary

Hooks

Adds an item to the garbage loot table.
Called to check whether garbage can spawn at a point; blocks it within 50 units of another pile.
Called after Catwork has loaded the map entities; loads the garbage spawn points.
Called to get how long a player takes to search garbage.
Called to get the progress bar to draw; shows the cleanup bar during the cleanup action.
Loads the garbage spawn points of the current map and makes each spawn as soon as possible.
Called every second; spawns garbage at the spawn points whose respawn delay has passed.
Called when a player finishes searching garbage; gives them what they found.
Saves the garbage spawn points of the current map to the schema data.
Spawns a garbage pile at a spawn point and remembers it as the point's pile.

Hooks

cwGarbage:AddItem(id, chance)

server gamemodes/cwhl2rp/plugins/garbage/plugin/sv_plugin.lua:66

Adds an item to the garbage loot table.

cwGarbage:AddItem('scrap_metal', 35)

Parameters

  • id String The item's unique ID
  • chance Number Percent chance to find the item when it is picked; values above 100 always succeed

cwGarbage:CanSpawnGarbage(position)

server gamemodes/cwhl2rp/plugins/garbage/plugin/sv_hooks.lua:42

Implements hook CanSpawnGarbage

Called to check whether garbage can spawn at a point; blocks it within 50 units of another pile.

Parameters

  • position Vector The spawn point's position

Returns

  • Boolean Whether the garbage can spawn

cwGarbage:ClockworkInitPostEntity()

server gamemodes/cwhl2rp/plugins/garbage/plugin/sv_hooks.lua:10

Implements hook ClockworkInitPostEntity

Called after Catwork has loaded the map entities; loads the garbage spawn points.

cwGarbage:GetGarbageTime(player)

server gamemodes/cwhl2rp/plugins/garbage/plugin/sv_hooks.lua:62

Implements hook GetGarbageTime

Called to get how long a player takes to search garbage.

The garbage_pickup_time config, less a second for every 10 points of Scavenger.

Parameters

  • player Player The player searching

Returns

  • Number The search time in seconds

cwGarbage:GetProgressBarInfo()

client gamemodes/cwhl2rp/plugins/garbage/plugin/cl_hooks.lua:7

Implements hook GetProgressBarInfo

Called to get the progress bar to draw; shows the cleanup bar during the cleanup action.

Returns

  • Map The bar's text, percentage and flash fields, or nil to show nothing

cwGarbage:LoadGarbageSpawnPoints()

server gamemodes/cwhl2rp/plugins/garbage/plugin/sv_plugin.lua:26

Loads the garbage spawn points of the current map and makes each spawn as soon as possible.

The list is rebuilt without the gaps that removed points left in older data.

Implements hook OneSecond

Called every second; spawns garbage at the spawn points whose respawn delay has passed.

A point only spawns when its last pile is gone and CanSpawnGarbage allows it, then waits for the garbage_respawn_delay config before the next pile. A point that something else blocks is looked at again five seconds later.

cwGarbage:PlayerTakeGarbage(player, entity)

server gamemodes/cwhl2rp/plugins/garbage/plugin/sv_hooks.lua:78

Implements hook PlayerTakeGarbage

Called when a player finishes searching garbage; gives them what they found.

Delays the respawn of the pile's spawn point and picks a random entry from cwGarbage.stored. The player finds it when a roll, lowered by their Scavenger attribute, is within the garbage_item_percentage config and a second roll is within the entry's chance. Very rare rolls give an RPG, 200 to 1500 cash or ten RPGs instead. Progresses Scavenger by 5.

Parameters

  • player Player The player who searched
  • entity Entity The cw_garbage pile

cwGarbage:SaveGarbageSpawnPoints()

server gamemodes/cwhl2rp/plugins/garbage/plugin/sv_plugin.lua:19

Saves the garbage spawn points of the current map to the schema data.

Writes plugins/garbage/<map>.

cwGarbage:SpawnGarbage(pointTable)

server gamemodes/cwhl2rp/plugins/garbage/plugin/sv_plugin.lua:40

Spawns a garbage pile at a spawn point and remembers it as the point's pile.

Parameters

  • pointTable Map The spawn point, with position and angles

Returns

  • Entity The pile, or nil when it could not be created

Defined in