View Single Post
Author Message
client21
Senior Member
Join Date: Apr 2013
Old 10-14-2021 , 11:48   MarkNativeAsOptional - inconvenient moment.
Reply With Quote #1

z.inc

PHP Code:
#if defined _z_included
#endinput
#endif
#define _z_included

native int Test_z();

public 
SharedPlugin __pl_z 
{
    
name "z",
    
file "z.smx",
    
required 0
};

public 
void __pl_z_SetNTVOptional()
{
    
MarkNativeAsOptional("Test_z");

z.sp

PHP Code:
#include <z>

public void OnClientPostAdminCheck(int client)
{
    
bool b false;
    if (
b) {
        
Test_z();
    }

sm plugins load z.smx
[SM] Plugin z.smx failed to load: Native "Test_z" was not found.

If I rename z.smx to zz.smx (or other) then it works.

if I do:

PHP Code:
public APLRes AskPluginLoad2(Handle myselfbool latechar[] errorint err_max)
{
    
MarkNativeAsOptional("Test_z");
    return 
APLRes_Success;

in z.smx then it works.

Why public void __pl_z_SetNTVOptional() doesn't work for z.smx
Why am I forced to do AskPluginLoad2->MarkNativeAsOptional in z.smx

-----------------
It will work if in z.smx I do:

PHP Code:
public APLRes AskPluginLoad2(Handle myselfbool latechar[] errorint err_max)
{
    
CreateNative("Test_z"Test_z_);
    return 
APLRes_Success;
}

public 
int Test_z_(Handle pluginint args) {
    return 
0;

But my goal is to create native "Test_z" with a delay.
Apparently __pl_z_SetNTVOptional doesn't work because of the delay and I have to do MarkNativeAsOptional.
Anyway, I expected more from __pl_z_SetNTVOptional.

Last edited by client21; 10-14-2021 at 11:59.
client21 is offline