Garry's Mod Wiki

Revision Difference

Entity:CallOnRemove#547796

<function name="CallOnRemove" parent="Entity" type="classfunc"> <description> Causes a specified function to be run if the entity is removed by any means. This can later be undone by <page>Entity:RemoveCallOnRemove</page> if you need it to not run. <bug issue="4675">This hook is called during clientside full updates. See <page>ENTITY:OnRemove#clientsidebehaviourremarks</page> for more information.</bug> <bug pull="1275">Using players with this function will provide a gimped entity to the callback.</bug> </description> <realm>Shared</realm> <file line="96-L108">lua/includes/extensions/entity.lua</file> <file line="108-L120">lua/includes/extensions/entity.lua</file> <args> <arg name="identifier" type="string">Identifier of the function within CallOnRemove</arg> <arg name="removeFunc" type="function">Function to be called on remove</arg> <arg name="argn..." type="vararg">Optional arguments to pass to removeFunc. Do note that the first argument passed to the function will always be the entity being removed, and the arguments passed on here start after that.</arg> </args> </function> <example> <description>Stops an engine sound when the entity is removed</description> <code>Entity:CallOnRemove("StopEngineSound",function(ent) ent:StopSound( "enginenoise.wav" ) end)</code> </example>