Raised This Month: $51 Target: $400
 12% 

[CSGO] Block left click knife


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sim242
AlliedModders Donor
Join Date: Dec 2012
Location: England
Old 10-06-2014 , 13:55   [CSGO] Block left click knife
Reply With Quote #1

Hey guys, I'm currently finishing off a project I've been working on for a while, I'm keeping it under wraps for now until it's finished and I put it on a server and then I'll share the IP if interested.

Basically I want to detect when a player attacks using a knife and if they do attack using a knife I want to block left click knife attacks so you can only knife someone by right clicking. I've seen it done on some other servers and I've searched thoroughly but unfortunately I've found no answer to my question.

Any help is appreciated
__________________
Steam - Sim
Request a private plugin
Not accepting requests at this time
sim242 is offline
Send a message via Skype™ to sim242
Bara
AlliedModders Donor
Join Date: Apr 2012
Location: Germany
Old 10-06-2014 , 14:01   Re: [CSGO] Block left click knife
Reply With Quote #2

Try this.
Attached Files
File Type: sp Get Plugin or Get Source (blockleftknife.sp - 902 views - 519 Bytes)
__________________
Discord (Bara#5006) | My Plugins (GitHub)
You like my work? Support is not a crime.
Bara is offline
sim242
AlliedModders Donor
Join Date: Dec 2012
Location: England
Old 10-06-2014 , 14:45   Re: [CSGO] Block left click knife
Reply With Quote #3

Just tried it out, seems to work thank you very much! One problem though, it shows the beginning of the knife animation which looks really glitchy. Is there a way of stopping left click knifing without it showing an animation? I read somewhere you can do it with PreThink or something but I have no idea how.
__________________
Steam - Sim
Request a private plugin
Not accepting requests at this time
sim242 is offline
Send a message via Skype™ to sim242
xf117
Senior Member
Join Date: Mar 2010
Location: Russia
Old 10-07-2014 , 12:07   Re: [CSGO] Block left click knife
Reply With Quote #4

Quote:
Originally Posted by sim242 View Post
Just tried it out, seems to work thank you very much! One problem though, it shows the beginning of the knife animation which looks really glitchy. Is there a way of stopping left click knifing without it showing an animation? I read somewhere you can do it with PreThink or something but I have no idea how.
Probably not. It's a client side prediction. Game expects the knife to attack even if you blocked it on server.
xf117 is offline
Send a message via ICQ to xf117
sim242
AlliedModders Donor
Join Date: Dec 2012
Location: England
Old 10-07-2014 , 12:15   Re: [CSGO] Block left click knife
Reply With Quote #5

Quote:
Originally Posted by xf117 View Post
Probably not. It's a client side prediction. Game expects the knife to attack even if you blocked it on server.
Fair enough, thanks anyway
__________________
Steam - Sim
Request a private plugin
Not accepting requests at this time
sim242 is offline
Send a message via Skype™ to sim242
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 10-07-2014 , 12:58   Re: [CSGO] Block left click knife
Reply With Quote #6

I use this code for make ultra fast attack
PHP Code:
FastAttack(client

    new 
ActiveWeapon GetEntPropEnt(clientProp_Send"m_hActiveWeapon"); 
    if(
IsValidEntity(ActiveWeapon)) 
    { 

                
SetEntPropFloat(ActiveWeaponProp_Send"m_flNextPrimaryAttack"0.50); 
                
SetEntPropFloat(clientProp_Send"m_flNextAttack"GetGameTime()); 
                
SetEntProp(clientProp_Send"m_iShotsFired"0); 
                
                new 
Float:NoRecoil[3] = {0.00.00.0}; 
                
SetEntPropVector(clientProp_Send"m_vecPunchAngle"NoRecoil); 
    } 


You can edit the values for make the next primary attack semi infinite, like
PHP Code:
// code

        
NextAttack(client99999.0); // next attack in 99999 seconds = no left click

// code

NextAttack(clientFloat:value

    new 
ActiveWeapon GetEntPropEnt(clientProp_Send"m_hActiveWeapon"); 
    if(
IsValidEntity(ActiveWeapon)) 
    { 

                
SetEntPropFloat(ActiveWeaponProp_Send"m_flNextPrimaryAttack"value); 
    } 

__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.


Last edited by Franc1sco; 10-07-2014 at 16:36.
Franc1sco is offline
Send a message via MSN to Franc1sco
sim242
AlliedModders Donor
Join Date: Dec 2012
Location: England
Old 10-07-2014 , 13:27   Re: [CSGO] Block left click knife
Reply With Quote #7

Thanks Franc1sco! Where about would I use these functions though? I'm not aware of any function that is called before an attack in which this could be used to prevent a left click knife.
__________________
Steam - Sim
Request a private plugin
Not accepting requests at this time
sim242 is offline
Send a message via Skype™ to sim242
Mitchell
~lick~
Join Date: Mar 2010
Old 10-07-2014 , 16:03   Re: [CSGO] Block left click knife
Reply With Quote #8

-1 would return false in IsValidEntity
so basically you're checking if the entity isn't -1 twice. (IsValidEntity already checks this afaik, if it doesnt then it would error out if -1 is passed through before you can even check -1)

EDIT: i've made my own version, doesn't check every frame if a player has used his knife. not tested.
Attached Files
File Type: sp Get Plugin or Get Source (DisableLeftKnife.sp - 731 views - 1.3 KB)

Last edited by Mitchell; 10-07-2014 at 16:23.
Mitchell is offline
sim242
AlliedModders Donor
Join Date: Dec 2012
Location: England
Old 10-07-2014 , 16:43   Re: [CSGO] Block left click knife
Reply With Quote #9

Unfortunately no your version doesn't work :/ Thanks for trying to help though
__________________
Steam - Sim
Request a private plugin
Not accepting requests at this time
sim242 is offline
Send a message via Skype™ to sim242
Uncle Jessie
Member
Join Date: May 2016
Location: Mind Prison
Old 03-22-2017 , 23:01   Re: [CSGO] Block left click knife
Reply With Quote #10

Quote:
Originally Posted by Bara View Post
Try this.
THANK YOU!
Uncle Jessie is offline
Reply



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 05:10.


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