AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Question Related to Libraries (https://forums.alliedmods.net/showthread.php?t=276342)

Depresie 12-19-2015 15:00

[HELP] Question Related to Libraries
 
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 01-02-2016 17:32

Re: [HELP] Question Related to Libraries
 
anyone can explain what are those libraries for? to know if it is worth to cut them out...

Arkshine 01-02-2016 17:56

Re: [HELP] Question Related to Libraries
 
Are you asking why it filters natives?

Depresie 01-02-2016 18:14

Re: [HELP] Question Related to Libraries
 
yep, im asking why mercylez decided to use define LIBRARY and the filter parts

Arkshine 01-02-2016 18:39

Re: [HELP] Question Related to Libraries
 
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.

Depresie 01-02-2016 18:54

Re: [HELP] Question Related to Libraries
 
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

fysiks 01-02-2016 20:31

Re: [HELP] Question Related to Libraries
 
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.

Depresie 01-02-2016 20:41

Re: [HELP] Question Related to Libraries
 
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

Depresie 01-03-2016 13:19

Re: [HELP] Question Related to Libraries
 
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 :P

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;
 } 


fysiks 01-03-2016 14:35

Re: [HELP] Question Related to Libraries
 
Quote:

Originally Posted by Arkshine (Post 2379263)
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.



All times are GMT -4. The time now is 17:50.

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