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

[CS:GO] How to detect player got understabbed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Trayz
Junior Member
Join Date: Aug 2015
Location: Porto,Portugal
Old 08-22-2018 , 17:59   [CS:GO] How to detect player got understabbed
Reply With Quote #1

Hello , i have an HideNSeek Server , and i need a plugin to block damage from ct´s doing understabs on terrorists.

I tried porting this (plugin) and my solution failed here´s my attempt.

If someone can help me i will apreciate.
__________________
Trayz is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 08-22-2018 , 18:18   Re: [CS:GO] How to detect player got understabbed
Reply With Quote #2

Quote:
Originally Posted by Trayz View Post
Hello , i have an HideNSeek Server , and i need a plugin to block damage from ct´s doing understabs on terrorists.

I tried porting this (plugin) and my solution failed here´s my attempt.

If someone can help me i will apreciate.
Try getting their origins. Origin[2] is Z, also known as the height origin. If the CT's origin at the moment of the stab ( hook SDKHook_OnTakeDamage ) is lower than the terror's by X value ( be careful because if a CT crouches it reduces his origin so make it 75 or something ( Unsure ) he's definitely understabbing.
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
Trayz
Junior Member
Join Date: Aug 2015
Location: Porto,Portugal
Old 08-23-2018 , 18:54   Re: [CS:GO] How to detect player got understabbed
Reply With Quote #3

Can you show me an example because i dont know how to check that
__________________
Trayz is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 08-27-2018 , 04:39   Re: [CS:GO] How to detect player got understabbed
Reply With Quote #4

Quote:
Originally Posted by Trayz View Post
Can you show me an example because i dont know how to check that
new Float:Origin[3];
GetEntPropVector(client, Prop_Data, "m_vecOrigin", Origin);

Then tell me the following: if the height of the stabber is lower than the stabbed by say 75, it should be guaranteed to be an understab right? If you think yes, go ahead and test it. Then basically check

if(Origin[attacker] < Origin[victim] - 75)
{
// No damage? I think you wanted that.
}


ONE IMPORTANT THING!!!

You need this code to block out damage:

damage = 0.0;
return Plugin_Changed;
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334

Last edited by eyal282; 08-27-2018 at 04:40.
eyal282 is offline
Trayz
Junior Member
Join Date: Aug 2015
Location: Porto,Portugal
Old 08-29-2018 , 18:06   Re: [CS:GO] How to detect player got understabbed
Reply With Quote #5

Thank you @eyal282
If someone want the plugin code (this comes with HUD text for CS:GO)
PHP Code:
#include <sourcemod> 
#include <sdktools> 
#include <sdkhooks> 
#include <cstrike>

public void OnPluginStart() 
{
    for (
int client 1client <= MaxClientsclient++)
        if (
IsValidClient(client))
            
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);
}

public 
void OnClientPutInServer(int client)
{
    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);
}

public 
Action OnTakeDamage(int victimint &attackerint &inflictorfloat &damageint &damagetype
{
    if(
IsValidClient(victim) && IsValidClient(attacker) && IsPlayerAlive(victim) && IsPlayerAlive(attacker))
    {
        if(
victim == attacker)
            return 
Plugin_Continue;
        
        
float iAPos[3], iVPos[3]; 
        
char weapon_attacker[30];
        
GetEntPropVector(victimProp_Data"m_vecOrigin"iVPos);
        
GetEntPropVector(attackerProp_Data"m_vecOrigin"iAPos);
        
GetClientWeapon(attackerweapon_attackersizeof(weapon_attacker)); 
        
        if(
GetClientTeam(victim) != CS_TEAM_T)
            return 
Plugin_Continue;
        
        if(!
StrEqual("weapon_knife",weapon_attacker,true))
            return 
Plugin_Continue;

        if(
iAPos[2] < iVPos[2] - 75)
        {
            
char message[30];
            
Format(message,sizeof(message),"Understab Blocked");
            
SetHudTextParams(-1.00.1252.025525525525500.250.10.2);
            
ShowHudText(victim, -1message);
            
ShowHudText(attacker, -1message);
            
damage 0.0;
            return 
Plugin_Changed;
        }
    }
    return 
Plugin_Continue;
}

stock bool IsValidClient(int client)
{
    if(
client >= && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client))
    {
        return 
true;
    }
    
    return 
false;

__________________

Last edited by Trayz; 08-29-2018 at 18:06.
Trayz is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 08-30-2018 , 12:42   Re: [CS:GO] How to detect player got understabbed
Reply With Quote #6

Quote:
Originally Posted by Trayz View Post
Thank you @eyal282
If someone want the plugin code (this comes with HUD text for CS:GO)
PHP Code:
#include <sourcemod> 
#include <sdktools> 
#include <sdkhooks> 
#include <cstrike>

public void OnPluginStart() 
{
    for (
int client 1client <= MaxClientsclient++)
        if (
IsValidClient(client))
            
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);
}

public 
void OnClientPutInServer(int client)
{
    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);
}

public 
Action OnTakeDamage(int victimint &attackerint &inflictorfloat &damageint &damagetype
{
    if(
IsValidClient(victim) && IsValidClient(attacker) && IsPlayerAlive(victim) && IsPlayerAlive(attacker))
    {
        if(
victim == attacker)
            return 
Plugin_Continue;
        
        
float iAPos[3], iVPos[3]; 
        
char weapon_attacker[30];
        
GetEntPropVector(victimProp_Data"m_vecOrigin"iVPos);
        
GetEntPropVector(attackerProp_Data"m_vecOrigin"iAPos);
        
GetClientWeapon(attackerweapon_attackersizeof(weapon_attacker)); 
        
        if(
GetClientTeam(victim) != CS_TEAM_T)
            return 
Plugin_Continue;
        
        if(!
StrEqual("weapon_knife",weapon_attacker,true))
            return 
Plugin_Continue;

        if(
iAPos[2] < iVPos[2] - 75)
        {
            
char message[30];
            
Format(message,sizeof(message),"Understab Blocked");
            
SetHudTextParams(-1.00.1252.025525525525500.250.10.2);
            
ShowHudText(victim, -1message);
            
ShowHudText(attacker, -1message);
            
damage 0.0;
            return 
Plugin_Changed;
        }
    }
    return 
Plugin_Continue;
}

stock bool IsValidClient(int client)
{
    if(
client >= && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client))
    {
        return 
true;
    }
    
    return 
false;

That's great .

Don't forget to mark as solved.
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-30-2018 , 17:04   Re: [CS:GO] How to detect player got understabbed
Reply With Quote #7

Rather than checking for the knife class in a string, why not check for damagetype DMG_SLASH?
__________________
Neuro Toxin is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 08-31-2018 , 07:42   Re: [CS:GO] How to detect player got understabbed
Reply With Quote #8

Quote:
Originally Posted by Neuro Toxin View Post
Rather than checking for the knife class in a string, why not check for damagetype DMG_SLASH?
Might be edited theoretically by another plugin into DMG_ACID or something ( I did that before )
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 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 18:51.


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