Raised This Month: $12 Target: $400
 3% 

Optional dependencies


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 02-03-2016 , 11:45   Optional dependencies
Reply With Quote #1

If I add this line in to my plugin:
#include <cURL>
It always requires this extension, even if it doesn't need it.
How can I disable this error for such cases?
L 02/03/2016 - 19:40:55: [SM] Unable to load plugin "test.smx": Required extension "curl" file("curl.ext") not running
and run the extension only when it necessary?
kadet.89 is offline
Send a message via Skype™ to kadet.89
Miu
Veteran Member
Join Date: Nov 2013
Old 02-03-2016 , 11:56   Re: Optional dependencies
Reply With Quote #2

Think you need to do #undef REQUIRE_EXTENSIONS before including curl.inc
Miu is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 02-03-2016 , 11:57   Re: Optional dependencies
Reply With Quote #3

put "
#undef REQUIRE_EXTENSIONS
"
right above the #include <cURL>
Edit: ninja'd

Last edited by Mitchell; 02-03-2016 at 11:57.
Mitchell is offline
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 02-03-2016 , 12:00   Re: Optional dependencies
Reply With Quote #4

Thanks, it works.
How to check if the extension is exist (is loaded) when the plugin requires it?

Last edited by kadet.89; 02-03-2016 at 12:11.
kadet.89 is offline
Send a message via Skype™ to kadet.89
Miu
Veteran Member
Join Date: Nov 2013
Old 02-03-2016 , 12:32   Re: Optional dependencies
Reply With Quote #5

https://sm.alliedmods.net/api/index....d=show&id=611& I suppose

eta: or https://sm.alliedmods.net/api/index....d=show&id=610&

Last edited by Miu; 02-03-2016 at 12:37.
Miu is offline
Impact123
Veteran Member
Join Date: Oct 2011
Location: Germany
Old 02-03-2016 , 15:09   Re: Optional dependencies
Reply With Quote #6

I would recommend to check if the native that you want to use exists
PHP Code:
// Place somewhere at the top
#define CURL_AVAILABLE() (GetFeatureStatus(FeatureType_Native, "curl_easy_init") == FeatureStatus_Available)

if (CURL_AVAILABLE())
{
    
// Curl is available

As far as i know the curl extension doesn't register itself as library and GetExtensionFileStatus would not work when someone renamed the extension file.
__________________

Last edited by Impact123; 02-03-2016 at 15:19.
Impact123 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 02-03-2016 , 15:45   Re: Optional dependencies
Reply With Quote #7

Properly written extensions and plugins (that have natives) register themselves as libraries so you can catch when they load and unload through global forwards.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 02-03-2016 at 15:46.
Powerlord is offline
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 02-04-2016 , 12:57   Re: Optional dependencies
Reply With Quote #8

Powerlord, it's not that case. But GetFeatureStatus works fine

Last edited by kadet.89; 02-04-2016 at 12:57.
kadet.89 is offline
Send a message via Skype™ to kadet.89
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 20:01.


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