View Full Version : [REQ] Deny Knife-Backstab
Hello!
I was wondering of a nice fellow would like to help me with a "Deny Knife-Backstab" plugin.
I'm hosting HnS, and in CS:GO you get "backstabbed" from every single angle and its quite a pain.
What this plugin should do: Make it impossible to one stab kill. The HnS plugin (https://forums.alliedmods.net/showthread.php?t=239132) that I am using forces the client to only be able to stab(Right click), even though you're using left click. I'm not sure if this information is needed, but I felt like adding it.
Feel free to ask any questions if there are any uncertainties.
Contact: Kurt (http://steamcommunity.com/id/OfficialKurt/)
Thanks in advance!
EDIT: This plugin should deal 55 damage of hp from each side you stab from, HnS only uses a knife so there no need to worry about other weapons. I'm sorry if I was unclear about this!
Would make it for you but our last incident was meh so here you are.
1) Hook player_death, look for weapon backstab.
It's not my fault that you scam people.
Give me proof of me scamming anyone please I would appreciate the read.
Learn some morals and to respect people that have went out of their way to help you without anything in return.
Maxximou5
07-11-2016, 02:17
Anyways... Here is this:
#include <sourcemod>
#include <sdkhooks>
#include <cstrike>
public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}
public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
{
if (victim < 1 || victim > MaxClients || attacker < 1 || attacker > MaxClients)
return Plugin_Continue;
if (damage > 55.0)
{
char weapon[64];
GetClientWeapon(attacker, weapon, sizeof(weapon));
if (StrEqual(weapon, "weapon_knife"))
{
PrintToChat(attacker, "\x04[HNS] Backstab denied!");
return Plugin_Handled;
}
}
return Plugin_Continue;
}You weren't very clear on what you wanted the outcome to be, so please go into to detail if the outcome isn't what was desired.
@Maxximou5
if (damage > 55.0)
Out of curiosity, why do you do that ? To save a bit of process time ?
Maxximou5
07-11-2016, 05:06
Standard stab damage is 55, which is why I picked it, and from the sound of it they will mostly only be using knives. Anything above 55 will most likely be a knife in the back and would kill the player. Also declaring anything isn't necessary unless there is a damage value above 55. If there's a better way of doing it, I too would like to know.
Source: https://www.reddit.com/r/GlobalOffensive/comments/2008gz/knife_differences_with_the_mouse1_and_mouse2/
Alright, alright, I was just curious, thanks.
Anyways... Here is this:
#include <sourcemod>
#include <sdkhooks>
#include <cstrike>
public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}
public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
{
if (victim < 1 || victim > MaxClients || attacker < 1 || attacker > MaxClients)
return Plugin_Continue;
if (damage > 55.0)
{
char weapon[64];
GetClientWeapon(attacker, weapon, sizeof(weapon));
if (StrEqual(weapon, "weapon_knife"))
{
PrintToChat(attacker, "\x04[HNS] Backstab denied!");
return Plugin_Handled;
}
}
return Plugin_Continue;
}You weren't very clear on what you wanted the outcome to be, so please go into to detail if the outcome isn't what was desired.
I am using the HnS Plugin which was mentioned above, this it probably what I need, I will test it and I'll return with feedback. Thanks!
Anyways... Here is this:
This plugin doesnt work properly, it doesnt deal any damage at all, and it prints "[HNS] Backstab denied!" even though you stab from the front. The function that I am seeking is that you deal 55 damage with a knife, HnS only uses knifes, Ts have flashbangs and a decoy which can deal 1hp each.
In conclussion, the knife should deal 55 damage from each side you stab from.
I'm sorry if I was unclear about this.
Maxximou5
07-11-2016, 17:17
As your title indicates, you wanted to deny knife damage, so that's what I had the plugin do. Also that the plugin does work properly, as it does what was intended, but rather the plugin does not do what you wanted. I only state this because people reading your message will then think the code doesn't work. Now that you've clarified what you mean, I believe this will do the job you want. If there are any issues let me know and I will happily fix them.
#include <sdkhooks>
public void OnClientPutInServer(int client)
{
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}
public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
{
if (victim < 1 || victim > MaxClients || attacker < 1 || attacker > MaxClients)
return Plugin_Continue;
if (damage > 55.0)
{
char weapon[64];
GetClientWeapon(attacker, weapon, sizeof(weapon));
if (StrEqual(weapon, "weapon_knife", false))
{
damage = 55.0;
return Plugin_Changed;
}
}
return Plugin_Continue;
}
Thank you man, my apologies for the missleading information, I'll try it out and return with feedback!
Maxximou5
07-11-2016, 17:27
No worries about it, I too made a mistake. It should function properly now, forgot to change the return type.
The plugin blocks all damage from a knife on map load or restart of server, however, if I reload the plugin by typing "sm_rcon sm plugins reload backstab", then you're able to deal damage again, but a backstab kills you with one stab.
Franc1sco
07-11-2016, 18:01
however, if I reload the plugin by typing "sm_rcon sm plugins reload backstab", then you're able to deal damage again, but a backstab kills you with one stab.
Fixed
#include <sdkhooks>
public void OnPluginStart()
{
for (new client = 1; client <= MaxClients; client++)
{
if (!IsClientInGame(client))
continue;
OnClientPutInServer(client);
}
}
public void OnClientPutInServer(int client)
{
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}
public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
{
if (victim < 1 || victim > MaxClients || attacker < 1 || attacker > MaxClients)
return Plugin_Continue;
if (damage > 55.0)
{
char weapon[64];
GetClientWeapon(attacker, weapon, sizeof(weapon));
if (StrEqual(weapon, "weapon_knife", false))
{
damage = 55.0;
return Plugin_Changed;
}
}
return Plugin_Continue;
}
Powerlord
07-11-2016, 18:37
Standard stab damage is 55, which is why I picked it, and from the sound of it they will mostly only be using knives. Anything above 55 will most likely be a knife in the back and would kill the player. Also declaring anything isn't necessary unless there is a damage value above 55. If there's a better way of doing it, I too would like to know.
Source: https://www.reddit.com/r/GlobalOffensive/comments/2008gz/knife_differences_with_the_mouse1_and_mouse2/
Not really a CS person, but SDKHook's TraceAttack may have a hitgroup value for backstab (like it does for headshot).
Maxximou5
07-11-2016, 20:41
Not really a CS person, but SDKHook's TraceAttack may have a hitgroup value for backstab (like it does for headshot).
I read this before: https://forums.alliedmods.net/showthread.php?t=249126
Made me believe the hitgroup wouldn't work for it, you may be right as I didn't try TraceAttack; however, I decided to just skip that since HnS doesn't use weapons that do more damage than a knife. As anything above 55 is a critical knife stab in the back, and more so since slash (left click) isn't available, it can only be a stab.
I'll keep your suggestion in mind, thank you for that.
While I got your attention, I was wondering if you could help a guy whos trying to code a scramble plugin for me, but he has encoured some issues.
Thread: Click me! (https://forums.alliedmods.net/showthread.php?t=284991)
The information required is located on that thread, any help is appreciated!
vBulletin® v3.8.7, Copyright ©2000-2024, vBulletin Solutions, Inc.