Summary
Hooks
cleanup action.Hooks
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
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
Implements hook ClockworkInitPostEntity
Called after Catwork has loaded the map entities; loads the garbage spawn points.
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
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,percentageandflashfields, ornilto show nothing
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:78Implements 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_garbagepile
Saves the garbage spawn points of the current map to the schema data.
Writes plugins/garbage/<map>.
Spawns a garbage pile at a spawn point and remembers it as the point's pile.
Parameters
- pointTable Map The spawn point, with
positionandangles
Returns
- Entity The pile, or
nilwhen it could not be created