Raised This Month: $32 Target: $400
 8% 

[CSGO] Blocking Left knife


Post New Thread Reply   
 
Thread Tools Display Modes
Author
The Killer NL
AlliedModders Donor
Join Date: Aug 2018
Location: The Netherlands
Plugin ID:
6298
Plugin Version:
2.5
Plugin Category:
Gameplay
Plugin Game:
Counter-Strike: GO
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Blocks Left knifes.
    Old 10-14-2018 , 06:30   [CSGO] Blocking Left knife
    Reply With Quote #1

    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.
    Attached Files
    File Type: sp Get Plugin or Get Source (blockleftknifeupkiller.sp - 706 views - 3.5 KB)
    __________________


    Last edited by The Killer NL; 10-16-2018 at 05:52.
    The Killer NL is offline
    Vigge
    New Member
    Join Date: Jul 2018
    Old 10-14-2018 , 06:36   Useful!
    Reply With Quote #2

    Thanks for the plugin! Easy install and works great, got it working right away, plug'n'play!
    Vigge is offline
    butare
    Senior Member
    Join Date: Nov 2016
    Old 10-14-2018 , 06:38   Re: [CSGO] Blocking Left knife
    Reply With Quote #3

    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;
    	}
    butare is offline
    Bara
    AlliedModders Donor
    Join Date: Apr 2012
    Location: Germany
    Old 10-14-2018 , 06:45   Re: [CSGO] Blocking Left knife
    Reply With Quote #4

    Quote:
    Originally Posted by butare View Post
    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.
    __________________
    Discord (Bara#5006) | My Plugins (GitHub)
    You like my work? Support is not a crime.
    Bara is offline
    butare
    Senior Member
    Join Date: Nov 2016
    Old 10-14-2018 , 06:46   Re: [CSGO] Blocking Left knife
    Reply With Quote #5

    Quote:
    Originally Posted by Bara View Post
    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
    butare is offline
    Bara
    AlliedModders Donor
    Join Date: Apr 2012
    Location: Germany
    Old 10-14-2018 , 06:53   Re: [CSGO] Blocking Left knife
    Reply With Quote #6

    Quote:
    Originally Posted by butare View Post
    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.
    __________________
    Discord (Bara#5006) | My Plugins (GitHub)
    You like my work? Support is not a crime.
    Bara is offline
    butare
    Senior Member
    Join Date: Nov 2016
    Old 10-14-2018 , 06:59   Re: [CSGO] Blocking Left knife
    Reply With Quote #7

    Quote:
    Originally Posted by Bara View Post
    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
    butare is offline
    The Killer NL
    AlliedModders Donor
    Join Date: Aug 2018
    Location: The Netherlands
    Old 10-14-2018 , 09:48   Re: [CSGO] Blocking Left knife
    Reply With Quote #8

    I understand what you guys mean but i'll keep it this for now since it's not really a big deal
    __________________

    The Killer NL is offline
    shanapu
    Veteran Member
    Join Date: Apr 2015
    Location: .de
    Old 10-14-2018 , 13:37   Re: [CSGO] Blocking Left knife
    Reply With Quote #9

    Quote:
    Originally Posted by The Killer NL View Post
    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;

    __________________
    coding & free software
    shanapu is offline
    Dr!fter
    The Salt Boss
    Join Date: Mar 2007
    Old 10-14-2018 , 14:03   Re: [CSGO] Blocking Left knife
    Reply With Quote #10

    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.

    Last edited by Dr!fter; 10-14-2018 at 14:06.
    Dr!fter is offline
    Reply


    Thread Tools
    Display Modes

    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 04:25.


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