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

Disable stab/normal hit with knife?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Javierko
AlliedModders Donor
Join Date: Sep 2017
Location: Czech republic
Old 01-23-2018 , 13:58   Disable stab/normal hit with knife?
Reply With Quote #1

Hello coders,

i am making some knife arena servers and i have idea to make something like: random round will be disable stab hit.

and question is - is possible to disable stab hit? i know i can set damage to stab hit 0, but i want it disable totally, like right mouse button will be unclickable.
__________________
My Github & Sourcemod work.
If you like my work and if you want to support me, you can through PayPal.

Official SourceMod CZ/SK Discord: https://discord.gg/Qvar55a
Javierko is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 01-23-2018 , 14:17   Re: Disable stab/normal hit with knife?
Reply With Quote #2

Maybe something like this
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

// Integers
int m_flNextSecondaryAttack;

public 
void OnPluginStart()
{
    
// Find
    
m_flNextSecondaryAttack FindSendPropInfo("CBaseCombatWeapon""m_flNextSecondaryAttack");
}

// Set Client Hooks
public void OnClientPutInServer(int client)
{
    
SDKHook(clientSDKHook_PreThinkOnPreThink);
}

public 
Action OnPreThink(int client)
{
    
int iWeapon GetEntPropEnt(clientProp_Send"m_hActiveWeapon");

    if (!
IsValidEdict(weapon))
    {
        return;
    }

    
char classname[MAX_NAME_LENGTH];
    if (
GetEdictClassname(weaponclassnamesizeof(classname)) || StrEqual(classname"weapon_knife"))
    {
        
SetEntDataFloat(weaponm_flNextSecondaryAttackGetGameTime() + 1.0); // block secondary attack
    
}

    return 
Plugin_Continue;

__________________
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; 01-23-2018 at 14:19.
Franc1sco is offline
Send a message via MSN to Franc1sco
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 01-23-2018 , 14:34   Re: Disable stab/normal hit with knife?
Reply With Quote #3

What the fuck man, i thought you somewhat knew what you were doing but then you go and use SetEntData for a regular public property.

SetEntPropFloat should be used
__________________

Last edited by Pelipoika; 01-23-2018 at 14:35.
Pelipoika is offline
Javierko
AlliedModders Donor
Join Date: Sep 2017
Location: Czech republic
Old 01-23-2018 , 14:46   Re: Disable stab/normal hit with knife?
Reply With Quote #4

Okay, big thanks.

When i will have more time i will try it.
__________________
My Github & Sourcemod work.
If you like my work and if you want to support me, you can through PayPal.

Official SourceMod CZ/SK Discord: https://discord.gg/Qvar55a
Javierko is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 01-23-2018 , 15:28   Re: Disable stab/normal hit with knife?
Reply With Quote #5

@Pelipoika

Its not my code, just a fast search
__________________
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; 01-23-2018 at 15:29.
Franc1sco is offline
Send a message via MSN to Franc1sco
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 01-23-2018 , 15:48   Re: Disable stab/normal hit with knife?
Reply With Quote #6

I would also use item definition index if its for CSGO as the classname isnt the same for all knives.
__________________
Neuro Toxin is offline
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 01-23-2018 , 16:16   Re: Disable stab/normal hit with knife?
Reply With Quote #7

Quote:
Originally Posted by Franc1sco View Post
@Pelipoika

Its not my code, just a fast search
ehmm,... it is!
https://github.com/Franc1sco/Franug-...oscope.sp#L150

but also Bara, databomb(or dataviruset), hackmaster and many more used SetEndData instead of SetEntProp for such functions (fast GitHub search), so no big deal for me... learned something new again.


Quote:
Originally Posted by Pelipoika View Post
What the fuck man, i thought you somewhat knew what you were doing but then you go and use SetEntData for a regular public property.

SetEntPropFloat should be used
You could had told us why SetEntData is better instead of SetEntProp.

Quote:
Originally Posted by asherkin View Post
SetEntProp has internal caching and safety checks, making it both faster and safer than using FindSendPropInfo+SetEntData.
good to know, time for some rewrites on my site done.
__________________
coding & free software

Last edited by shanapu; 01-23-2018 at 21:15. Reason: typos
shanapu is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 01-23-2018 , 17:12   Re: Disable stab/normal hit with knife?
Reply With Quote #8

Quote:
Originally Posted by shanapu View Post
ehmm,... it is!
https://github.com/Franc1sco/Franug-...oscope.sp#L150

but also Bara, databomb(or dataviruset), hackmaster and many more used SetEndData instead of SetEntProp for such functions (fast GitHub search), so no big deal for me... learned something new again.




You could had told us why SetEntData is better instead of SetEntProp.



good to know, time for some rewrites on my site.
Ohh ok you won!

Really for me that was basically the same (because it do the same) and I saw that multiple times too.
__________________
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; 01-23-2018 at 17:15.
Franc1sco is offline
Send a message via MSN to Franc1sco
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 21:40.


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