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

Solved ,


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
cacaopea
Member
Join Date: May 2019
Location: Viet Nam
Old 10-16-2021 , 08:06   ,
Reply With Quote #1

hello,everyone.

how can i add someone's steamid to activate hookevent?
- I tried many ways it doesn't seem to work
PHP Code:
#include <sourcemod>
#include <sdktools>

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

public 
Event_FireStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    
    
char sweapon[256];
    
char steamId[64];
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    
    
GetEventString(event"weapon"sweaponsizeof(sweapon));
    
GetEntPropEnt(clientProp_Send"m_hActiveWeapon");

        if (
IsClientInGame(client) && IsPlayerAlive(client) && GetClientTeam(client) == 2)
        {
    
GetClientAuthId(clientAuthId_Steam2steamIdsizeof(steamId));
      if (
StrEqual(steamId"STEAM_1:1:612286583")) 
       {
   
        
    
     if (
StrEqual(sweapon"vomitjar"))
    {
        
        
           
PrintToChatAll("%s:steamid"steamId);
        
PrintToChatAll("%s:sweapon"sweapon);
        
PrintToChatAll("%i:client"client);
        
    }
    }
}


Last edited by cacaopea; 11-09-2021 at 20:17. Reason: Restore to previous version.
cacaopea is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 10-16-2021 , 08:21   Re: steamid active hookevent
Reply With Quote #2

What exactly are you trying to do? Block players from shooting?
__________________
Psyk0tik is offline
cacaopea
Member
Join Date: May 2019
Location: Viet Nam
Old 10-16-2021 , 08:36   Re: steamid active hookevent
Reply With Quote #3

Quote:
Originally Posted by Psyk0tik View Post
What exactly are you trying to do? Block players from shooting?
i just want if someone with the respective steamid will trigger the hookevent instead of all players being activated
example: all players when throwing vomitjar, in PrintoChatAll only notifies the player with that steamid. If there are 4 people in the room.
- only the person with the steamid I entered above can activate the notification
- sorry for my bad english
cacaopea is offline
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
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 10-16-2021 , 09:35   Re: steamid active hookevent
Reply With Quote #5

Quote:
Originally Posted by cacaopea View Post
i just want if someone with the respective steamid will trigger the hookevent instead of all players being activated
example: all players when throwing vomitjar, in PrintoChatAll only notifies the player with that steamid. If there are 4 people in the room.
- only the person with the steamid I entered above can activate the notification
- sorry for my bad english
Still didn't understand the purpose of filtering it by steamid.
What message is supposed to output to chat?
Also weapon_fire may trigger even if the player switches fast after releasing the vomitjar. (false positive)
__________________
Marttt 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 08:28.


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