Raised This Month: $ Target: $400
 0% 

[HELP] Question Related to Libraries


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Depresie
Veteran Member
Join Date: Nov 2013
Old 12-19-2015 , 15:00   [HELP] Question Related to Libraries
Reply With Quote #1

Can anyone explain to me what is this for and why is it usefull?

PHP Code:
#define LIBRARY_TYRANT "zp50_class_tyrant"
#include <zp50_class_tyrant>


public plugin_init()
{
    
register_plugin("[ZP] Admin Commands"ZP_VERSION_STRING"ZP Dev Team")
  
    
// Tyrant Class loaded?
    
if (LibraryExists(LIBRARY_TYRANTLibType_Library))
        
register_concmd("zp_tyrant""cmd_tyrant"_"<target> - Turn someone into a Tyrant"0)
    
}

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

public 
module_filter(const module[])

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

__________________
Depresie is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 01-02-2016 , 17:32   Re: [HELP] Question Related to Libraries
Reply With Quote #2

anyone can explain what are those libraries for? to know if it is worth to cut them out...
__________________
Depresie is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-02-2016 , 17:56   Re: [HELP] Question Related to Libraries
Reply With Quote #3

Are you asking why it filters natives?
__________________
Arkshine is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 01-02-2016 , 18:14   Re: [HELP] Question Related to Libraries
Reply With Quote #4

yep, im asking why mercylez decided to use define LIBRARY and the filter parts
__________________

Last edited by Depresie; 01-02-2016 at 18:16.
Depresie is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-02-2016 , 18:39   Re: [HELP] Question Related to Libraries
Reply With Quote #5

Likely this plugin relies on natives from third-party module, and to avoid plugin throwing an error at run-time because native/module doesn't exist, you can decide whether to ignore or not.
To make the plugin optional if you don't have the associated dependency.

From doc:

Quote:
* @note This is useful for creating plugins that can dynamically decide which
* modules or features to use at runtime, often necessary for cross-mod
* plugins. It allows to deploy a single version of the plugin instead
* of compiling multiple versions for each use-case.
__________________

Last edited by Arkshine; 01-02-2016 at 18:43.
Arkshine is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-03-2016 , 14:35   Re: [HELP] Question Related to Libraries
Reply With Quote #6

Quote:
Originally Posted by Arkshine View Post
Likely this plugin relies on natives from third-party module, and to avoid plugin throwing an error at run-time because native/module doesn't exist, you can decide whether to ignore or not.
__________________
fysiks is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 01-02-2016 , 18:54   Re: [HELP] Question Related to Libraries
Reply With Quote #7

So, they are there in case you don't have the plugin with the neccesary natives to not screw up, right?
so i can delete them if im planning to use all the plugins with the neccesary natives
__________________

Last edited by Depresie; 01-02-2016 at 18:57.
Depresie is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-02-2016 , 20:31   Re: [HELP] Question Related to Libraries
Reply With Quote #8

I'd recommend that you leave it there since you are not really understanding it. However, you could remove it and see what happens. If it breaks your plugin then put it back.
__________________
fysiks is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 01-02-2016 , 20:41   Re: [HELP] Question Related to Libraries
Reply With Quote #9

well, the addon im editing on, is zombie plague 5.0.. and it is made in pieces, that means it has around 70 plugins... as far as i know, after i delete the filters, all i should do is be careful at the checks ( if/switch/case )

i had an ideea what they do, but i wanted to know for sure

i realy want to get rid of them, mainly because there are many checks for the libraries
__________________

Last edited by Depresie; 01-02-2016 at 20:43.
Depresie is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 01-03-2016 , 13:19   Re: [HELP] Question Related to Libraries
Reply With Quote #10

Sorry for double post, is in this case the module and native filter only used because of the externaly natives? i think yes, but i want to be sure

PHP Code:
public plugin_natives() {
     
register_library("zp50_class_tyrant")
     
register_native("zp_class_tyrant_get""native_class_tyrant_get")
     
register_native("zp_class_tyrant_set""native_class_tyrant_set")
     
register_native("zp_class_tyrant_get_count""native_class_tyrant_get_count")
     
     
set_module_filter("module_filter")
     
set_native_filter("native_filter")
 }
 public 
module_filter(const module[])
 {
     if (
equal(moduleLIBRARY_GRENADE_FROST) || equal(moduleLIBRARY_GRENADE_FIRE))
         return 
PLUGIN_HANDLED;
     
     return 
PLUGIN_CONTINUE;
 }
 public 
native_filter(const name[], indextrap)
 {
     if (!
trap)
         return 
PLUGIN_HANDLED;
         
     return 
PLUGIN_CONTINUE;
 } 
__________________
Depresie 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 17:50.


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