Raised This Month: $32 Target: $400
 8% 

Metamod plugin writing


Post New Thread Reply   
 
Thread Tools Display Modes
w00tguy123
New Member
Join Date: Feb 2013
Old 02-13-2013 , 18:56   Re: Metamod plugin writing
Reply With Quote #11

I've found a solution to the problem!

First I downloaded a random plugin's source code (FakeFull on that page). MSVC converted the project for 2010, I changed the include directories to work with my setup and removed the custom build step. The project then built successfully and loaded properly with metamod-p. After that, I started ripping parts of code out of the project hoping to find some special code that breaks it. I was able to remove almost everything until the "GiveFnptrsToDll" function in "meta_api.cpp". The Module Definition File used by FakeFull needs this for some reason but I decided to delete it anyway and change the project settings around so that I could compile without errors. Finally, it wouldn't load with metamod-p.

Enough backstory, here's how to get the stub plugin working:
(replace each "YOUR_PROJ" with your project's name)

1) Create a file in your project directory called "YOUR_PROJ.def".

2) Put this inside of it:
Code:
LIBRARY YOUR_PROJ
EXPORTS
	GiveFnptrsToDll			@1
SECTIONS
	.data READ WRITE
3) Go into your project's settings and change this:
Linker->Input->Module Definition File->".\YOUR_PROJ.def"

4) Copy this function into your "meta_api.cpp" file:
Code:
void WINAPI GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals ) {
	memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t));
	gpGlobals = pGlobals;
}
5) Test it! I've attached my project files in case if it doesn't work for you. There may be some other project settings that you need changed.

Edit: I just realized this code was in h_export.cpp. I guess the definition file was the cause of the problem.
Attached Files
File Type: zip stub plugin msvc2010.zip (16.3 KB, 143 views)

Last edited by w00tguy123; 02-13-2013 at 19:55.
w00tguy123 is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 03-06-2013 , 16:45   Re: Metamod plugin writing
Reply With Quote #12

How to set folder ?

asm
inf
obj
Attached Thumbnails
Click image for larger version

Name:	Безымянный.png
Views:	259
Size:	74.3 KB
ID:	116721  
__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
abhishek_deshkar
Senior Member
Join Date: Jun 2013
Location: Earth
Old 12-24-2016 , 23:11   Re: Metamod plugin writing
Reply With Quote #13

Quote:
Originally Posted by w00tguy123 View Post
I've found a solution to the problem!

First I downloaded a random plugin's source code (FakeFull on that page). MSVC converted the project for 2010, I changed the include directories to work with my setup and removed the custom build step. The project then built successfully and loaded properly with metamod-p. After that, I started ripping parts of code out of the project hoping to find some special code that breaks it. I was able to remove almost everything until the "GiveFnptrsToDll" function in "meta_api.cpp". The Module Definition File used by FakeFull needs this for some reason but I decided to delete it anyway and change the project settings around so that I could compile without errors. Finally, it wouldn't load with metamod-p.

Enough backstory, here's how to get the stub plugin working:
(replace each "YOUR_PROJ" with your project's name)

1) Create a file in your project directory called "YOUR_PROJ.def".

2) Put this inside of it:
Code:
LIBRARY YOUR_PROJ
EXPORTS
	GiveFnptrsToDll			@1
SECTIONS
	.data READ WRITE
3) Go into your project's settings and change this:
Linker->Input->Module Definition File->".\YOUR_PROJ.def"

4) Copy this function into your "meta_api.cpp" file:
Code:
void WINAPI GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals ) {
	memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t));
	gpGlobals = pGlobals;
}
5) Test it! I've attached my project files in case if it doesn't work for you. There may be some other project settings that you need changed.

Edit: I just realized this code was in h_export.cpp. I guess the definition file was the cause of the problem.
I'm getting this error while compiling.

PHP Code:
Severity    Code    Description    Project    File    Line    Suppression State
Error    C2733    
'Meta_Query'second C linkage of overloaded function not allowed    w00tplug    C:\Users\abhis\Desktop\stub_plugin\meta_api.cpp    81 
Any solution ?
abhishek_deshkar is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 12-30-2016 , 06:59   Re: Metamod plugin writing
Reply With Quote #14

Quote:
Originally Posted by abhishek_deshkar View Post
I'm getting this error while compiling.

PHP Code:
Severity    Code    Description    Project    File    Line    Suppression State
Error    C2733    
'Meta_Query'second C linkage of overloaded function not allowed    w00tplug    C:\Users\abhis\Desktop\stub_plugin\meta_api.cpp    81 
Any solution ?
You have 2 incompatible declarations of Meta_Query, ensure that the implementation matches the header.
__________________
asherkin is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:01.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode