View Single Post
The Killer NL
AlliedModders Donor
Join Date: Aug 2018
Location: The Netherlands
Old 10-15-2018 , 01:23   Re: [CSGO] Blocking Left knife
Reply With Quote #11

Quote:
Originally Posted by shanapu View Post
It is. In the worst case, your plugin will do fifteen StrEqual checks before it blocks the attack.
Baras example just needs a maximum of two checks. Where IIRC StrContains is less expensive than StrEqual. And when valve adds a new knife the probability is high they will call it somethig like knife (or bayonet), so there will be no need to edit your plugin for a valve update.

But the main reason why I decided to post here is:
With your method to block the attack players can easily lag the server and make it unplayable.

Instead of block the attack on OnPlayerRunCmd I recommend this method:

PHP Code:
void EnableWeaponFire(int clientbool status true)
{
    if (
status// true = allow shooting
    
{
        
SDKUnhook(clientSDKHook_PreThinkPreThinkWeapon);
    }
    else 
// false = suppress shooting
    
{
        
SDKHook(clientSDKHook_PreThinkPreThinkWeapon);
    
    }
}
 public 
Action PreThinkWeapon(int client)
{
     
int weapon GetEntPropEnt(clientProp_Send"m_hActiveWeapon");
     if (
weapon || !IsValidEdict(weapon) || !IsValidEntity(weapon))
        return 
Plugin_Continue;
     
SetEntPropFloat(weaponProp_Send"m_flNextPrimaryAttack"GetGameTime() + 0.25);  // Primary
     
SetEntPropFloat(weaponProp_Send"m_flNextSecondaryAttack"GetGameTime() + 0.25);  // Secondary
     
return Plugin_Continue;

I see, i kinda been using it for a long time on a server of mine never kinda felt lag but i get ur point i'll try looking into it when i have time
__________________


Last edited by The Killer NL; 10-15-2018 at 01:24.
The Killer NL is offline