What template to choose for the plugin ?
#1

What is the best template under 'Visual C++' in MVS08 to create a plugin, I usually just modify another plugin if I want to mess around with them (learning) but I decided to try it from scratch and have fallen at the first hurdle hahaha.

Also if there is a file which tells me what template has been used to create the previous ones could you point this out to me please !

Edit:

Hmm just noticed (sorry not been awake long) a 'project user options' file, it says stuff like:

Quote:

<Configurations>
<Configuration
Name="Debug|Win32"

It's the 'Win' bit which is messing with me now, is this "Visual C++ >> Win32 >> Win32 Project" and does this limit it to Windows only ?
Reply
#2

Same boat im in. I got the Helloworld plugin to compile, but only because you open the solution and press F7. I wish sources like Jacobs IRC plugin was like that.
Reply
#3

Heres what i do to create a new plugin.

Updated version with images here.

Also if you need a project file for any other plugin just ask and ill make one and send it to you.
Reply
#4

Awsome, very helpfull reply !

I'm off out right now for a few hours but when I get back I shall give it another go following your instructions, thanks for that dude I apreciate it.
Reply
#5

Minor thing, you can replace
Code:
#include "./SDK/amx/amx.h"
#include "./SDK/plugincommon.h"
by this
Code:
#include "SDK\\plugin.h"
This is useless it seem:
Code:
void **ppPluginData;
And all the logprintf part isn't really needed if you don't want your plugin to log in the server log file.
Reply
#6

Quote:
Originally Posted by 0rb
Minor thing, you can replace
Code:
#include "./SDK/amx/amx.h"
#include "./SDK/plugincommon.h"
by this
Code:
#include "SDK\\plugin.h"
And all the logprintf part isn't really needed if you don't want your plugin to log in the server log file.
Edited.
Reply
#7

Wicked! TY for this!
Reply
#8

Good stuff, worked first time with no problems, loaded fine and I got the message "My Plugin got loaded.".

Cheers for the info and help !
Reply
#9

Quote:
Originally Posted by JeNkStAX
Heres what i do to create a new plugin.

1) Open Microsoft Visual Studio (Or Microsoft Visual C++ if you have the Express edition).
2) When the program has loaded click File->New->Project.
3) Then when the New Project window appears select Win32 Console Application then click Ok.
4) When the Win32 Application Wizard appears click next.
5) Then under Application Type change it to DLL and under Additional Options select Empty Project then click Finish.
6) Then when the project has been created you should see the Solution Explorer
(If you dont then select View->Solution Explorer).
7) In the Solution Explorer right click My Plugin (Or your project name) and select Properties.
In the properties window select Configuration Properties->Linker->Input.
9) Now where it says Module definition file type main.def.
10) In the solution explorer right click My Plugin and click Add->New Item.
11) When the Add New Item window appears select Module-Definition File and enter main as a name for it.
(If you cant see Module-Definition File then select C++ File and name it main.def)
12) Now you should see main.def under Souce Files in the Solution Explorer (If not then expand Source Files).
13) Double click MyPlugin(Or your project name).def and copy the following into it.
Code:
EXPORTS
	Supports
	Load
	Unload
	AmxLoad
	AmxUnload
14) Now repeat steps 10 and 11 but this time select C++ File and name it main.cpp.
15) Now repeat step 12 but this time open main.cpp.
16) Now copy the following into main.cpp.
Code:
#include "./SDK/plugin.h"

typedef void (*logprintf_t)(char* format, ...);

logprintf_t logprintf;
void **ppPluginData;
extern void *pAMXFunctions;

PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports() 
{
	return SUPPORTS_VERSION | SUPPORTS_AMX_NATIVES;
}

PLUGIN_EXPORT bool PLUGIN_CALL Load( void **ppData ) 
{
	pAMXFunctions = ppData[PLUGIN_DATA_AMX_EXPORTS];
	logprintf = (logprintf_t)ppData[PLUGIN_DATA_LOGPRINTF];

	logprintf( "My Plugin got loaded." );
	return true;
}

PLUGIN_EXPORT void PLUGIN_CALL Unload( )
{
	logprintf( "My Plugin got unloaded." );
}

AMX_NATIVE_INFO MyProjectNatives[ ] =
{
	{ 0, 0 }
};

PLUGIN_EXPORT int PLUGIN_CALL AmxLoad( AMX *amx ) 
{
	return amx_Register( amx, MyProjectNatives, -1 );
}

PLUGIN_EXPORT int PLUGIN_CALL AmxUnload( AMX *amx ) 
{
	return AMX_ERR_NONE;
}
17) Copy the SDK folder from the Plugin SDK to your plugins folder.
1 In the Solution Explorer right click MyPlugin(Or your project name) and select Add->New Filter and name the new filter SDK.
19) Now right click the SDK filter and select Add->Existing Item.
20) Now browse to your plugin folder then open the SDK folder you just copied into there and select amxplugin.cpp.
1 You should now be able to compile your project with no Errors/Warnings.

Also if you need a project file for any other plugin just ask and ill make one and send it to you.
Great guide, i have been meaning to do something like this but never got around to it. This one deserves a sticky.
Reply
#10

I was thinking of posting it as a seperate topic and adding images but IDK.
Reply
#11

Would be good to have, without this post I would of been there for a while hehe.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)