Garry's Mod Wiki

Revision Difference

saverestore.AddRestoreHook#512803

<function name="AddRestoreHook" parent="saverestore" type="libraryfunc">⤶ <description>Adds a restore/load hook for the Half-Life 2 save system.</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 loaded. It has one argument:&#xA;&#xA;&#xA;&lt;page&gt;IRestore&lt;/page&gt; save - The restore object to be used to read data from save file that is being loaded&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;You can also use those functions to read data:&#xA;&#xA;&#xA;&lt;page&gt;saverestore.ReadVar&lt;/page&gt;&#xA;&#xA;&#xA;&lt;page&gt;saverestore.ReadTable&lt;/page&gt;&#xA;&#xA;&#xA;&lt;page&gt;saverestore.LoadEntity&lt;/page&gt;</arg>⤶ </args>⤶ </function>⤶ ⤶ <example>⤶ <description>Example usage.</description>⤶ <code>⤶ saverestore.AddRestoreHook( "HookNameHere", function( save )⤶ PrintTable( saverestore.ReadTable( save ) )⤶ end )⤶ </code>⤶ <output>⤶ If you used example from <page>saverestore.AddSaveHook</page>⤶ ⤶ ```⤶ 1 = Test⤶ ```⤶ ⤶ </output>⤶ ⤶ </example>