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

Knife Headshot


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Silvsilver
Member
Join Date: Oct 2017
Old 12-03-2017 , 15:36   Knife Headshot
Reply With Quote #1

I want a plugin to be able to headshot with knife.
Silvsilver is offline
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 12-04-2017 , 10:35   Re: Knife Headshot
Reply With Quote #2

How about you specify a game atleast...
__________________
xines is offline
Silvsilver
Member
Join Date: Oct 2017
Old 12-05-2017 , 22:15   Re: Knife Headshot
Reply With Quote #3

Ohh. For csgo.
Silvsilver is offline
CowGod
Senior Member
Join Date: Feb 2015
Old 12-07-2017 , 15:38   Re: Knife Headshot
Reply With Quote #4

should knifes always be a headshot or only when aiming at the head?
CowGod is offline
Send a message via Skype™ to CowGod
Silvsilver
Member
Join Date: Oct 2017
Old 12-09-2017 , 11:44   Re: Knife Headshot
Reply With Quote #5

Quote:
Originally Posted by CowGod View Post
should knifes always be a headshot or only when aiming at the head?
Only when aiming at the head.
Silvsilver is offline
Papero
Veteran Member
Join Date: Aug 2016
Location: Italy
Old 12-09-2017 , 12:46   Re: Knife Headshot
Reply With Quote #6

Try this:

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

#define PLUGIN_AUTHOR         "Hexah"
#define PLUGIN_VERSION        "1.0"

#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo =
{
    
name "KnifeHS",
    
author PLUGIN_AUTHOR,
    
description "",
    
version PLUGIN_VERSION,
    
url "csitajb.it"
};

public 
void OnPluginStart()
{
    
HookEvent("player_death"Event_PlayerDeathEventHookMode_Pre);
}

public 
Action Event_PlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    
char sWeapon[32];
    
event.GetString("weapon"sWeaponsizeof(sWeapon)); //Get weapon name
    
    
if (StrContains(sWeapon"knife"false) != -1//If the weapon isn't a knife
        
return Plugin_Continue;
        
    
int client GetClientOfUserId(event.GetInt("attacker")); //Get client index
    
    
float vPos[3];
    
float vAng[3];
    
    
GetClientAbsOrigin(clientvAng);
    
GetClientAbsAngles(clientvAng);
    
TR_TraceRayFilter(vPosvAngMASK_SHOTRayType_InfiniteTrace_DontHitSelfclient); //Start the trace
    
    
int iHitGroup TR_GetHitGroup(); //Get the hit group
    
    
if (iHitGroup == 1//Not sure if '1' for it's okay. (For HS hitgroup)
    
{
        
event.SetBool("headshot"true);
        return 
Plugin_Changed;
    }
    return 
Plugin_Continue;
}

public 
bool Trace_DontHitSelf(int entityint contentsMaskany data)
{
    return 
entity != data;

If someone can confirm me that the hitgroup of "headshots" is "1" would be great, since I really don't know if that's okay.
Attached Files
File Type: sp Get Plugin or Get Source (KnifeHS.sp - 262 views - 1.3 KB)
__________________
My Plugins
SPCode


Steam: hexer504
Telegram: Hexah
Discord: Hexah#6903

If you like my work you can donate here!

Last edited by Papero; 12-10-2017 at 07:16. Reason: Get attacker index instead of the player that died.
Papero is offline
Silvsilver
Member
Join Date: Oct 2017
Old 12-09-2017 , 14:00   Re: Knife Headshot
Reply With Quote #7

Quote:
Originally Posted by Papero View Post
Try this:

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

#define PLUGIN_AUTHOR         "Hexah"
#define PLUGIN_VERSION        "1.0"

#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo =
{
    
name "KnifeHS",
    
author PLUGIN_AUTHOR,
    
description "",
    
version PLUGIN_VERSION,
    
url "csitajb.it"
};

public 
void OnPluginStart()
{
    
HookEvent("player_death"Event_PlayerDeathEventHookMode_Pre);
}

public 
Action Event_PlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    
char sWeapon[32];
    
event.GetString("weapon"sWeaponsizeof(sWeapon)); //Get weapon name
    
    
if (StrContains(sWeapon"knife"false) != -1//If the weapon isn't a knife
        
return Plugin_Continue;
        
    
int client GetClientOfUserId(event.GetInt("userid")); //Get client index
    
    
float vPos[3];
    
float vAng[3];
    
    
GetClientAbsOrigin(clientvAng);
    
GetClientAbsAngles(clientvAng);
    
TR_TraceRayFilter(vPosvAngMASK_SHOTRayType_InfiniteTrace_DontHitSelfclient); //Start the trace
    
    
int iHitGroup TR_GetHitGroup(); //Get the hit group
    
    
if (iHitGroup == 1//Not sure if '1' for it's okay. (For HS hitgroup)
    
{
        
event.SetBool("headshot"true);
        return 
Plugin_Changed;
    }
    return 
Plugin_Continue;
}

public 
bool Trace_DontHitSelf(int entityint contentsMaskany data)
{
    return 
entity != data;

If someone can confirm me that the hitgroup of "headshots" is "1" would be great, since I really don't know if that's okay.

I tried it but it didn't work, knifing is as normal
thx for your time!
Silvsilver is offline
Papero
Veteran Member
Join Date: Aug 2016
Location: Italy
Old 12-10-2017 , 07:17   Re: Knife Headshot
Reply With Quote #8

Quote:
Originally Posted by Silvsilver View Post
I tried it but it didn't work, knifing is as normal
thx for your time!
I updated the first post please retry, if that dont work I'll rewrite using: player_hurt event instead of player_death.
__________________
My Plugins
SPCode


Steam: hexer504
Telegram: Hexah
Discord: Hexah#6903

If you like my work you can donate here!

Last edited by Papero; 12-10-2017 at 07:17.
Papero is offline
Silvsilver
Member
Join Date: Oct 2017
Old 12-10-2017 , 12:09   Re: Knife Headshot
Reply With Quote #9

It still doesn't work. But I have another guy wich are helping me out. CowGod ^
Silvsilver is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 12-10-2017 , 12:14   Re: Knife Headshot
Reply With Quote #10

Instead of getting the player's absolute origin try getting their eye angles and eye position.
Mitchell 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:46.


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