Raised This Month: $51 Target: $400
 12% 

fix 1 warning without effect the plugin function.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AGONN
Member
Join Date: Jan 2018
Old 03-05-2018 , 06:42   fix 1 warning without effect the plugin function.
Reply With Quote #1

hi , this plugin have 2 warnings :

Code:
// C:\Users\MAGIC INFO\Desktop\Compiler_AMXX\filewatcher.sma(91) : warning 213: tag mismatch
// C:\Users\MAGIC INFO\Desktop\Compiler_AMXX\filewatcher.sma(91) : warning 213: tag mismatch
i want to remove this warnings without effecting the plugin function.

Code:
#include <amxmodx> 
#include <orpheu> 

#define PLUGIN "File watcher" 
#define VERSION "0.2" 
#define AUTHOR "mazdan" 

#define f "file_watcher.log" 

new Array:aRule 
new Array:aFile 
new Array:aRuleType 

public plugin_init() 
{ 
    register_plugin(PLUGIN, VERSION, AUTHOR) 
    register_srvcmd("fw_add_file","file_add",_,"fw_add_file <ACCEPT | BLOCK> <filename>") 
    register_srvcmd("fw_rules","show_rules") 
    aRule=ArrayCreate(1,32) 
    aRuleType=ArrayCreate(1,32) 
    aFile=ArrayCreate(128,32) 
    server_cmd("exec filewatcher.cfg") 
    OrpheuRegisterHook(OrpheuGetFunction("FS_Open"),"FS_Open", OrpheuHookPre) 
} 



public OrpheuHookReturn:FS_Open(test[],b[]) 
{ 
    if(containi(b,"w")!=-1) 
    { 
        new rule 
        strtolower(test) 
        replace_all(test,strlen(test),"/","\") 
        new len=strlen(test) 
        new count=ArraySize(aFile) 
        for(new i;(i<count && !rule);i++) 
        { 
            new file[128] 
            ArrayGetString(aFile,i,file,127) 
            switch(ArrayGetCell(aRuleType,i)) 
            { 
                case 0:if(equal(test,file)) rule=i+1 
                    case 1:if(containi(test,file)==len-strlen(file)) rule=i+1 
                    case 2:if(containi(test,file)==0) rule=i+1 
                    case 3:if(containi(test,file)!=-1) rule=i+1 
                } 
        } 
        if(rule) 
        { 
            if(ArrayGetCell(aRule,--rule)) 
            { 
                log_to_file(f,"Rule [#%d] ACCEPT %s",rule,test) 
                return OrpheuIgnored; 
            } 
            else 
            { 
                log_to_file(f,"Rule [#%d] BLOCK %s",rule,test) 
                return OrpheuSupercede; 
            } 
        } 
        else 
        { 
            log_to_file(f,"No rule BLOCK %s",test) 
            return OrpheuSupercede; 
        } 
    } 
    return OrpheuIgnored; 
} 


public file_add() 
{ 
    new rule[10] 
    new file[128] 
    read_argv(1,rule,9) 
    read_argv(2,file,127) 
    if(!equal(rule,"ACCEPT") && !equal(rule,"BLOCK")) 
    { 
        log_to_file(f,"RULE ADD ERROR use <ACCEPT | BLOCK>") 
        console_print(0,"RULE ADD ERROR use <ACCEPT | BLOCK>") 
        return PLUGIN_HANDLED; 
    } 
    if(strlen(file)<1) 
    { 
        log_to_file(f,"RULE ADD ERROR ^" ^" to specify filename") 
        console_print(0,"RULE ADD ERROR ^" ^" to specify filename") 
        return PLUGIN_HANDLED; 
    } 
    ArrayPushCell(aRule,equal(rule,"ACCEPT")) 
    ArrayPushCell(aRuleType,((file[0]==42) + 2*(file[strlen(file)-1]==42)) )        //Yep 42 
    replace_all(file,127,"*","") 
    replace_all(file,127,"/","\") 
    ArrayPushString(aFile,file) 
    return PLUGIN_HANDLED; 
} 

public show_rules() 
{ 
    if(!ArraySize(aFile)) 
        console_print(0,"NO RULES FOUND!") 
    else 
    { 
        new count=ArraySize(aFile) 
        for(new i;i<count;i++) 
        { 
            new file[128] 
            ArrayGetString(aFile,i,file,127) 
            console_print(0,"[%d] %s %s%s%s",i,(ArrayGetCell(aRule,i))?"ACCEPT":"BLOCK",(ArrayGetCell(aRuleType,i) & 1)?"*":"",file,(ArrayGetCell(aRuleType,i) & 2)?"*":"") 
        } 
         
    } 
     
}

Last edited by AGONN; 03-05-2018 at 06:43.
AGONN is offline
raizo11
BANNED
Join Date: Dec 2013
Location: https://t.me/pump_upp
Old 03-05-2018 , 07:56   Re: fix 1 warning without effect the plugin function.
Reply With Quote #2

??
Attached Files
File Type: sma Get Plugin or Get Source (file_watcher.sma - 495 views - 3.2 KB)

Last edited by raizo11; 03-05-2018 at 07:56.
raizo11 is offline
Send a message via ICQ to raizo11 Send a message via AIM to raizo11 Send a message via MSN to raizo11 Send a message via Yahoo to raizo11 Send a message via Skype™ to raizo11
AGONN
Member
Join Date: Jan 2018
Old 03-05-2018 , 11:59   Re: fix 1 warning without effect the plugin function.
Reply With Quote #3

that effect the plugin function , it do not read the rules from the filewatcher.cfg
AGONN is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-05-2018 , 22:16   Re: fix 1 warning without effect the plugin function.
Reply With Quote #4

You are trying to add and multiple boolean values. You can't do that type of math with boolean values. You need to convert the booleans to integers before doing math with them.

One way to do this with in-line code is using the ternary operator:
Code:
(x == y) ? 1 : 0
__________________

Last edited by fysiks; 03-05-2018 at 22:16.
fysiks is offline
AGONN
Member
Join Date: Jan 2018
Old 03-06-2018 , 06:42   Re: fix 1 warning without effect the plugin function.
Reply With Quote #5

Can you be more spesefic ?
this line :

Code:
ArrayPushCell(aRuleType,((file[0]==42) + 2*(file[strlen(file)-1]==42)) )        //Yep 42
will become ?
AGONN is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-06-2018 , 21:18   Re: fix 1 warning without effect the plugin function.
Reply With Quote #6

This is the Scripting Help section so I won't write the code for you (for simply things like this). Try to do it yourself and test it. If it doesn't work, post what code you tried and we'll let you know what you did wrong.

Here is an example:

Code:
new a = 1
new b = 1

new var = (a == b) ? 1 : 0
If a is equal to b then var will be 1 otherwise var will be 0.

Also, in your case, instead of multiplying by 2, you can a 2 and a 0 for the two values.
__________________

Last edited by fysiks; 03-06-2018 at 21:19.
fysiks is offline
AGONN
Member
Join Date: Jan 2018
Old 03-08-2018 , 12:07   Re: fix 1 warning without effect the plugin function.
Reply With Quote #7

i did not understand
AGONN 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 09:29.


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