[C++] GMod binary module question(s)

Hello.

I just compiled my first binary for GMod in C++, I have followed several tutorials including out-dated ones and made it working pretty quickly.
I run GMod, go to LAN, submit “lua_run_cl require(‘test’); lua_run_cl MsgN(TestFunction()); lua_run_cl MsgN(TestFunction(100.24));” into console and it replies to me just fine.
Okay. Now, I have some question(s). I don’t get the most of this, but I understand C++ itself.

Here are my questions:
Please tell me what is this useful for?
Why C++ module and not pure glua script (benefits of C++ module versus pure glua script)?
How can I “convert” glua script into C++ module (see glua code below)?

For my last question from above, for example, I want to convert the following glua code into C++ gmod module representation, if this is even possible (please describe C++ code with comments):
[LUA]if not CLIENT or SERVER then
return
end
local function shTickHooked()
local ply = LocalPlayer():GetEyeTrace().Entity
if not ply:IsPlayer() then
return
end
MsgN(ply:Nick())
end
hook.Remove(‘Tick’, ‘TestingTick’) – My tip: Remove previously loaded hook (if any exists, it wont throw error - it is good practise; I have spent some time debugging lots of glua codes).
hook.Add(‘Tick’, ‘TestingTick’, shTickHooked) – Now add a new hook (many devs forget to remove before add)[/LUA]
Above glua code was written out of my head (while I was writing this thread).
For the sake of sample, it will spam the “Nick”-name in developer console depending on player I aim at.

Thanks in advance.

A module is useful for speed and doing stuff not bound in lua.

Otherwise, trying to call lua code through a module make the performance not worth the trouble.
Modules also require the user to download and place them in a specific location, and can’t be in a workshop addon.

Binaries are more useful for servers in general.
Most peope would either
a) not trust that the dll is not malicious
b) be too stupid to install

Okay, thanks to both of you for your replies.
I don’t want to develop something malicious, I only want to learn about it.

I know, never implied that you would be.
But people usually don’t trust binaries :smiley:

Binary modules are not meant to replace lua scripts, they are meant to expand gmod’s lua library.
People have used binary modules to do stuff like unlimited file IO, controlling winamp, lua debugging, and accessing internal source engine stuff like cvars, networking, and other fun stuff.
As someone above me said, usually they are only used on servers, since you can’t use them clientside on your server unless you force people to manually download and install them.