Raised This Month: $91 Target: $400
 22% 

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 , 12: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 show support ?
Want to check my plugins ?
Total donation count : 330,98 ChF.- (in 3+ years)

Last edited by Arkarr; 12-20-2017 at 13:01.
Arkarr is online now
neatek
AlliedModders Donor
Join Date: Jul 2010
Location: Russia
Old 12-20-2017 , 14: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 14:13.
neatek is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 12-20-2017 , 14: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 show support ?
Want to check my plugins ?
Total donation count : 330,98 ChF.- (in 3+ years)

Last edited by Arkarr; 12-20-2017 at 14:54.
Arkarr is online now
neatek
AlliedModders Donor
Join Date: Jul 2010
Location: Russia
Old 12-20-2017 , 14: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 15:03.
neatek is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 12-20-2017 , 15: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 show support ?
Want to check my plugins ?
Total donation count : 330,98 ChF.- (in 3+ years)
Arkarr is online now
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 12-20-2017 , 16: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 , 16: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.
__________________
Am I back? Well, we'll see.
Powerlord is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 12-20-2017 , 16: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 show support ?
Want to check my plugins ?
Total donation count : 330,98 ChF.- (in 3+ years)
Arkarr is online now
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 12-21-2017 , 18: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 , 18:32   Re: Plugin late load
Reply With Quote #10

Thank you for the sample !
__________________
Want to show support ?
Want to check my plugins ?
Total donation count : 330,98 ChF.- (in 3+ years)
Arkarr is online now
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 05:30.


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