AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [CSGO] Blocking Left knife (https://forums.alliedmods.net/showthread.php?t=311353)

The Killer NL 10-14-2018 06:30

[CSGO] Blocking Left knife
 
1 Attachment(s)
Description:
Hello Everyone, This plugin basically blocks all the left clicks of your knife.
Could be useful for 35hp knife servers if you only want to have right click...

Install:
  • smx file move to csgo/addons/sourcemod/plugins/

Credits:
  • Bara
  • The Killer [NL]
  • SM9

Quote:

Version 2.2 (Wasn't public) All the normal knives added
Version 2.3 Added the newest knives
Version 2.4 Changes by SM9
Version 2.5 Fixed issue of Tasers not working. Thanks to SM9 to
Regards Killer.

Vigge 10-14-2018 06:36

Useful!
 
Thanks for the plugin! Easy install and works great, got it working right away, plug'n'play! :)

butare 10-14-2018 06:38

Re: [CSGO] Blocking Left knife
 
You can replace all your if statements with one if:

Code:

        if(StrContains(sWeapon, "knife") != -1 || StrEqual(sWeapon, "weapon_bayonet"))
        {
                buttons &= ~IN_ATTACK;
                return Plugin_Changed;
        }


Bara 10-14-2018 06:45

Re: [CSGO] Blocking Left knife
 
Quote:

Originally Posted by butare (Post 2619666)
Code:

        if(StrContains(sWeapon, "knife") != -1 || StrEqual(sWeapon, "weapon_bayonet"))
        {
                buttons &= ~IN_ATTACK;
                return Plugin_Changed;
        }


Code:

if(StrContains(sWeapon, "knife", false) != -1 || StrContains(sWeapon, "bayonet", false) != -1)
Maybe Valve adds a new bayonet equal knife with just other name.

butare 10-14-2018 06:46

Re: [CSGO] Blocking Left knife
 
Quote:

Originally Posted by Bara (Post 2619669)
Code:

if(StrContains(sWeapon, "knife", false) != -1 || StrContains(sWeapon, "bayonet", false) != -1)
Maybe Valve adds a new bayonet equal knife with just other name.

Or they can add a gun with "bayonet" in name, never knows :)

Bara 10-14-2018 06:53

Re: [CSGO] Blocking Left knife
 
Quote:

Originally Posted by butare (Post 2619670)
Or they can add a gun with "bayonet" in name, never knows :)

Sure, but my opinion based on Karambit and Talon Knife. Looks basically equal with a few changes.

butare 10-14-2018 06:59

Re: [CSGO] Blocking Left knife
 
Quote:

Originally Posted by Bara (Post 2619672)
Sure, but my opinion based on Karambit and Talon Knife. Looks basically equal with a few changes.

Yea but they both have "knife" in their names, so I think they made a mistake when they add bayonet and not add "knife" to it's name. So other versions of knifes (even if it's just another bayonet looking knife) should contain "knife" in their name, as all other knifes do (ofc except bayonet for some reason). And rn it's just an offtopic, so I'll stop right there :)

The Killer NL 10-14-2018 09:48

Re: [CSGO] Blocking Left knife
 
I understand what you guys mean but i'll keep it this for now since it's not really a big deal

shanapu 10-14-2018 13:37

Re: [CSGO] Blocking Left knife
 
Quote:

Originally Posted by The Killer NL (Post 2619687)
I understand what you guys mean but i'll keep it this for now since it's not really a big deal

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;



Dr!fter 10-14-2018 14:03

Re: [CSGO] Blocking Left knife
 
The better way is to get the item definition (m_iItemDefinitionIndex or whatever...) convert it to an id with https://sm.alliedmods.net/new-api/cs...emDefIndexToID and comparing that it is within the range of https://github.com/alliedmodders/sou....inc#L144-L159 or one of the 3 other knifes.


All times are GMT -4. The time now is 22:06.

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