Raised This Month: $ Target: $400
 0% 

Moving plugin to SourceMM


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sion
Junior Member
Join Date: Nov 2004
Old 05-20-2006 , 05:55   Moving plugin to SourceMM
Reply With Quote #1

First of all a big thank you to eveyone who has helped me thusfar with my plugin I am now in the process of moving it to SourceMM as a base.

My question is, is there any considerations I should be aware of when moving from the modified Valve example plugin in the SDK?

thanks again.
sion is offline
L. Duke
Veteran Member
Join Date: Apr 2005
Location: Walla Walla
Old 05-20-2006 , 14:17  
Reply With Quote #2

The one thing I would suggest is to remove the FireEvent hook in the sample_mm and instead inherit IGameEventListener2.

SamplePlugin.h
Code:
class SamplePlugin : public ISmmPlugin, public IMetamodListener, public IGameEventListener2
Code:
	// game event listener
	void FireGameEvent( IGameEvent *event );
SamplePlugin.cpp
Also, add your listener in AllPluginsLoaded() rather than Load()
Code:
	// add event listener from .res files
	// files:  ../hl2/resource/serverevents.res ../hl2/resource/gameevents.res  ../mod_directory/modevents.res  
	 m_GameEventManager->AddListener(this, "round_end", true);
Here is a modified version of the sample_mm plugin that has those changes made:
sample2_mm
L. Duke is offline
BAILOPAN
Join Date: Jan 2004
Old 05-20-2006 , 15:15  
Reply With Quote #3

If you rely on NetworkIDValidated(), you will find that there's no such callback for the GameDLL.

Most people implement it by placing all connected players into a list/queue. Then you hook GameFrame, and every frame, check if a player has a steamid yet. Once they do, remove them from the queue and call your own NetworkIDValidated routines.

FYI: It's a good idea to use g_SMAPI->pGlobals()->time or something, and limit your gameframe processing to every .5-1seconds.

(I'm sure someone has an example, unfortunately I don't at the moment.)
__________________
egg
BAILOPAN is offline
c0ldfyr3
AlliedModders Donor
Join Date: Aug 2005
Location: Ireland
Old 05-20-2006 , 22:11  
Reply With Quote #4

Quote:
Originally Posted by BAILOPAN
If you rely on NetworkIDValidated(), you will find that there's no such callback for the GameDLL.

Most people implement it by placing all connected players into a list/queue. Then you hook GameFrame, and every frame, check if a player has a steamid yet. Once they do, remove them from the queue and call your own NetworkIDValidated routines.

FYI: It's a good idea to use g_SMAPI->pGlobals()->time or something, and limit your gameframe processing to every .5-1seconds.

(I'm sure someone has an example, unfortunately I don't at the moment.)
OR...

Code:
void GameFrame()
{
     static int x = 0;
     x++;
     if ( x == 10 )
     {
          // CODE HERE
          x = 0;
     }
}
__________________
c0ldfyr3 is offline
Send a message via MSN to c0ldfyr3 Send a message via Yahoo to c0ldfyr3
showdax
Senior Member
Join Date: Dec 2004
Old 05-20-2006 , 22:19  
Reply With Quote #5

Quote:
Originally Posted by c0ldfyr3
Quote:
Originally Posted by BAILOPAN
If you rely on NetworkIDValidated(), you will find that there's no such callback for the GameDLL.

Most people implement it by placing all connected players into a list/queue. Then you hook GameFrame, and every frame, check if a player has a steamid yet. Once they do, remove them from the queue and call your own NetworkIDValidated routines.

FYI: It's a good idea to use g_SMAPI->pGlobals()->time or something, and limit your gameframe processing to every .5-1seconds.

(I'm sure someone has an example, unfortunately I don't at the moment.)
OR...

Code:
void GameFrame()
{
     int x;
     x++;
     if ( x == 10 )
     {
          // CODE HERE
          x = 0;
     }
}
Code:
int x = 0;

void GameFrame()
{
     if (x++ == 10)
     {
          x = 0;
     }
}
Pulling random numbers off the stack isn't really a good idea.
showdax is offline
Send a message via MSN to showdax
c0ldfyr3
AlliedModders Donor
Join Date: Aug 2005
Location: Ireland
Old 05-21-2006 , 00:05  
Reply With Quote #6

I corrected it, sorry im extremly drunk =P
__________________
c0ldfyr3 is offline
Send a message via MSN to c0ldfyr3 Send a message via Yahoo to c0ldfyr3
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 00:53.


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