Raised This Month: $ Target: $400
 0% 

Is it possible fail state ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Awesome_man
Senior Member
Join Date: May 2014
Location: singapore
Old 12-27-2015 , 01:48   Is it possible fail state ?
Reply With Quote #1

Is it possible that if certain steamid is not an admins or say removed from user.ini then the plugin should not work

i mean if particular steamid is not an admins or not in user.ini the plugin should disabled and should not work
Awesome_man is offline
wickedd
Veteran Member
Join Date: Nov 2009
Old 12-27-2015 , 03:24   Re: Is it possible fail state ?
Reply With Quote #2

Why?
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 12-27-2015 , 04:08   Re: Is it possible fail state ?
Reply With Quote #3

Quote:
Originally Posted by Awesome_man View Post
Is it possible that if certain steamid is not an admins or say removed from user.ini then the plugin should not work

i mean if particular steamid is not an admins or not in user.ini the plugin should disabled and should not work
Sure. Just detect the user and pause(...) the plugin using the flag:
Quote:
Originally Posted by https://www.amxmodx.org/api/amxmodx/pause
"d" - stop plugin, making it unavailable to unpause
__________________
Plugin: Sublime Text - ITE , Galileo
Multi-Mod: Manager / Plugin / Server

Support me on Patreon, Ko-fi, Liberapay or Open Collective

Last edited by addons_zz; 12-27-2015 at 04:10.
addons_zz is offline
Awesome_man
Senior Member
Join Date: May 2014
Location: singapore
Old 12-27-2015 , 04:39   Re: Is it possible fail state ?
Reply With Quote #4

Quote:
Originally Posted by addons_zz View Post
Sure. Just detect the user and pause(...) the plugin using the flag:
can you show post an example code ?
Awesome_man is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 12-27-2015 , 04:39   Re: Is it possible fail state ?
Reply With Quote #5

PHP Code:

#include <amxmodx>
#include <amxmisc>
  
#define PLUGIN "My Plugin"
#define VERSION "1.0"
#define AUTHOR "siriudmd99"

#define STEAMID "your steamid"
#define FLAGS "abcdefghijklmnopqrstu"
  

public plugin_init() {

    
register_plugin(PLUGINVERSIONAUTHOR)
          
    if(!
is_auth_admin)                   
                 
set_fail_state("[%s] You're not allowed to use this plugin!"PLUGIN)

}

bool:is_auth_admin(){
    
    static 
u_Flagsu_Countu_Acces
    u_Count
=admins_num()
      
    for (new 
0u_Count; ++i)
    {
        
u_Flags=admins_lookup(i,AdminProp_Flags);
u_Access=admins_lookup(i,AdminProp_Access);
admins_lookup(i,AdminProp_Auth,AuthData,charsmax(AuthData));

        if (
u_Flags FLAG_AUTHID) && (equal(STEAMAuthData)) && (equal(FLAGS,u_Access)) return true;
            
    }

return 
false;


Instead of "your steamid" put steam which you would like to check.
Edit: if you want to stop other plugins then use server_cmd("amx_pausecfg stop plugin_name.amxx") instead of set fail state.

Last edited by siriusmd99; 12-27-2015 at 04:45.
siriusmd99 is offline
Awesome_man
Senior Member
Join Date: May 2014
Location: singapore
Old 12-27-2015 , 04:49   Re: Is it possible fail state ?
Reply With Quote #6

Quote:
Originally Posted by siriusmd99 View Post
PHP Code:

#include <amxmodx>
#include <amxmisc>
  
#define PLUGIN "My Plugin"
#define VERSION "1.0"
#define AUTHOR "siriudmd99"

#define STEAMID "your steamid"
#define FLAGS "abcdefghijklmnopqrstu"
  

public plugin_init() {

    
register_plugin(PLUGINVERSIONAUTHOR)
          
    if(!
is_auth_admin)                   
                 
set_fail_state("[%s] You're not allowed to use this plugin!"PLUGIN)

}

bool:is_auth_admin(){
    
    static 
u_Flagsu_Countu_Acces
    u_Count
=admins_num()
      
    for (new 
0u_Count; ++i)
    {
        
u_Flags=admins_lookup(i,AdminProp_Flags);
u_Access=admins_lookup(i,AdminProp_Access);
admins_lookup(i,AdminProp_Auth,AuthData,charsmax(AuthData));

        if (
u_Flags FLAG_AUTHID) && (equal(STEAMAuthData)) && (equal(FLAGS,u_Access)) return true;
            
    }

return 
false;


Instead of "your steamid" put steam which you would like to check.
Edit: if you want to stop other plugins then use server_cmd("amx_pausecfg stop plugin_name.amxx") instead of set fail state.
Suppose there is a plugin named "abc.amxx" "ghj.amxx" how can dey be paused if particular steamid not an admin in user.ini file ?
Awesome_man is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 12-27-2015 , 04:56   Re: Is it possible fail state ?
Reply With Quote #7

I said you. Just put your steamid in define at the top of the plugin and replace set fail state with the stop command above .
siriusmd99 is offline
Old 12-27-2015, 05:22
fysiks
This message has been deleted by fysiks. Reason: nvm
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 12-27-2015 , 06:05   Re: Is it possible fail state ?
Reply With Quote #9

Try this:

Code:
/** AMX Mod X Script  *  *  This program is free software; you can redistribute it and/or modify it  *  under the terms of the GNU General Public License as published by the  *  Free Software Foundation; either version 2 of the License, or ( at  *  your option ) any later version.  *  *  This program is distributed in the hope that it will be useful, but  *  WITHOUT ANY WARRANTY; without even the implied warranty of  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  *  See the GNU General Public License for more details.  *  *  You should have received a copy of the GNU General Public License  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.  *  * ***********************************************************    */ #include <amxmodx> #include <amxmisc> new Trie:g_black_list /*  * Called just after server activation.  */ public plugin_init() {     register_plugin( "Cool Plugin", "1.0", "Addons zz" )         g_black_list = TrieCreate()         TrieSetCell( g_black_list, "STEAM_0:1:xxxxxxxx", 1 )     TrieSetCell( g_black_list, "STEAM_0:1:xxxxxxxx", 1 )     TrieSetCell( g_black_list, "STEAM_0:1:xxxxxxxx", 1 )     TrieSetCell( g_black_list, "STEAM_0:1:xxxxxxxx", 1 )     TrieSetCell( g_black_list, "STEAM_0:1:xxxxxxxx", 1 )     TrieSetCell( g_black_list, "STEAM_0:1:xxxxxxxx", 1 )     TrieSetCell( g_black_list, "STEAM_0:1:xxxxxxxx", 1 ) } /*  * Called when all plugins went through plugin_init()  */ public plugin_cfg() {     new string_steam_ID[ 32 ]         copy( string_steam_ID, charsmax( string_steam_ID ), "STEAM_0:1:xxxxxxxx" )         if( TrieKeyExists( g_black_list, string_steam_ID ) )     {         pause( "d", "my_bad_pluing.amxx" );         pause( "d", "my_more_bad_pluing.amxx" );     } } /*  * Called just before server deactivation and subsequent unloading of the  * plugin.  */ public plugin_end() {     TrieDestroy( g_black_list ) }

Here is a function from the default plugin AMXX "admin.sma" to load admins from "users.ini":
Code:
loadSettings(szFilename[]) {     new File=fopen(szFilename,"r");         if (File)     {         new Text[512];         new Flags[32];         new Access[32]         new AuthData[44];         new Password[32];                 while (!feof(File))         {             fgets(File,Text,sizeof(Text)-1);                         trim(Text);                         // comment             if (Text[0]==';')             {                 continue;             }                         Flags[0]=0;             Access[0]=0;             AuthData[0]=0;             Password[0]=0;                         // not enough parameters             if (parse(Text,AuthData,sizeof(AuthData)-1,Password,sizeof(Password)-1,Access,sizeof(Access)-1,Flags,sizeof(Flags)-1) < 2)             {                 continue;             }                         admins_push(AuthData,Password,read_flags(Access),read_flags(Flags));             AdminCount++;         }                 fclose(File);     }     if (AdminCount == 1)     {         server_print("[AMXX] %L", LANG_SERVER, "LOADED_ADMIN");     }     else     {         server_print("[AMXX] %L", LANG_SERVER, "LOADED_ADMINS", AdminCount);     }         return 1; }
__________________
Plugin: Sublime Text - ITE , Galileo
Multi-Mod: Manager / Plugin / Server

Support me on Patreon, Ko-fi, Liberapay or Open Collective

Last edited by addons_zz; 12-27-2015 at 07:15. Reason: new better info
addons_zz 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 18:13.


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