saverestore.AddRestoreHook

From GMod Wiki

Jump to: navigation, search
Function
Syntax saverestore.AddRestoreHook( String Name, Function func )
Where is this used?
Description:
Adds a hook enabling a function to restore something when a save game is loaded.
Returns: nil
Part of Library: saverestore
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Saverestore.AddRestoreHook]Saverestore.AddRestoreHook [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionHooks a save and restore function to save my_table.
Used onNewerShared.png
Code
local function MySaveFunction( save )
   saverestore.WriteTable( my_table, save )
end
 
local function MyRestoreFunction( restore )
   my_table = saverestore.ReadTable( restore )
end
 
saverestore.AddSaveHook( "HookNameHere", MySaveFunction )
saverestore.AddRestoreHook( "HookNameHere", MyRestoreFunction )
 
OutputN/A


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox