Garry's Mod Wiki

Revision Difference

saverestore.AddSaveHook#512781

<function name="AddSaveHook" parent="saverestore" type="libraryfunc">⤶ <description>Adds a save hook for the Half-Life 2 save system. You can this to carry data through level transitions in Half-Life 2.</description>⤶ <realm>Shared</realm>⤶ <args>⤶ <arg name="identifier" type="string">The unique identifier for this hook.</arg>⤶ <arg name="callback" type="function">The function to be called when an engine save is being saved. It has one argument:&#xA;&#xA;&#xA;&lt;page&gt;ISave&lt;/page&gt; save - The save object to be used to write data to the save file that is being saved&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;You can also use those functions to save data:&#xA;&#xA;&#xA;&lt;page&gt;saverestore.WriteVar&lt;/page&gt;&#xA;&#xA;&#xA;&lt;page&gt;saverestore.WriteTable&lt;/page&gt;&#xA;&#xA;&#xA;&lt;page&gt;saverestore.SaveEntity&lt;/page&gt;</arg>⤶ </args>⤶ </function>⤶ ⤶ <example>⤶ <description>Example usage.</description>⤶ <code>⤶ saverestore.AddSaveHook( "HookNameHere", function( save )⤶ saverestore.WriteTable( { "test" }, save )⤶ end )⤶ </code>⤶ ⤶ </example>