saverestore.AddSaveHook

From GMod Wiki

Jump to: navigation, search
Function
Syntax saverestore.AddSaveHook( String Name, Function func )
Where is this used?
Description:
Adds a hook enabling a function to save something when the game is saved.
Returns: nil
Part of Library: saverestore
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Saverestore.AddSaveHook]Saverestore.AddSaveHook [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