[MODULE] Engine Calls

This may sound dumb, But im new to this so excuse me. Im stuck trying to figure out how i can call GMod/Source/engine function from my module. I Have found some stuff on source sdk but everything is way outdated for me to use. Any links/help would be greatly appreciated. Thanks.

Download this folder and add it as an include directory (C/C++ > General > Additional Include Directories).

Download this folder and add any libs needed as dependencies (Linker > General > Additional Library Dependencies and Linker > Input).

Set C/C++ > Code Generation > Runtime Library to Multi-threaded (/MT).

Thanks, Helps alot. What headers should I include though? All of them, Or specific.

You don’t need to include anything other than whatever you’re gonna use. If you wanna just give it a test run and have it print a simple message, you can include tier0/dbg.h and use
[cpp]Msg("Hello world
That will print to the game console.

Thanks for the help, The functions show up as being defined but when ever I try to build using the function Msg(“Test”) inf my MODULE_OPEN it throws this error

You need to list tier0.lib as a dependency.

Wherever you saved tier0.lib, also put that directory in Linker > General > Additional Library Dependencies.

Now its complaining that is cannot open input file ‘tier0.lib’

Never mind I did it to /mp/src/lib by accident. I really apreciate your help man! One last thing though, Is there a wiki or documetation for source functions like the gmod wiki?

Other than the Valve Developer site, I don’t know.

AlliedModders is pretty helpful, I think, but it’s sort of targeted towards a specific mod. Good as a reference for info, though.

Alright, Well I cannot thank you enough, I had been here nearly 2 hours trying to solve this. Thank you!

[editline]23rd February 2016[/editline]

Hey man, Sorry to re-open this, Im trying to access the engine to excute a client console command. I have included these two files

#include "public/cdll_int.h"
#include "game/client/cdll_client_int.h"

Then I tried to do this

engine->ClientCmd("say Hello!

But it give me this error (I Have included all the libs in the lib folder)

You don’t need that second include. Show full code.

This is probably the way to go: https://github.com/glua/SourceSDK

Glua also has a base module, to make things more convenient: https://github.com/glua/module-base

Hopefully these still work.

This is what i do

You can’t use the global ‘engine’ defined in the source headers, you’ll need to find the class instance yourself. Specifically for that class, you can use Valve’s interface system.

// Sys_GetFactory, CreateInterfaceFn and VENGINE_CLIENT_INTERFACE_VERSION are defined in the SDK though VENGINE_CLIENT_INTERFACE_VERSION might be out of date
CreateInterfaceFn engineInterface = Sys_GetFactory( "engine.dll" );
IVEngineClient* myEngineRef = (IVEngineClient*)engineInterface( VENGINE_CLIENT_INTERFACE_VERSION, NULL );

He never said he wanted the warning function and you also included no typedef definition. And your function has no support for vararg parameters that Warning does - how is this useful to him?