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

SetNTVOptional() isn't being called automatically?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 09-27-2018 , 22:17   SetNTVOptional() isn't being called automatically?
Reply With Quote #1

What could cause my SetNTVOptional() to not call automatically?
I made sure I have the #include for it, made sure I undefined REQUIRE_PLUGIN before including and set required to 0 in SharedPlugin.

Getting "native X not found" unless I manually call the SetNTVOptional() function in AskPluginLoad2. Which is weird as I only get the error for 1 native.
__________________
retired
shavit is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 09-27-2018 , 22:39   Re: SetNTVOptional() isn't being called automatically?
Reply With Quote #2

It won't be called if you named it incorrectly.
Fyren is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 09-28-2018 , 03:12   Re: SetNTVOptional() isn't being called automatically?
Reply With Quote #3

Quote:
Originally Posted by Fyren View Post
It won't be called if you named it incorrectly.
My naming seems correct though.

Plugin file name is shavit-core.

.inc
Code:
public SharedPlugin __pl_shavit =
{
	name = "shavit",
	file = "shavit-core.smx",
#if defined REQUIRE_PLUGIN
	required = 1
#else
	required = 0
#endif
};

#if !defined REQUIRE_PLUGIN
public void __pl_shavit_SetNTVOptional()
{
	MarkNativeAsOptional("Shavit_Rankings_DeleteMap");
}
.sp
Code:
#undef REQUIRE_PLUGIN
#include <shavit>
__________________
retired
shavit is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 09-28-2018 , 03:52   Re: SetNTVOptional() isn't being called automatically?
Reply With Quote #4

Using your first block (with an #endif and native void Shavit_Rankings_DeleteMap();) and the following code, the plugin loads fine for me:

PHP Code:
#undef REQUIRE_PLUGIN
#include "shavit"

public void OnPluginStart() {
        
int x 0;
        if (
xShavit_Rankings_DeleteMap();


Last edited by Fyren; 09-28-2018 at 03:53.
Fyren is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 09-28-2018 , 04:10   Re: SetNTVOptional() isn't being called automatically?
Reply With Quote #5

Quote:
Originally Posted by Fyren View Post
Using your first block (with an #endif and native void Shavit_Rankings_DeleteMap();) and the following code, the plugin loads fine for me:

PHP Code:
#undef REQUIRE_PLUGIN
#include "shavit"

public void OnPluginStart() {
        
int x 0;
        if (
xShavit_Rankings_DeleteMap();

That's just weird.. it doesn't for me from the shavit-core plugin, but it does run it from other plugins. Is there a limit for how many plugins can use a SharedPlugin? I have multiple plugins' natives in a single .inc

Edit: I found that the issue is gone as soon as I remove the file = "file name", part in the SharedPlugin struct. Is that a bug?
__________________
retired

Last edited by shavit; 09-28-2018 at 04:20.
shavit is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 09-28-2018 , 15:34   Re: SetNTVOptional() isn't being called automatically?
Reply With Quote #6

If you can post code with everything cut out of it possible that still has the problem, we'll look into it.
Fyren is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 09-29-2018 , 11:23   Re: SetNTVOptional() isn't being called automatically?
Reply With Quote #7

Quote:
Originally Posted by shavit View Post
.sp
Code:
#undef REQUIRE_PLUGIN
#include <shavit>
If the code (dependency) is indeed "optional", e.g. not required, I would in the above code do:

Code:
#tryinclude
__________________
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
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 09-29-2018 , 17:44   Re: SetNTVOptional() isn't being called automatically?
Reply With Quote #8

#tryinclude isn't very useful. If the include is missing, then you can't have any mention of its declared stuff or the compile will fail. You'd end up wrapping everything in #ifs to deal with it and then the resulting binary will not optionally use the other plugin if the include was missing at compile-time.
Fyren 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 12:38.


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