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

Plugin late load


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 12-20-2017 , 11:58   Plugin late load
Reply With Quote #1

Hey !

I have a small problem.
I have a main plugin, wich is required for module to run. The problem is that the module load first because the name is "shorter" than the main plugin :

ASteambot_Core (MAIN plugin)
ASteambot_Chat (MODULE)

ASteambot_Chat load before ASteambot_Core and ASteambot_Core is unable to send that to that plugin.
__________________
Want to check my plugins ?

Last edited by Arkarr; 12-20-2017 at 12:01.
Arkarr is offline
neatek
AlliedModders Donor
Join Date: Jul 2010
Location: Russia
Old 12-20-2017 , 13:13   Re: Plugin late load
Reply With Quote #2

Maybe this? (in core plugin)
PHP Code:
void OnPluginStart() {
    
ServerCommand("sm plugins reload YourModule.smx");

Or why not just rename file.
__________________

Last edited by neatek; 12-20-2017 at 13:13.
neatek is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 12-20-2017 , 13:53   Re: Plugin late load
Reply With Quote #3

Quote:
Originally Posted by neatek View Post
Maybe this? (in core plugin)
PHP Code:
void OnPluginStart() {
    
ServerCommand("sm plugins reload YourModule.smx");

Or why not just rename file.
Because, again, that's dirty code.

EDIT:
Plus, the point of modules is to be COMPLETLY independant from the core plugin. It should only use it. Not the other way around.
__________________
Want to check my plugins ?

Last edited by Arkarr; 12-20-2017 at 13:54.
Arkarr is offline
neatek
AlliedModders Donor
Join Date: Jul 2010
Location: Russia
Old 12-20-2017 , 13:54   Re: Plugin late load
Reply With Quote #4

Quote:
Originally Posted by Arkarr View Post
Because, again, that's dirty code.
Of course. Do you have any other ideas?

Maybe place modules in folder for ex: ASteamBot/modules.smx and maybe they will load later?
__________________

Last edited by neatek; 12-20-2017 at 14:03.
neatek is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 12-20-2017 , 14:22   Re: Plugin late load
Reply With Quote #5

Quote:
Originally Posted by neatek View Post
Of course. Do you have any other ideas?

Maybe place modules in folder for ex: ASteamBot/modules.smx and maybe they will load later?
Nope, that's why I asked here haha... !
__________________
Want to check my plugins ?
Arkarr is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 12-20-2017 , 15:32   Re: Plugin late load
Reply With Quote #6

There is no guarantee what order SM plugins are loaded in, your best solution is to write your code to handle ANY load order.
__________________
WildCard65 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 12-20-2017 , 15:32   Re: Plugin late load
Reply With Quote #7

The OnAllPluginsLoaded hook exists for a reason. Just have your modules set to not do anything until it's called.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 12-20-2017 , 15:43   Re: Plugin late load
Reply With Quote #8

Quote:
Originally Posted by Powerlord View Post
The OnAllPluginsLoaded hook exists for a reason. Just have your modules set to not do anything until it's called.
Indeed, but I didn't know about it. Oh well, should have thought about it.
Thank you!
__________________
Want to check my plugins ?
Arkarr is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 12-21-2017 , 17:23   Re: Plugin late load
Reply With Quote #9

Something like:

PHP Code:
bool g_bCoreLoaded false;

public 
OnAllPluginsLoaded()
{
    if (
LibraryExists("some_fancy_core"))
    {
        
g_bCoreLoaded true;
    }
}

public 
void OnLibraryAdded(const char[] name)
{
    if (
StrEqual(name"some_fancy_core"))
    {
        
g_bCoreLoaded true;
    }
}

public 
void OnLibraryRemoved(const char[] name)
{
    if (
StrEqual(name"some_fancy_core"))
    {
        
g_bCoreLoaded false;
    }
}

public 
YourFancyFunctionHere()
{
    if (
g_bCoreLoaded) {
        
/* YAY! We got our core, ... do what you need to do here! */
    
}
    else
    {
        
/* Ohhh no, core is missing, do what you need to do here! */
    
}

__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 12-21-2017 , 17:32   Re: Plugin late load
Reply With Quote #10

Thank you for the sample !
__________________
Want to check my plugins ?
Arkarr is offline
Reply


Thread Tools
Display Modes

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 02:46.


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