View Single Post
Fortis
Junior Member
Join Date: Nov 2016
Old 10-14-2021 , 22:38   Re: MarkNativeAsOptional - inconvenient moment.
Reply With Quote #2

Quote:
Originally Posted by client21 View Post
But my goal is to create native "Test_z" with a delay.
I'm confused by what you mean here, you create natives in AskPluginLoad2 to ensure all other plugins on your server can use the native as long as they have the include file. You can mark natives as optional in the include file so if you unload the plugin you created the native in, the other plugins using it can still run and won't fail to load.

Example:

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",
#if defined REQUIRE_PLUGIN
    
required 1,
#else
    
required 0,
#endif
};

#if !defined REQUIRE_PLUGIN
public void __pl_z_SetNTVOptional()
{
    
MarkNativeAsOptional("Test_Z");
}
#endif 
z.sp
PHP Code:
#include <z>

public APLRes AskPluginLoad2(Handle myselfbool latechar[] errorint err_max)
{
    
CreateNative("Test_Z"Native_Z);
    return 
APLRes_Success;
}

public 
int Native_Z(Handle pluginint numParams)
{
    return 
0;
}

public 
void OnClientPostAdminCheck(int client)
{
    
int z Test_Z();

Any other plugin now can use the Test_Z native as long as its included

zz.sp
PHP Code:
#include <z>

public void OnClientPutInServer(int client)
{
    
int z Test_Z();


Last edited by Fortis; 10-16-2021 at 14:17.
Fortis is offline