How to make the shield is not destroyed when teammate attacks it?

GanHUNTER

Участник
Сообщения
39
Реакции
16
Hello.
As in the title. How to make the shield is not destroyed when teammate attacks it?

I tried to use sdkhook OnTakeDamage but when a player has a shield, teammate can still destroy it.
But when a player drop a shield to the ground, teammate cannot destroy it.

Can you help me?


Sorry for my bad english. xd

Regards. ;)
 
Решение
C-подобный:
L 06/29/2020 - 15:47:44: [DHOOKS] Unknown subsection "penetration_power" (expected "arguments"): line: 33 col: 21
L 06/29/2020 - 15:47:44: [SM] Error parsing gameconfig file "/home/data/dynamit5544/778539.csgo/csgo/addons/sourcemod/gamedata/teamshieldprotect.games.txt":
L 06/29/2020 - 15:47:44: [SM] Error 3 on line 33, col 21: Callback error
L 06/29/2020 - 15:47:44: [SM] Exception reported: Unable to open teamshieldprotect.games: Callback error
L 06/29/2020 - 15:47:44: [SM] Blaming: dmgshield.smx
L 06/29/2020 - 15:47:44: [SM] Call stack trace:
L 06/29/2020 - 15:47:44: [SM]   [0] GameData.GameData
L 06/29/2020 - 15:47:44: [SM]   [1] Line 16, C:\Users\Komputer\Desktop\scriptinghhh\dmgshield.sp::OnPluginStart
L 06/29/2020 - 15:47:44: [SM]...

vanz666

Участник
Сообщения
45
Реакции
157
Hello.
As in the title. How to make the shield is not destroyed when teammate attacks it?

I tried to use sdkhook OnTakeDamage but when a player has a shield, teammate can still destroy it.
But when a player drop a shield to the ground, teammate cannot destroy it.

Can you help me?


Sorry for my bad english. xd

Regards. ;)
Try this.
Tested on Windows, should also work on Linux.
You also need to install DHooks

C-подобный:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <dhooks>

#pragma newdecls required

int g_shieldAttacker = -1;

Handle g_detourFireBullet;
Handle g_detourIncreaseShieldDamage;

public void OnPluginStart()
{
    GameData conf = new GameData("teamshieldprotect.games");

    if (conf == null)
        SetFailState("Failed to load teamshieldprotect gamedata");

    if (!(g_detourFireBullet = DHookCreateFromConf(conf, "CCSPlayer::FireBullet")))
        SetFailState("Failed to setup detour for CCSPlayer::FireBullet");
 
    if (!(g_detourIncreaseShieldDamage = DHookCreateFromConf(conf, "CWeaponShield::IncreaseDamage")))
        SetFailState("Failed to setup detour for CWeaponShield::IncreaseDamage");
 
    delete conf;

    if (!DHookEnableDetour(g_detourFireBullet, false, Detour_OnFireBullet))
        SetFailState("Failed to detour CCSPlayer::FireBullet");
 
    if (!DHookEnableDetour(g_detourFireBullet, true, Detour_OnFireBulletPost))
        SetFailState("Failed to detour CCSPlayer::FireBullet post");
     
    if (!DHookEnableDetour(g_detourIncreaseShieldDamage, false, Detour_OnIncreaseShieldDamage))
        SetFailState("Failed to detour CWeaponShield::IncreaseDamage");
}

public MRESReturn Detour_OnFireBullet(int client, Handle params)
{
    g_shieldAttacker = client;
    return MRES_Ignored;
}

public MRESReturn Detour_OnFireBulletPost(int client, Handle params)
{
    g_shieldAttacker = -1;
    return MRES_Ignored;
}

public MRESReturn Detour_OnIncreaseShieldDamage(int entity, Handle params)
{
    if (g_shieldAttacker != -1)
    {
        int owner = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");
     
        if (owner > 0 && owner <= MaxClients && IsClientInGame(owner) && IsPlayerAlive(owner) && GetClientTeam(owner) == GetClientTeam(g_shieldAttacker))
            return MRES_Supercede;
    }

    return MRES_Ignored;
}
Форматирование (BB-код):
"Games"
{
    "csgo"
    {
        "Functions"
        {
            "CCSPlayer::FireBullet"
            {
                "signature" "CCSPlayer::FireBullet"
                "callconv" "thiscall"
                "return" "void"
                "this" "entity"
                "arguments"
                {
                    "origin"
                    {
                        "type" "object"
                        "size" "12"
                    }
                    "angles"
                    {
                        "type" "vectorptr"
                    }
                    "distance"
                    {
                        "type" "float"
                        "windows"
                        {
                            "register" "xmm3"
                        }
                    }
                    "penetration_power"
                    {
                        "type" "float"
                    }
                    "penetration"
                    {
                        "type" "int"
                    }
                    "bullet_type"
                    {
                        "type" "int"
                    }
                    "damage"
                    {
                        "type" "int"
                    }
                    "unknown"
                    {
                        "type" "int"
                    }
                    "range_modifier"
                    {
                        "type" "float"
                    }
                    "attacker"
                    {
                        "type" "cbaseentity"
                    }
                    "do_effects"
                    {
                        "type" "bool"
                    }
                    "spread_x"
                    {
                        "type" "float"
                    }
                    "spread_y"
                    {
                        "type" "float"
                    }
                }
            }
         
            "CWeaponShield::IncreaseDamage"
            {
                "signature" "CWeaponShield::IncreaseDamage"
                "callconv" "thiscall"
                "return" "void"
                "this" "entity"
                "arguments"
                {
                    "damage"
                    {
                        "type" "float"
                        "windows"
                        {
                            "register" "xmm1"
                        }
                    }
                }
            }
        }

        "Signatures"
        {
            "CCSPlayer::FireBullet"
            {
                "library" "server"
                "windows" "\x55\x8B\xEC\x83\xE4\xF0\x81\xEC\x2A\x2A\x2A\x2A\x66\x0F\x6E\x45\x2A\x8D\x94\x24\x2A\x2A\x2A\x2A"
                "linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\x2A\x2A\x2A\x2A\x0F\xB6\x45\x2A\xF3\x0F\x2A\x45\x2A\x88\x85\x2A\x2A\x2A\x2A\x8D\x85\x2A\x2A\x2A\x2A\x89\x44\x24\x2A\x8D\x85\x2A\x2A\x2A\x2A\x89\x44\x24\x2A\x8D\x85\x2A\x2A\x2A\x2A\x89\x44\x24\x2A\x8B\x45\x2A\xF3\x0F\x11\x45\x2A"
            }
         
            "CWeaponShield::IncreaseDamage"
            {
                "library" "server"
                "windows" "\x55\x8B\xEC\x83\xEC\x10\x53\x56\x57\xF3\x0F\x11\x4D\x2A"
                "linux" "\x55\x89\xE5\x83\xEC\x2A\x89\x5D\x2A\x8B\x5D\x2A\x89\x75\x2A\x89\x7D\x2A\x89\x1C\x24\xE8\x2A\x2A\x2A\x2A\x85\xC0\x89\xC6\x0F\x84\x2A\x2A\x2A\x2A\xC7\x44\x24\x2A\x2A\x2A\x2A\x2A"
            }
        }
    }
}
 
Последнее редактирование:

GanHUNTER

Участник
Сообщения
39
Реакции
16
Try this.
Tested on Windows, should also work on Linux.
You also need to install DHooks

C-подобный:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <dhooks>

#pragma newdecls required

int g_shieldAttacker = -1;

Handle g_detourFireBullet;
Handle g_detourIncreaseShieldDamage;

public void OnPluginStart()
{
    GameData conf = new GameData("teamshieldprotect.games");

    if (conf == null)
        SetFailState("Failed to load teamshieldprotect gamedata");

    if (!(g_detourFireBullet = DHookCreateFromConf(conf, "CCSPlayer::FireBullet")))
        SetFailState("Failed to setup detour for CCSPlayer::FireBullet");

    if (!(g_detourIncreaseShieldDamage = DHookCreateFromConf(conf, "CWeaponShield::IncreaseDamage")))
        SetFailState("Failed to setup detour for CWeaponShield::IncreaseDamage");

    delete conf;

    if (!DHookEnableDetour(g_detourFireBullet, false, Detour_OnFireBullet))
        SetFailState("Failed to detour CCSPlayer::FireBullet");

    if (!DHookEnableDetour(g_detourFireBullet, true, Detour_OnFireBulletPost))
        SetFailState("Failed to detour CCSPlayer::FireBullet post");
    
    if (!DHookEnableDetour(g_detourIncreaseShieldDamage, false, Detour_OnIncreaseShieldDamage))
        SetFailState("Failed to detour CWeaponShield::IncreaseDamage");
}

public MRESReturn Detour_OnFireBullet(int client, Handle params)
{
    g_shieldAttacker = client;
    return MRES_Ignored;
}

public MRESReturn Detour_OnFireBulletPost(int client, Handle params)
{
    g_shieldAttacker = -1;
    return MRES_Ignored;
}

public MRESReturn Detour_OnIncreaseShieldDamage(int entity, Handle params)
{
    if (g_shieldAttacker != -1)
    {
        int owner = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");
    
        if (owner > 0 && owner <= MaxClients && IsClientInGame(owner) && IsPlayerAlive(owner) && GetClientTeam(owner) == GetClientTeam(g_shieldAttacker))
            return MRES_Supercede;
    }

    return MRES_Ignored;
}
Форматирование (BB-код):
"Games"
{
    "csgo"
    {
        "Functions"
        {
            "CCSPlayer::FireBullet"
            {
                "signature" "CCSPlayer::FireBullet"
                "callconv" "thiscall"
                "return" "void"
                "this" "entity"
                "arguments"
                {
                    "origin"
                    {
                        "type" "object"
                        "size" "12"
                    }
                    "angles"
                    {
                        "type" "vectorptr"
                    }
                    "distance"
                    {
                        "type" "float"
                        "windows"
                        {
                            "register" "xmm3"
                        }
                    }
                    "penetration_power"
                    {
                        "type" "float"
                    }
                    "penetration"
                    {
                        "type" "int"
                    }
                    "bullet_type"
                    {
                        "type" "int"
                    }
                    "damage"
                    {
                        "type" "int"
                    }
                    "unknown"
                    {
                        "type" "int"
                    }
                    "range_modifier"
                    {
                        "type" "float"
                    }
                    "attacker"
                    {
                        "type" "cbaseentity"
                    }
                    "do_effects"
                    {
                        "type" "bool"
                    }
                    "spread_x"
                    {
                        "type" "float"
                    }
                    "spread_y"
                    {
                        "type" "float"
                    }
                }
            }
        
            "CWeaponShield::IncreaseDamage"
            {
                "signature" "CWeaponShield::IncreaseDamage"
                "callconv" "thiscall"
                "return" "void"
                "this" "entity"
                "arguments"
                {
                    "damage"
                    {
                        "type" "float"
                        "windows"
                        {
                            "register" "xmm1"
                        }
                    }
                }
            }
        }

        "Signatures"
        {
            "CCSPlayer::FireBullet"
            {
                "library" "server"
                "windows" "\x55\x8B\xEC\x83\xE4\xF0\x81\xEC\x2A\x2A\x2A\x2A\x66\x0F\x6E\x45\x2A\x8D\x94\x24\x2A\x2A\x2A\x2A"
                "linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\x2A\x2A\x2A\x2A\x0F\xB6\x45\x2A\xF3\x0F\x2A\x45\x2A\x88\x85\x2A\x2A\x2A\x2A\x8D\x85\x2A\x2A\x2A\x2A\x89\x44\x24\x2A\x8D\x85\x2A\x2A\x2A\x2A\x89\x44\x24\x2A\x8D\x85\x2A\x2A\x2A\x2A\x89\x44\x24\x2A\x8B\x45\x2A\xF3\x0F\x11\x45\x2A"
            }
        
            "CWeaponShield::IncreaseDamage"
            {
                "library" "server"
                "windows" "\x55\x8B\xEC\x83\xEC\x10\x53\x56\x57\xF3\x0F\x11\x4D\x2A"
                "linux" "\x55\x89\xE5\x83\xEC\x2A\x89\x5D\x2A\x8B\x5D\x2A\x89\x75\x2A\x89\x7D\x2A\x89\x1C\x24\xE8\x2A\x2A\x2A\x2A\x85\xC0\x89\xC6\x0F\x84\x2A\x2A\x2A\x2A\xC7\x44\x24\x2A\x2A\x2A\x2A\x2A"
            }
        }
    }
}

It doesn't work in linux. :(
 

GanHUNTER

Участник
Сообщения
39
Реакции
16

C-подобный:
L 06/29/2020 - 15:47:44: [DHOOKS] Unknown subsection "penetration_power" (expected "arguments"): line: 33 col: 21
L 06/29/2020 - 15:47:44: [SM] Error parsing gameconfig file "/home/data/dynamit5544/778539.csgo/csgo/addons/sourcemod/gamedata/teamshieldprotect.games.txt":
L 06/29/2020 - 15:47:44: [SM] Error 3 on line 33, col 21: Callback error
L 06/29/2020 - 15:47:44: [SM] Exception reported: Unable to open teamshieldprotect.games: Callback error
L 06/29/2020 - 15:47:44: [SM] Blaming: dmgshield.smx
L 06/29/2020 - 15:47:44: [SM] Call stack trace:
L 06/29/2020 - 15:47:44: [SM]   [0] GameData.GameData
L 06/29/2020 - 15:47:44: [SM]   [1] Line 16, C:\Users\Komputer\Desktop\scriptinghhh\dmgshield.sp::OnPluginStart
L 06/29/2020 - 15:47:44: [SM] Unable to load plugin "dmgshield.smx": Error detected in plugin startup (see error logs)

File teamshieldprotect.games is located in gamedata folder
 

vanz666

Участник
Сообщения
45
Реакции
157
C-подобный:
L 06/29/2020 - 15:47:44: [DHOOKS] Unknown subsection "penetration_power" (expected "arguments"): line: 33 col: 21
L 06/29/2020 - 15:47:44: [SM] Error parsing gameconfig file "/home/data/dynamit5544/778539.csgo/csgo/addons/sourcemod/gamedata/teamshieldprotect.games.txt":
L 06/29/2020 - 15:47:44: [SM] Error 3 on line 33, col 21: Callback error
L 06/29/2020 - 15:47:44: [SM] Exception reported: Unable to open teamshieldprotect.games: Callback error
L 06/29/2020 - 15:47:44: [SM] Blaming: dmgshield.smx
L 06/29/2020 - 15:47:44: [SM] Call stack trace:
L 06/29/2020 - 15:47:44: [SM]   [0] GameData.GameData
L 06/29/2020 - 15:47:44: [SM]   [1] Line 16, C:\Users\Komputer\Desktop\scriptinghhh\dmgshield.sp::OnPluginStart
L 06/29/2020 - 15:47:44: [SM] Unable to load plugin "dmgshield.smx": Error detected in plugin startup (see error logs)

File teamshieldprotect.games is located in gamedata folder
You are probably using an older version of DHooks.
Install the latest from here.
 

vanz666

Участник
Сообщения
45
Реакции
157
C-подобный:
L 06/29/2020 - 15:47:44: [DHOOKS] Unknown subsection "penetration_power" (expected "arguments"): line: 33 col: 21
L 06/29/2020 - 15:47:44: [SM] Error parsing gameconfig file "/home/data/dynamit5544/778539.csgo/csgo/addons/sourcemod/gamedata/teamshieldprotect.games.txt":
L 06/29/2020 - 15:47:44: [SM] Error 3 on line 33, col 21: Callback error
L 06/29/2020 - 15:47:44: [SM] Exception reported: Unable to open teamshieldprotect.games: Callback error
L 06/29/2020 - 15:47:44: [SM] Blaming: dmgshield.smx
L 06/29/2020 - 15:47:44: [SM] Call stack trace:
L 06/29/2020 - 15:47:44: [SM]   [0] GameData.GameData
L 06/29/2020 - 15:47:44: [SM]   [1] Line 16, C:\Users\Komputer\Desktop\scriptinghhh\dmgshield.sp::OnPluginStart
L 06/29/2020 - 15:47:44: [SM] Unable to load plugin "dmgshield.smx": Error detected in plugin startup (see error logs)

File teamshieldprotect.games is located in gamedata folder
Thanks. It helped

But the plugin still doesn't work.
Now this should work.
The signature for Linux has been updated and a check for a knife attack has been added.
C-подобный:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <dhooks>

#pragma newdecls required

int g_shieldAttacker = -1;

Handle g_detourFireBullet;
Handle g_detourIncreaseShieldDamage;
Handle g_detourPrimaryAttack;
Handle g_detourSecondaryAttack;

public void OnPluginStart()
{
    GameData conf = new GameData("teamshieldprotect.games");

    if (conf == null)
        SetFailState("Failed to load teamshieldprotect gamedata");

    if (!(g_detourFireBullet = DHookCreateFromConf(conf, "CCSPlayer::FireBullet")))
        SetFailState("Failed to setup detour for CCSPlayer::FireBullet");

    if (!(g_detourIncreaseShieldDamage = DHookCreateFromConf(conf, "CWeaponShield::IncreaseDamage")))
        SetFailState("Failed to setup detour for CWeaponShield::IncreaseDamage");
       
    if (!(g_detourPrimaryAttack = DHookCreateFromConf(conf, "CBaseCombatWeapon::PrimaryAttack")))
        SetFailState("Failed to setup detour for CBaseCombatWeapon::PrimaryAttack");
   
    if (!(g_detourSecondaryAttack = DHookCreateFromConf(conf, "CBaseCombatWeapon::SecondaryAttack")))
        SetFailState("Failed to setup detour for CBaseCombatWeapon::SecondaryAttack");

    delete conf;

    if (!DHookEnableDetour(g_detourFireBullet, false, Detour_OnFireBullet))
        SetFailState("Failed to detour CCSPlayer::FireBullet");

    if (!DHookEnableDetour(g_detourFireBullet, true, Detour_OnFireBulletPost))
        SetFailState("Failed to detour CCSPlayer::FireBullet post");
   
    if (!DHookEnableDetour(g_detourIncreaseShieldDamage, false, Detour_OnIncreaseShieldDamage))
        SetFailState("Failed to detour CWeaponShield::IncreaseDamage");

    DHookAddEntityListener(ListenType_Created, EntityCreated);
}

public void EntityCreated(int entity, const char[] classname)
{
    char clsname[32];
    GetEntityNetClass(entity, clsname, sizeof(clsname));

    if (!strcmp(clsname, "CKnife") ||
        !strcmp(clsname, "CKnifeGG"))
    {
        DHookEntity(g_detourPrimaryAttack, false, entity, _, Detour_OnKnifeAttack);
        DHookEntity(g_detourPrimaryAttack, true, entity, _, Detour_OnFireBulletPost);
        DHookEntity(g_detourSecondaryAttack, false, entity, _, Detour_OnKnifeAttack);
        DHookEntity(g_detourSecondaryAttack, true, entity, _, Detour_OnFireBulletPost);
    }
}

public MRESReturn Detour_OnKnifeAttack(int entity, Handle params)
{
    g_shieldAttacker = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");
    return MRES_Ignored;
}

public MRESReturn Detour_OnFireBullet(int client, Handle params)
{
    g_shieldAttacker = client;
    return MRES_Ignored;
}

public MRESReturn Detour_OnFireBulletPost(int client, Handle params)
{
    g_shieldAttacker = -1;
    return MRES_Ignored;
}

public MRESReturn Detour_OnIncreaseShieldDamage(int entity, Handle params)
{
    if (IsValidClient(g_shieldAttacker))
    {
        int owner = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");
   
        if (IsValidClient(owner) && GetClientTeam(owner) == GetClientTeam(g_shieldAttacker))
        {
            DHookSetParam(params, 1, 0.0);
            return MRES_ChangedHandled;
        }
    }

    return MRES_Ignored;
}

bool IsValidClient(int client)
{
    return (client > 0 && client <= MaxClients && IsClientInGame(client) && IsPlayerAlive(client));
}
Форматирование (BB-код):
"Games"
{
    "csgo"
    {
        "Functions"
        {
            "CCSPlayer::FireBullet"
            {
                "signature" "CCSPlayer::FireBullet"
                "callconv" "thiscall"
                "return" "void"
                "this" "entity"
                "arguments"
                {
                    "origin"
                    {
                        "type" "object"
                        "size" "12"
                    }
                    "angles"
                    {
                        "type" "vectorptr"
                    }
                    "distance"
                    {
                        "type" "float"
                        "windows"
                        {
                            "register" "xmm3"
                        }
                    }
                    "penetration_power"
                    {
                        "type" "float"
                    }
                    "penetration"
                    {
                        "type" "int"
                    }
                    "bullet_type"
                    {
                        "type" "int"
                    }
                    "damage"
                    {
                        "type" "int"
                    }
                    "unknown"
                    {
                        "type" "int"
                    }
                    "range_modifier"
                    {
                        "type" "float"
                    }
                    "attacker"
                    {
                        "type" "cbaseentity"
                    }
                    "do_effects"
                    {
                        "type" "bool"
                    }
                    "spread_x"
                    {
                        "type" "float"
                    }
                    "spread_y"
                    {
                        "type" "float"
                    }
                }
            }
            
            "CWeaponShield::IncreaseDamage"
            {
                "signature" "CWeaponShield::IncreaseDamage"
                "callconv" "thiscall"
                "return" "void"
                "this" "entity"
                "arguments"
                {
                    "damage"
                    {
                        "type" "float"
                        "windows"
                        {
                            "register" "xmm1"
                        }
                    }
                }
            }
            
            "CBaseCombatWeapon::PrimaryAttack"
            {
                "offset" "CBaseCombatWeapon::PrimaryAttack"
                "hooktype" "entity"
                "return" "void"
                "this" "entity"
            }
            
            "CBaseCombatWeapon::SecondaryAttack"
            {
                "offset" "CBaseCombatWeapon::SecondaryAttack"
                "hooktype" "entity"
                "return" "void"
                "this" "entity"
            }
        }

        "Offsets"
        {
            "CBaseCombatWeapon::PrimaryAttack"
            {
                "windows" "312"
                "linux" "318"
            }
            
            "CBaseCombatWeapon::SecondaryAttack"
            {
                "windows" "313"
                "linux" "319"
            }
        }

        "Signatures"
        {
            "CCSPlayer::FireBullet"
            {
                "library" "server"
                "windows" "\x55\x8B\xEC\x83\xE4\xF0\x81\xEC\x2A\x2A\x2A\x2A\x66\x0F\x6E\x45\x2A\x8D\x94\x24\x2A\x2A\x2A\x2A"
                "linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\xCC\x06\x00\x00\x0F\xB6\x45\x3C\xF3\x0F\x2A\x45\x2C\x88\x85\xBF\xF9\xFF\xFF\x8D\x85\x1C\xFF\xFF\xFF\x89\x44\x24\x0C\x8D\x85\x10\xFF\xFF\xFF\x89\x44\x24\x08\x8D\x85\x04\xFF\xFF\xFF\x89\x44\x24\x04\x8B\x45\x18\xF3\x0F\x11\x45\xD0"
            }
        
            "CWeaponShield::IncreaseDamage"
            {
                "library" "server"
                "windows" "\x55\x8B\xEC\x83\xEC\x10\x53\x56\x57\xF3\x0F\x11\x4D\x2A"
                "linux" "\x55\x89\xE5\x83\xEC\x2A\x89\x5D\x2A\x8B\x5D\x2A\x89\x75\x2A\x89\x7D\x2A\x89\x1C\x24\xE8\x2A\x2A\x2A\x2A\x85\xC0\x89\xC6\x0F\x84\x2A\x2A\x2A\x2A\xC7\x44\x24\x2A\x2A\x2A\x2A\x2A"
            }
        }
    }
}
 
Решение

GanHUNTER

Участник
Сообщения
39
Реакции
16
Now this should work.
The signature for Linux has been updated and a check for a knife attack has been added.
C-подобный:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <dhooks>

#pragma newdecls required

int g_shieldAttacker = -1;

Handle g_detourFireBullet;
Handle g_detourIncreaseShieldDamage;
Handle g_detourPrimaryAttack;
Handle g_detourSecondaryAttack;

public void OnPluginStart()
{
    GameData conf = new GameData("teamshieldprotect.games");

    if (conf == null)
        SetFailState("Failed to load teamshieldprotect gamedata");

    if (!(g_detourFireBullet = DHookCreateFromConf(conf, "CCSPlayer::FireBullet")))
        SetFailState("Failed to setup detour for CCSPlayer::FireBullet");

    if (!(g_detourIncreaseShieldDamage = DHookCreateFromConf(conf, "CWeaponShield::IncreaseDamage")))
        SetFailState("Failed to setup detour for CWeaponShield::IncreaseDamage");
      
    if (!(g_detourPrimaryAttack = DHookCreateFromConf(conf, "CBaseCombatWeapon::PrimaryAttack")))
        SetFailState("Failed to setup detour for CBaseCombatWeapon::PrimaryAttack");
  
    if (!(g_detourSecondaryAttack = DHookCreateFromConf(conf, "CBaseCombatWeapon::SecondaryAttack")))
        SetFailState("Failed to setup detour for CBaseCombatWeapon::SecondaryAttack");

    delete conf;

    if (!DHookEnableDetour(g_detourFireBullet, false, Detour_OnFireBullet))
        SetFailState("Failed to detour CCSPlayer::FireBullet");

    if (!DHookEnableDetour(g_detourFireBullet, true, Detour_OnFireBulletPost))
        SetFailState("Failed to detour CCSPlayer::FireBullet post");
  
    if (!DHookEnableDetour(g_detourIncreaseShieldDamage, false, Detour_OnIncreaseShieldDamage))
        SetFailState("Failed to detour CWeaponShield::IncreaseDamage");

    DHookAddEntityListener(ListenType_Created, EntityCreated);
}

public void EntityCreated(int entity, const char[] classname)
{
    char clsname[32];
    GetEntityNetClass(entity, clsname, sizeof(clsname));

    if (!strcmp(clsname, "CKnife") ||
        !strcmp(clsname, "CKnifeGG"))
    {
        DHookEntity(g_detourPrimaryAttack, false, entity, _, Detour_OnKnifeAttack);
        DHookEntity(g_detourPrimaryAttack, true, entity, _, Detour_OnFireBulletPost);
        DHookEntity(g_detourSecondaryAttack, false, entity, _, Detour_OnKnifeAttack);
        DHookEntity(g_detourSecondaryAttack, true, entity, _, Detour_OnFireBulletPost);
    }
}

public MRESReturn Detour_OnKnifeAttack(int entity, Handle params)
{
    g_shieldAttacker = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");
    return MRES_Ignored;
}

public MRESReturn Detour_OnFireBullet(int client, Handle params)
{
    g_shieldAttacker = client;
    return MRES_Ignored;
}

public MRESReturn Detour_OnFireBulletPost(int client, Handle params)
{
    g_shieldAttacker = -1;
    return MRES_Ignored;
}

public MRESReturn Detour_OnIncreaseShieldDamage(int entity, Handle params)
{
    if (IsValidClient(g_shieldAttacker))
    {
        int owner = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");
  
        if (IsValidClient(owner) && GetClientTeam(owner) == GetClientTeam(g_shieldAttacker))
        {
            DHookSetParam(params, 1, 0.0);
            return MRES_ChangedHandled;
        }
    }

    return MRES_Ignored;
}

bool IsValidClient(int client)
{
    return (client > 0 && client <= MaxClients && IsClientInGame(client) && IsPlayerAlive(client));
}
Форматирование (BB-код):
"Games"
{
    "csgo"
    {
        "Functions"
        {
            "CCSPlayer::FireBullet"
            {
                "signature" "CCSPlayer::FireBullet"
                "callconv" "thiscall"
                "return" "void"
                "this" "entity"
                "arguments"
                {
                    "origin"
                    {
                        "type" "object"
                        "size" "12"
                    }
                    "angles"
                    {
                        "type" "vectorptr"
                    }
                    "distance"
                    {
                        "type" "float"
                        "windows"
                        {
                            "register" "xmm3"
                        }
                    }
                    "penetration_power"
                    {
                        "type" "float"
                    }
                    "penetration"
                    {
                        "type" "int"
                    }
                    "bullet_type"
                    {
                        "type" "int"
                    }
                    "damage"
                    {
                        "type" "int"
                    }
                    "unknown"
                    {
                        "type" "int"
                    }
                    "range_modifier"
                    {
                        "type" "float"
                    }
                    "attacker"
                    {
                        "type" "cbaseentity"
                    }
                    "do_effects"
                    {
                        "type" "bool"
                    }
                    "spread_x"
                    {
                        "type" "float"
                    }
                    "spread_y"
                    {
                        "type" "float"
                    }
                }
            }
           
            "CWeaponShield::IncreaseDamage"
            {
                "signature" "CWeaponShield::IncreaseDamage"
                "callconv" "thiscall"
                "return" "void"
                "this" "entity"
                "arguments"
                {
                    "damage"
                    {
                        "type" "float"
                        "windows"
                        {
                            "register" "xmm1"
                        }
                    }
                }
            }
           
            "CBaseCombatWeapon::PrimaryAttack"
            {
                "offset" "CBaseCombatWeapon::PrimaryAttack"
                "hooktype" "entity"
                "return" "void"
                "this" "entity"
            }
           
            "CBaseCombatWeapon::SecondaryAttack"
            {
                "offset" "CBaseCombatWeapon::SecondaryAttack"
                "hooktype" "entity"
                "return" "void"
                "this" "entity"
            }
        }

        "Offsets"
        {
            "CBaseCombatWeapon::PrimaryAttack"
            {
                "windows" "312"
                "linux" "318"
            }
           
            "CBaseCombatWeapon::SecondaryAttack"
            {
                "windows" "313"
                "linux" "319"
            }
        }

        "Signatures"
        {
            "CCSPlayer::FireBullet"
            {
                "library" "server"
                "windows" "\x55\x8B\xEC\x83\xE4\xF0\x81\xEC\x2A\x2A\x2A\x2A\x66\x0F\x6E\x45\x2A\x8D\x94\x24\x2A\x2A\x2A\x2A"
                "linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\xCC\x06\x00\x00\x0F\xB6\x45\x3C\xF3\x0F\x2A\x45\x2C\x88\x85\xBF\xF9\xFF\xFF\x8D\x85\x1C\xFF\xFF\xFF\x89\x44\x24\x0C\x8D\x85\x10\xFF\xFF\xFF\x89\x44\x24\x08\x8D\x85\x04\xFF\xFF\xFF\x89\x44\x24\x04\x8B\x45\x18\xF3\x0F\x11\x45\xD0"
            }
       
            "CWeaponShield::IncreaseDamage"
            {
                "library" "server"
                "windows" "\x55\x8B\xEC\x83\xEC\x10\x53\x56\x57\xF3\x0F\x11\x4D\x2A"
                "linux" "\x55\x89\xE5\x83\xEC\x2A\x89\x5D\x2A\x8B\x5D\x2A\x89\x75\x2A\x89\x7D\x2A\x89\x1C\x24\xE8\x2A\x2A\x2A\x2A\x85\xC0\x89\xC6\x0F\x84\x2A\x2A\x2A\x2A\xC7\x44\x24\x2A\x2A\x2A\x2A\x2A"
            }
        }
    }
}
Damn.. It work!
You are amazing. :D Thank you!! :D
 

GanHUNTER

Участник
Сообщения
39
Реакции
16
Hello.
After the second last update CS:GO Valve broke this plugin. ☹

Can you repair this plugin @vanz666 ?? 😊

C-подобный:
L 08/09/2020 - 23:25:15: [SM] Exception reported: Failed to setup detour for CCSPlayer::FireBullet
L 08/09/2020 - 23:25:15: [SM] Blaming: dmgshield.smx
L 08/09/2020 - 23:25:15: [SM] Call stack trace:
L 08/09/2020 - 23:25:15: [SM]   [0] SetFailState
L 08/09/2020 - 23:25:15: [SM]   [1] Line 24, C:\Users\Komputer\Desktop\scriptinghhh\dmgshield.sp::OnPluginStart
 

GanHUNTER

Участник
Сообщения
39
Реакции
16
Can anyone help?


C-подобный:
L 08/09/2020 - 23:25:15: [SM] Exception reported: Failed to setup detour for CCSPlayer::FireBullet
L 08/09/2020 - 23:25:15: [SM] Blaming: dmgshield.smx
L 08/09/2020 - 23:25:15: [SM] Call stack trace:
L 08/09/2020 - 23:25:15: [SM]   [0] SetFailState
L 08/09/2020 - 23:25:15: [SM]   [1] Line 24, C:\Users\Komputer\Desktop\scriptinghhh\dmgshield.sp::OnPluginStart
 

vanz666

Участник
Сообщения
45
Реакции
157
Can anyone help?


C-подобный:
L 08/09/2020 - 23:25:15: [SM] Exception reported: Failed to setup detour for CCSPlayer::FireBullet
L 08/09/2020 - 23:25:15: [SM] Blaming: dmgshield.smx
L 08/09/2020 - 23:25:15: [SM] Call stack trace:
L 08/09/2020 - 23:25:15: [SM]   [0] SetFailState
L 08/09/2020 - 23:25:15: [SM]   [1] Line 24, C:\Users\Komputer\Desktop\scriptinghhh\dmgshield.sp::OnPluginStart
Updated
 

Вложения

  • teamshieldprotect.games.txt
    4.2 КБ · Просмотры: 8

sPonso™

Участник
Сообщения
169
Реакции
48
@vanz666
After the update on November 10, the signature offsets have changed, is it possible to get a new one?
Либо может кто другой подобрать новую сигнатуру, отблагодарю финансово
"CCSPlayer::FireBullet"
{
"library" "server"
"windows" "\x55\x8B\xEC\x83\xE4\xF0\x81\xEC\x2A\x2A\x2A\x2A\x66\x0F\x6E\x45\x2A\x8D\x94\x24\x2A\x2A\x2A\x2A"
"linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\x6C\x07\x00\x00"
}

L 11/10/2021 - 12:00:15: [SM] Exception reported: Failed to setup detour for CCSPlayer::FireBullet
L 11/10/2021 - 12:00:15: [SM] Blaming: shield_block_team.smx
L 11/10/2021 - 12:00:15: [SM] Call stack trace:
L 11/10/2021 - 12:00:15: [SM] [0] SetFailState
L 11/10/2021 - 12:00:15: [SM] [1] Line 24, C:\Users\sPonso\Desktop\ \\compile\addons\sourcemod\scripting\shield_block_team.sp::OnPluginStart
L 11/10/2021 - 12:00:15: [SM] Unable to load plugin "shield_block_team.smx": Error detected in plugin startup (see error logs)
 

Fanyatsu

Шизофреник со стажем
Сообщения
1,030
Реакции
341
Сверху Снизу