|
AlliedModders Donor
Join Date: Aug 2018
Location: The Netherlands
|
10-15-2018
, 01:23
Re: [CSGO] Blocking Left knife
|
#11
|
Quote:
Originally Posted by shanapu
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 client, bool status = true) { if (status) // true = allow shooting { SDKUnhook(client, SDKHook_PreThink, PreThinkWeapon); } else // false = suppress shooting { SDKHook(client, SDKHook_PreThink, PreThinkWeapon); } } public Action PreThinkWeapon(int client) { int weapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon"); if (weapon < 0 || !IsValidEdict(weapon) || !IsValidEntity(weapon)) return Plugin_Continue; SetEntPropFloat(weapon, Prop_Send, "m_flNextPrimaryAttack", GetGameTime() + 0.25); // Primary SetEntPropFloat(weapon, Prop_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.
|
|
|
|