Raised This Month: $ Target: $400
 0% 

'Hybrid' Plugin?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 09-22-2021 , 04:41   Re: 'Hybrid' Plugin?
Reply With Quote #1

it is possible and you have 2 way:
1. Using Module filter and check libary zp50_core (since it usually there) and then use Native Filter to prevent an error throw at you when you check zp_get_user_zombie. After that, you can just check Libary to see if they are running ZP or not

PHP Code:
new bool:IsZPRunning false

public plugin_natives()
{
    
set_module_filter("module_filter")
    
set_native_filter("native_filter")
}
public 
module_filter(const module[])
{
    if (
equal(module"zp50_core"))
        return 
PLUGIN_HANDLED;
    
    return 
PLUGIN_CONTINUE;
}
public 
native_filter(const name[], indextrap)
{
    if (!
trap)
        return 
PLUGIN_HANDLED;
    
    return 
PLUGIN_CONTINUE;
}

public 
plugin_init()
{
    if(
LibraryExists(LIBRARY_BUYMENUSLibType_Library)) 
        
IsZPRunning true //then just check it if to seprate ZP and Normal

This way will automatically swap between 2 mode without needing to edit it.
The downside is it not work with ZP 4.3 since ZP 4.3 was not used Library

2. Make a #define and make #if every time you need to separate between ZP and Normal. Here I used #if defined
PHP Code:
#define ZP_MODE 

#if defined ZP_MODE
    //Do ZP stuff
#else
    //Do Normal Stuff
#endif 
So you could just comment the #define to switch to other mode. Of course, the #else is optional.
But with this, you have to manually change and have to compile again.

P/S: I am not sure with filter way since I haven't try it yet but you could take look at ZP 5.0 Main Menu as example
P/S2: If you use native for plugins then the second one is more ideal since you have to register_native (which called before plugin_init)
__________________
My plugin:

Last edited by Celena Luna; 09-22-2021 at 05:03.
Celena Luna is offline
asdian
Member
Join Date: Sep 2016
Location: Indonesia
Old 09-22-2021 , 06:54   Re: 'Hybrid' Plugin?
Reply With Quote #2

Quote:
Originally Posted by Celena Luna View Post
it is possible and you have 2 way:
1. Using Module filter and check libary zp50_core (since it usually there) and then use Native Filter to prevent an error throw at you when you check zp_get_user_zombie. After that, you can just check Libary to see if they are running ZP or not

PHP Code:
new bool:IsZPRunning false

public plugin_natives()
{
    
set_module_filter("module_filter")
    
set_native_filter("native_filter")
}
public 
module_filter(const module[])
{
    if (
equal(module"zp50_core"))
        return 
PLUGIN_HANDLED;
    
    return 
PLUGIN_CONTINUE;
}
public 
native_filter(const name[], indextrap)
{
    if (!
trap)
        return 
PLUGIN_HANDLED;
    
    return 
PLUGIN_CONTINUE;
}

public 
plugin_init()
{
    if(
LibraryExists(LIBRARY_BUYMENUSLibType_Library)) 
        
IsZPRunning true //then just check it if to seprate ZP and Normal

This way will automatically swap between 2 mode without needing to edit it.
The downside is it not work with ZP 4.3 since ZP 4.3 was not used Library

2. Make a #define and make #if every time you need to separate between ZP and Normal. Here I used #if defined
PHP Code:
#define ZP_MODE 

#if defined ZP_MODE
    //Do ZP stuff
#else
    //Do Normal Stuff
#endif 
So you could just comment the #define to switch to other mode. Of course, the #else is optional.
But with this, you have to manually change and have to compile again.

P/S: I am not sure with filter way since I haven't try it yet but you could take look at ZP 5.0 Main Menu as example
P/S2: If you use native for plugins then the second one is more ideal since you have to register_native (which called before plugin_init)
how to use that native filter to prevent error with zp_ natives ?

Last edited by asdian; 09-22-2021 at 06:55.
asdian is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 09-22-2021 , 23:47   Re: 'Hybrid' Plugin?
Reply With Quote #3

Quote:
Originally Posted by asdian View Post
how to use that native filter to prevent error with zp_ natives ?
PHP Code:
new bool:IsZPRunning false //Boolean to check if ZP is running.

public plugin_natives()
{
    
set_native_filter("native_filter")
    
set_module_filter("module_filter")
}

public 
native_filter(const name[], indextrap)
{
    if(!
trap)
        return 
PLUGIN_HANDLED
    
    
return PLUGIN_CONTINUE
}

public 
module_filter(const module[])
{
    if (
equal(module"zp50_core"))
        return 
PLUGIN_HANDLED;
    
    return 
PLUGIN_CONTINUE;
}

public 
plugin_init()
{
    if(
LibraryExists("zp50_core"LibType_Library)) 
        
IsZPRunning true //if zp50_core loaded, plugin will be in ZP mode


//I will make example here when tanking damage
public fw_Player_TakeDamage(victiminflictorattackerFloat:DamageiDamageBits)
{
    if(
IsZPRunning)
    {
        if(
zp_core_is_zombie(id)
        {
             
//Do ZP stuff
            
SetHamParamFloat(42000.0)
        }
    }
    else
   {
       
//Do Normal CS Mode stuff
      
SetHamParamFloat(4100.0)
   }

If you want to know if there is a Libary, check the include file
Code:
#if AMXX_VERSION_NUM >= 175     #pragma reqlib zp50_core     #if !defined AMXMODX_NOAUTOLOAD         #pragma loadlib zp50_core     #endif #else     #pragma library zp50_core #endif

Because zombieplague.inc doesn't have libary, it can't be check this way.
__________________
My plugin:

Last edited by Celena Luna; 09-22-2021 at 23:53.
Celena Luna is offline
asdian
Member
Join Date: Sep 2016
Location: Indonesia
Old 09-23-2021 , 02:38   Re: 'Hybrid' Plugin?
Reply With Quote #4

Quote:
Originally Posted by Celena Luna View Post
PHP Code:
new bool:IsZPRunning false //Boolean to check if ZP is running.

public plugin_natives()
{
    
set_native_filter("native_filter")
    
set_module_filter("module_filter")
}

public 
native_filter(const name[], indextrap)
{
    if(!
trap)
        return 
PLUGIN_HANDLED
    
    
return PLUGIN_CONTINUE
}

public 
module_filter(const module[])
{
    if (
equal(module"zp50_core"))
        return 
PLUGIN_HANDLED;
    
    return 
PLUGIN_CONTINUE;
}

public 
plugin_init()
{
    if(
LibraryExists("zp50_core"LibType_Library)) 
        
IsZPRunning true //if zp50_core loaded, plugin will be in ZP mode


//I will make example here when tanking damage
public fw_Player_TakeDamage(victiminflictorattackerFloat:DamageiDamageBits)
{
    if(
IsZPRunning)
    {
        if(
zp_core_is_zombie(id)
        {
             
//Do ZP stuff
            
SetHamParamFloat(42000.0)
        }
    }
    else
   {
       
//Do Normal CS Mode stuff
      
SetHamParamFloat(4100.0)
   }

If you want to know if there is a Libary, check the include file
Code:
#if AMXX_VERSION_NUM >= 175     #pragma reqlib zp50_core     #if !defined AMXMODX_NOAUTOLOAD         #pragma loadlib zp50_core     #endif #else     #pragma library zp50_core #endif

Because zombieplague.inc doesn't have libary, it can't be check this way.
i see...
PHP Code:
if (equal(module"zp50_core")) 
is 'module' code meant the .sma ?
asdian is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 09-23-2021 , 03:27   Re: 'Hybrid' Plugin?
Reply With Quote #5

Quote:
Originally Posted by asdian View Post
i see...
PHP Code:
if (equal(module"zp50_core")) 
is 'module' code meant the .sma ?
I am not sure but I think it is also referring to the library.
__________________
My plugin:
Celena Luna is offline
asdian
Member
Join Date: Sep 2016
Location: Indonesia
Old 09-23-2021 , 05:15   Re: 'Hybrid' Plugin?
Reply With Quote #6

Quote:
Originally Posted by Celena Luna View Post
I am not sure but I think it is also referring to the library.
the .inc ?
asdian is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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