Thread: [Solved] ,
View Single Post
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-16-2021 , 08:36   Re: steamid active hookevent
Reply With Quote #4

I made it so it use admins, rather than hard coded steamids in code or else source.

PHP Code:

bool WhiteList
[MAXPLAYERS+1];


public 
void OnPluginStart()
{
    
HookEvent("weapon_fire"weapon_fire);
}

public 
void OnClientPostAdminCheck(int client)
{
    
// Use admins list and overrides
    
WhiteList[client] = CheckCommandAccess(client"admin_weaponfire"ADMFLAG_ROOT);

}

public 
void weapon_fire(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));


    if(!
WhiteList[client] || GetClientTeam(client) != 2)
        return;


    
char weapon[65];
    
    
event.GetString("weapon"weaponsizeof(weapon));
    
    
PrintToChatAll(" %L weapon %s"clientweapon);

- This system works - if you not give admin flag "Z" (root) access to anyone, not even yourself.
ROOT access is special flag, it magically bypass everything. It's not good for use.

in admins.cfg
Code:
/**
 * USE THIS SECTION TO DECLARE DETAILED ADMIN PROPERTIES.
 *
 * Each admin should have its own "Admin" section, followed by a name.
 * The name does not have to be unique.
 *
 * Available properties: (Anything else is filtered as custom)
 *      "auth"          - REQUIRED - Auth method to use.  Built-in methods are:
 *                        "steam"  - Steam based authentication
 *                        "name"   - Name based authentication
 *                        "ip"	- IP based authentication
 *                        Anything else is treated as custom.
 *					 Note: Only one auth method is allowed per entry.
 *
 *      "identity"      - REQUIRED - Identification string, for example, a steamid or name.
 *					 Note: Only one identity is allowed per entry.
 *
 *      "password"      - Optional password to require.
 *      "group"         - Adds one group to the user's group table.
 *      "flags"         - Adds one or more flags to the user's permissions.
 *		"immunity"		- Sets the user's immunity level (0 = no immunity).
 *						  Immunity can be any value.  Admins with higher 
 *						  values cannot be targetted.  See sm_immunity_mode 
 *						  to tweak the rules.  Default value is 0.
 *
 * Example:
	"BAILOPAN"
	{
		"auth"			"steam"
		"identity"		"STEAM_0:1:16"
		"flags"			"abcdef"
	}
 *
 */
Admins
{



	"BAILOPAN"
	{
		"auth"			"steam"
		"identity"		"STEAM_0:1:16"
		"group"			"my_group"
	}



}


in admin_groups.cfg
Code:
Groups
{
	/**
	 * Allowed properties for a group:
	 *
	 *   "flags"           - Flag string.
	 *   "immunity"        - Immunity level number, or a group name.
	 *						 If the group name is a number, prepend it with an 
	 *						 '@' symbol similar to admins_simple.ini.  Users 
	 *						 will only inherit the level number if it's higher 
	 *						 than their current value.
	 */
	"Default"
	{
		"immunity"		"1"
	}
	
	"Full Admins"
	{
		/**
		 * You can override commands and command groups here.
		 * Specify a command name or group and either "allow" or "deny"
		 * Examples:
		 * 		":CSDM"			"allow"
		 *		"csdm_enable"	"deny"
		 */
		 Overrides
		 {
		 }
		"flags"			"abcdefghiz"

		/* Largish number for lots of in-between values. */
		"immunity"		"99"
	}


	"my_group"
	{
		"admin_weaponfire"	"allow"
	}




}
Bacardi is offline