AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Native Boolean? (https://forums.alliedmods.net/showthread.php?t=218549)

Unkolix 06-17-2013 14:51

Native Boolean?
 
I don't know how to call this, but I hope you will understand. Is it possible to set a bool so it will work on 2 plugins or even more?

I have a bhop plugin and I want to set a bool to true, when player has auto bhop.
I have another plugin (a menu) where, he can choose to turn bhop on/off.
And I want to make the menu kinda cool, when you turn the bhop on it will show "Turn bhop OFF" and opposite.

Bos93 06-17-2013 16:03

Re: Native Boolean?
 
PHP Code:

#include < amxmodx >

#define PLUGIN_NAME        "x"
#define PLUGIN_VERSION    "x"
#define PLUGIN_AUTHOR    "x"

new bool:g_bReturn;

public 
plugin_init( )
{
    
register_plugin 
    

        
PLUGIN_NAME
        
PLUGIN_VERSION
        
PLUGIN_AUTHOR 
    
);
}

public 
plugin_natives()
{
    
register_native("get_bReturn""_get_bReturn_");
}

public 
_get_bReturn_( )
{
    return 
g_bReturn;



Example for other plugins:

native bool:get_bReturn;

if( get_bReturn ) //code

ConnorMcLeod 06-17-2013 16:09

Re: Native Boolean?
 
You don't need native for this, use rather a xvar, there is a tutorial.
Or you can use a cvar, kindly the same.

Bos93 06-17-2013 16:21

Re: Native Boolean?
 
Yes,but

Quote:

Originally Posted by Arkshine (Post 1307686)
The speed is really trivial here and not worth to be mentioned. The choice should be more considering the user's preference or plugin design, not the speed. Just my opinion.


^SmileY 06-17-2013 16:42

Re: Native Boolean?
 
Get a cvar pointer -> get_cvar_pointer("cvar");

LOL

ConnorMcLeod 06-17-2013 16:43

Re: Native Boolean?
 
Means that no system is better than the other, so, using xvar doesn't require to build the native, only need to declare a public variable.

Unkolix 06-20-2013 06:47

Re: Native Boolean?
 
Quote:

Originally Posted by Bos93 (Post 1972193)
PHP Code:

#include < amxmodx >

#define PLUGIN_NAME        "x"
#define PLUGIN_VERSION    "x"
#define PLUGIN_AUTHOR    "x"

new bool:g_bReturn;

public 
plugin_init( )
{
    
register_plugin 
    

        
PLUGIN_NAME
        
PLUGIN_VERSION
        
PLUGIN_AUTHOR 
    
);
}

public 
plugin_natives()
{
    
register_native("get_bReturn""_get_bReturn_");
}

public 
_get_bReturn_( )
{
    return 
g_bReturn;



Example for other plugins:

native bool:get_bReturn;

if( get_bReturn ) //code

If I will use that like this?
PHP Code:

bool:get_bReturn[33];
public 
plugin_natives()
{
    
register_native("get_bReturn""_get_bReturn_");
}

public 
_get_bReturn_( )
{
    return 
g_bReturn;


Do I have to change something?

^SmileY 06-20-2013 07:09

Re: Native Boolean?
 
Quote:

Originally Posted by ConnorMcLeod (Post 1972223)
Means that no system is better than the other, so, using xvar doesn't require to build the native, only need to declare a public variable.


Unkolix 06-20-2013 07:13

Re: Native Boolean?
 
How will I set a xvar for a separate player? All I see is set a boolean true or false, that doesn't solve my problem.

EpicMonkey 06-20-2013 07:22

Re: Native Boolean?
 
http://forums.alliedmods.net/showpos...19&postcount=2


All times are GMT -4. The time now is 11:35.

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