View Single Post
BRU7US
Member
Join Date: Jul 2020
Location: Tatarstan, Kazan
Old 10-16-2022 , 07:04   Re: How to create properly a native for a bool value?
Reply With Quote #5

My way:

Code:

PHP Code:
bool RankedMatch false;

public 
APLRes AskPluginLoad2(Handle myselfbool latechar[] errorint err_max)
{
    
CreateNative("RankedMatch"Native_RankedMatch);
    
    
RegPluginLibrary("warmode");
    
    return 
APLRes_Success;
}

public 
any Native_RankedMatch(Handle pluginint numParams// "any" instead "int"
{
    return 
RankedMatch//or try "view_as<bool>(RankedMatch);"

Include:

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

native bool RankedMatch(); // "bool" instead "int"

public SharedPlugin __pl_warmode =
{
    
name "War mode",
    
file "warmode.smx",
#if defined REQUIRE_PLUGIN
    
required 1,
#else
    
required 0,
#endif
};

#if !defined REQUIRE_PLUGIN
public void __pl_warmode_SetNTVOptional()
{

    
MarkNativeAsOptional("RankedMatch");
}
#endif 
BRU7US is offline