• Module (dll) basics
    5 replies, posted
Hi I want to write a gmod module (dll) that does something simple like display text, just for understanding how it works. First, I did this simple example: [url]http://wiki.garrysmod.com/page/Setting_Visual_Studio_Up_for_Making_Binary_Modules[/url] Which resulted in gmcl_test_win32.dll. I put the this dll in ...\GarrysMod\garrysmod\lua\bin. Started gmod, opened a map, checked the console to see if there was any output connected to the dll running, ...nothing. When is the dll ran? When hl2.exe starts or when a map is opened? I'd like to know if the dll has been loaded ie a message on screen. The source of the dll is : #define GMMODULE #include "Interface.h" // Called when the module opens GMOD_MODULE_OPEN() { return 0; } // Called when the module closes GMOD_MODULE_CLOSE() { return 0; } can somebody add something simple to let me know the dll has been loaded please? or add a pause to GMOD_MODULE_OPEN and i'll check if that dll has been loaded by hl2.exe once i know this, i'll start learning and writing my module... but i'd like to know if it works 1st of all.
You have to load your module from lua using require("modulename") where modulename has to be the same as this: gmcl_modulename_win32.dll So in your case it would be require("test") Also to print a message you can obviously just use cout or printf in the GMOD_MODULE_OPEN() hook.
thanks for your info, very helpful. so something like: local function spawn( ply ) require("test") end hook.Add( "PlayerSpawn", "call dll", spawn )
[QUOTE=arustusername;49537206]thanks for your info, very helpful. so something like: local function spawn( ply ) require("test") end hook.Add( "PlayerSpawn", "call dll", spawn )[/QUOTE] Yeah, expect if the module is clientside you dont need to use playerspawn and its serverside hook. Remember to add print stuff to the module. Another way of testing it would be [CODE]lua_run_cl require("test") [/CODE] in clients console when sv_allowcslua is 1
^ thanks for the extra info, noted. i've tested it and it's loaded my dll fine. ^^ thanks again.
.
Sorry, you need to Log In to post a reply to this thread.