• Hook.Call Args
    2 replies, posted
[QUOTE=wiki.garrysmod.com]hook.Call( string eventName, table gamemodeTable, vararg args )[/QUOTE] How do I put this into practice, when I have 2 variables to give to the function behind the hook? Lets say I have variable(s) a & b. They both must be sent through the hook.
varargs are a variable amount of arguments, meaning that you can give as many arguments you want after that argument, like so: [lua]hook.Call( "MyHook", "GAMEMODE", a, b, c, d )[/lua] Then your hooked function will be passed a, b, c and d, like so: [lua]hook.Add( "MyHook", "MyHookID", function( a, b, c, d ) print( a, b, c, d ) end )[/lua] It's a bit confusing to get the hang of using them in your own code, but [url=http://lua-users.org/wiki/VarargTheSecondClassCitizen]here's[/url] a little more information
Vararg means any number of arguments. So, [code]hook.Call( _, _, var1, var2, var3 )[/code]
Sorry, you need to Log In to post a reply to this thread.