View Single Post
Author Message
eyal282
Veteran Member
Join Date: Aug 2011
Old 12-07-2020 , 10:50   [Tutorial] [CS:GO] How to make a gun silent
Reply With Quote #1

Code:
AddTempEntHook("Shotgun Shot", Hook_FireBullets);


public Action:Hook_FireBullets(const String:te_name[], const Players[], numClients, Float:delay)
{
	new client = 0;
	
	for (new i = 1; i <= MaxClients;i++)
	{
		if(!IsClientInGame(i))
			continue;
			
		new bool:Found = false;
		
		for (new a = 0; a < numClients;a++)
		{
			if(Players[a] == i)
				Found = true;
		}
		
		if(!Found)
		{
			client = i;
			
			break;
		}
	}
	
	if(client == 0)
		return Plugin_Continue;
	
	new weapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");

	if(weapon == -1)
		return Plugin_Continue;

	// client is the player that fired the weapon	
	// weapon is the weapon that was fired.
	return Plugin_Stop;
}
I have no clue why the temp ent is "Shotgun Shot" but it actually works.
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334

Last edited by eyal282; 12-07-2020 at 16:06.
eyal282 is offline