--------------------------------
So I'm trying to create a function within an OOP class to use for a addhook.
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
function Hook:Create(hookName, args, ...) 	self.hooks[hookName] = true 	self.hookCallable[hookName] = { 		args = args, 		__callableName = '____'..hookName 	} 	loadstring('self.hookCallable['..hookName..'].__callableName = function ('..args..') end') 	addhook(hookName, 'Hook.hookCallable["'..hookName..'"].__callableName') end
This isn't working. Is there any way to create a function and use it for addhook within a method?
I've also tried this approach
1
loadstring('function ____'..hookName..'('..args..') end')
AFAIK, it does create the function and append it to the addhook but the addhook doesn't read the arguments, which is infact a STRING so it works with loadstring.
1
hook:Create('join', 'id')
And so, whenever someone joins, triggering the join hook, the cs2d addhook returns the error that the parameters are nil. How to do this?
edited 2×, last 20.02.18 05:48:48 pm