AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Read file problems (https://forums.alliedmods.net/showthread.php?t=19932)

Zenith77 10-28-2005 19:37

Read file problems
 
Ok this plugin allows exec commands..but its supposed to block it if the command is in BlockCommands.ini

but for some reason I put the command in there but it still doesnt block it...


here is my BlockCommands.ini

Code:

; Put what commands you want to be
; blocked from being executed on clients


bind
say

This is the code that checks the file:

Code:
while(read_file(clProtectFile, line2++, szText2, 255, txtLen2) ) {                         if( szText2[0] == ';' || !txtLen2) continue                         if(equali(szText2, arg2) ) {                                 client_print(id, print_console, "[EXEC] Sorry, but that command has been blocked! ")                                 return PLUGIN_HANDLED                             }         }

The entire code :
Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN "EXEC |-FULL CONTROL-|" #define VERSION "1.0" #define AUTHOR "Zenith77" #define EXEC_LOAD_SUCCESS "[EXEC] Loaded Successfully ! " #define EXEC_LOAD_FAILURE "[EXEC] Load FAILURE! Please make sure you have all files in the proper directory!" #define EXEC_ERROR_FILE_ACCESS "[EXEC] NoAccess.ini was not detected!" #define EXEC_ERROR_FILE_IMMUNITIY "[EXEC] Immunitiy.ini was not detected!" #define EXEC_ERROR_FILE_COMMANDS "[EXEC] BlockedCommands.ini was not detected!" new clProtectFile[200], noaccessFile[200], immuneFile[200], configdir[200] new szText[256] , txtLen , line = 0 new szText2[256], txtLen2, line2 = 0 new szText3[256], txtLen3, line3 = 0 new bool:isDenied[33] new bool:hasImmunity[33] public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_cvar( "sv_exec", "1" )     //register_cvar( "amx_exec_tell", "1"): next update         register_concmd( "amx_exec", "client_exec", ADMIN_RCON, "<target or @ALL> <command> <parameters> executes command on client" )         get_configsdir(configdir, 199)         format(noaccessFile, 199, "%s/EXEC/NoAccess.ini", configdir)     format(immuneFile, 199, "%s/EXEC/Immunity.ini", configdir)             if( !file_exists(noaccessFile) || !file_exists(immuneFile) ) {         server_print( EXEC_LOAD_FAILURE )     }         else {         server_print( EXEC_LOAD_SUCCESS )     } } public client_connect(id) {     // I plan to revise this system, sometime.     isDenied[id] = false     hasImmunity[id] = false     } public client_exec(id, level, cid)  {         if( !cmd_access(id, level, cid, 3)) {         return PLUGIN_HANDLED     }         if( get_cvar_num("sv_exec") < 1 ) {                 client_print(id, print_console, " [EXEC] Sorry EXEC has been disabled" )                 return PLUGIN_HANDLED     }         if( isDenied[id] ) {                 client_print(id, print_console, " [EXEC] Sorry you are not allowed to use EXEC commands ! " )                 return PLUGIN_HANDLED     }                         get_configsdir(configdir, 199)         format(noaccessFile, 199, "%s/EXEC/NoAccess.ini", configdir)     format(clProtectFile, 199, "%s/EXEC/BlockedCommands.ini", configdir)     format(immuneFile, 199, "%s/EXEC/Immunity.ini", configdir)         if( !file_exists(noaccessFile) ) {              server_print( "----------ERROR--------- ")         server_print( "")         server_print( "COULD NOT READ FROM FILE NoAccess.ini" )         server_print( "REASON: " )         server_print( EXEC_ERROR_FILE_ACCESS )         server_print( "" )         server_print( "Terminating Plugin! REASON:")         server_print( "Cannot give accurate access rights to users!")         server_print( "----------ERROR--------- ")                 set_cvar_num("sv_exec", 0)                 return PLUGIN_HANDLED     }         if( !file_exists(immuneFile) ) {                 server_print( "----------ERROR--------- ")         server_print( "")         server_print( "COULD NOT READ FROM FILE NoAccess.ini" )         server_print( "REASON: " )         server_print( EXEC_ERROR_FILE_IMMUNITIY )         server_print( "" )         server_print( "Terminating Plugin! REASON:")         server_print( "Cannot give accurate access rights to users!")         server_print( "----------ERROR--------- ")                 set_cvar_num("sv_exec", 0)                 return PLUGIN_HANDLED     }         if( !file_exists(clProtectFile) ) {                 server_print( "----------ERROR--------- ")         server_print( "")         server_print( "COULD NOT READ FROM FILE NoAccess.ini" )         server_print( "REASON: " )         server_print( EXEC_ERROR_FILE_COMMANDS )         server_print( "" )         server_print( "Terminating Plugin! REASON:")         server_print( "Cannot give accurate access rights to users!")         server_print( "----------ERROR--------- ")                 set_cvar_num("sv_exec", 0)                 return PLUGIN_HANDLED     }             new authid[32]     get_user_authid(id, authid, 31)         /* ------------------- NO ACCESS FILE ------------ */             read_NoAccessFile(id, authid)         if( isDenied[id] )         return PLUGIN_HANDLED             /* -----END----- */             new arg[32], arg2[32],arg3[32], target     new  name[32], tName[32]         read_argv(1, arg, 31)     read_argv(2, arg2, 31)     read_argv(3, arg3, 31)         if( !equali(arg, "@ALL") ) {                 target = cmd_target(id, arg,  2)                 get_user_name(target, tName, 31)     }                   get_user_name(id, name, 31)     get_user_name(target, tName, 31)         /* --------------------IMMUNITY FILE --------------------*/         read_ImmuntityFile(id, authid)         /*-----End---- */         if( !hasImmunity[id] ) {                 /* --------- Blocked Commands File --------- */         // Coudnt put it in a stock because I was not able to block it         // if the command has been blocked.                 while(read_file(clProtectFile, line2++, szText2, 255, txtLen2) ) {                         if( szText2[0] == ';' || !txtLen2) continue                         if(equali(szText2, arg2) ) {                                 client_print(id, print_console, "[EXEC] Sorry, but that command has been blocked! ")                                 return PLUGIN_HANDLED                             }         }                 /*-----End----*/     }         if( equali(arg, "@ALL" ) )  {                 for( new i = 1; i<get_maxplayers(); i++ ) {                         if( !is_user_connected(i)) continue                         client_cmd(i,  "%s %s", arg2, arg3)         }                 log_amx( "[EXEC] ADMIN %s with AUTHID: %s executed command %s on ALL players ", name, authid, arg2 )                 return PLUGIN_HANDLED     }         else {                 client_cmd(target, "%s %s", arg2, arg3)                 log_amx("[EXEC] ADMIN %s with AUTHID: %s executed command %s on %s", name, authid, arg2, tName)             }         return PLUGIN_HANDLED     } /* -----------STOCKS------------- */ stock read_NoAccessFile(id, authid[]) {         get_configsdir(configdir, 199)         format(noaccessFile, 199, "%s/EXEC/NoAccess.ini", configdir)         while(read_file(noaccessFile, line++, szText, 255, txtLen) ) {                 if( szText[0] == ';' ||  !txtLen) continue                 if( equali(szText, authid) ) {                         client_print(id, print_console, " [EXEC] Sorry you are not allowed to use EXEC commands ! " )                         isDenied[id] = true         }     }     } stock read_ImmuntityFile(id, authid[]) {         get_configsdir(configdir, 199)         format(immuneFile, 199, "%s/EXEC/Immunity.ini", configdir)         while(read_file(immuneFile, line3++, szText3, 255, txtLen3) ) {                 if( szText[0] == ';' || !txtLen) continue                 if(equali(szText, authid) ){                         hasImmunity[id] = true         }     } }

As a small note, this was working about 2 months back when it was originally created but had some bugs in it, not it doenst even block, but i can execute commands on people...

Hawk552 10-28-2005 20:06

You should probably try
Code:
containi(szText2, arg2)!=-1

In place of
Code:
equali(szText2, arg2)

Zenith77 10-30-2005 11:10

nope :/

Hawk552 10-30-2005 11:16

Add some debugging info, see how far it goes.


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

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