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

Native Optional


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Starbish
AlliedModders Donor
Join Date: Oct 2011
Location: South Korea
Old 09-13-2015 , 01:08   Native Optional
Reply With Quote #1

i got a problem that a plugin which uses natives from another one gets error when another one is not loaded.

is there any ways to make this native not stop working without error when native is not registered?


Example :
if(LibraryExists("test1") && test2() || LibraryExists("test3") && test3())

without LibraryExists(), test2 and test3 will not work and make errors when test1 or test3 plugin is not registered on the library.

Last edited by Starbish; 09-13-2015 at 01:13.
Starbish is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 09-13-2015 , 02:06   Re: Native Optional
Reply With Quote #2

MarkNativeAsOptional in AskPluginLoad2.
Drixevel is offline
Starbish
AlliedModders Donor
Join Date: Oct 2011
Location: South Korea
Old 09-13-2015 , 02:46   Re: Native Optional
Reply With Quote #3

Quote:
Originally Posted by r3dw3r3w0lf View Post
MarkNativeAsOptional in AskPluginLoad2.
i already used that but it seems not working.

i called a function used that and it gets error that Native is out of bound?
__________________
Starbish is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 09-13-2015 , 03:38   Re: Native Optional
Reply With Quote #4

Quote:
Originally Posted by Starbish View Post
i already used that but it seems not working.

i called a function used that and it gets error that Native is out of bound?
Have you added a bool that's true if they exist or not OnPluginStart?
Drixevel is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-13-2015 , 04:10   Re: Native Optional
Reply With Quote #5

#undef REQUIRE_PLUGIN before you include the plugin in question.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 09-13-2015 at 04:10.
Powerlord is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 09-13-2015 , 05:16   Re: Native Optional
Reply With Quote #6

Quote:
Originally Posted by Powerlord View Post
#undef REQUIRE_PLUGIN before you include the plugin in question.
Me being the guy that assumed he did that already.
Drixevel is offline
Merudo
Senior Member
Join Date: Feb 2016
Old 02-26-2016 , 16:56   Re: Native Optional
Reply With Quote #7

Quote:
Originally Posted by redwerewolf View Post
Have you added a bool that's true if they exist or not OnPluginStart?
I know how to add a bool to check if the plugin is loaded.

However in future versions of the plugin, they may change the name of the native, or remove them completely (unlikely but possible).

Or, the plugin might only load halfway, because of incorrect signature files or something of the sort.

Is there another way to make sure the native is bound before called it?
Merudo is offline
splewis
Veteran Member
Join Date: Feb 2014
Location: United States
Old 02-26-2016 , 17:32   Re: Native Optional
Reply With Quote #8

Quote:
Originally Posted by Merudo View Post
I know how to add a bool to check if the plugin is loaded.

However in future versions of the plugin, they may change the name of the native, or remove them completely (unlikely but possible).

Or, the plugin might only load halfway, because of incorrect signature files or something of the sort.

Is there another way to make sure the native is bound before called it?
You should usually rely on plugins have a solid API, but you could use GetFeatureStatus w/ FeatureType_Native as the first parameter to check if a native exists.
__________________
splewis is offline
Merudo
Senior Member
Join Date: Feb 2016
Old 02-27-2016 , 15:12   Re: Native Optional
Reply With Quote #9

I use GetFeatureStatus but my users still report "Native is not bound" errors.

I don't know what to do.

Last edited by Merudo; 02-27-2016 at 15:12.
Merudo is offline
splewis
Veteran Member
Join Date: Feb 2014
Location: United States
Old 02-27-2016 , 17:05   Re: Native Optional
Reply With Quote #10

Quote:
Originally Posted by Merudo View Post
I use GetFeatureStatus but my users still report "Native is not bound" errors.

I don't know what to do.
There would have to be a MarkNativeAsOptional call for the natives you're referring to. Usually those are included in the plugin's .inc file that declares the native, but only if REQUIRE_PLUGIN is #undefine'd.
__________________
splewis 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 13:57.


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