AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How can make a include file with this native (https://forums.alliedmods.net/showthread.php?t=316299)

Saint Sinner 05-16-2019 03:21

How can make a include file with this native
 
Sorry guys i am beginner ... Can put here a little example how can make to work?


I have this native
Code:

public plugin_natives()
{
    register_library("knife_duels")
    register_native("is_user_in_duel","_is_user_in_duel")
}

public _is_user_in_duel(index)
{
    new id = get_param(1)
    if(!is_user_connected(id))
        return PLUGIN_CONTINUE
    if(is_in_duel[id] == 2)
        return PLUGIN_HANDLED
    return PLUGIN_CONTINUE
}

include

Code:

#if defined _knife_duels_included
  #endinput
#endif
#define _knife_duels_included

native _is_user_in_duel(index)

Plugin example
Code:

#include <knife_duels>

public plugin_connect(id)
{
    if(is_in_duel[id] == 2)
    {
        // something
    }
}


Natsheh 05-16-2019 03:37

Re: How can make a include file with this native
 
This should be inside the include

PHP Code:

#if defined _knife_duels_included
  #endinput
#endif
#define _knife_duels_included

native is_user_in_duel(index); 

And in the example plugin

PHP Code:

#include <knife_duels>

public plugin_connect(id)
{
    if(
is_user_in_duel(id))
    {
        
// something
    
}


Notice PLUGIN_CONTINUE, PLUGIN_HANDLED

Are constants 1st equal to 0 and 2th equal to 1

Saint Sinner 05-16-2019 07:03

Re: How can make a include file with this native
 
thanks !

But this native where can put becouse i have 2 plugins ? or not need them anymore? Or en the plugin base?

public plugin_natives()
{
register_library("knife_duels")
register_native("is_user_in_duel","_is_user_i n_duel")
}

JocAnis 05-16-2019 07:44

Re: How can make a include file with this native
 
if you are using two plugins only (one is reading (using native) from another) then i dont see a advantage of using .include file...about your last post..put that plugin_natives in 'main' plugin and in second plugin use
Code:

native is_user_in_duel( id )
above plugin_init()
or i missunderstood what you need

Saint Sinner 05-16-2019 08:21

Re: How can make a include file with this native
 
ok thanks


All times are GMT -4. The time now is 01:23.

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