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

[CSGO] I can’t block CSGO Events


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Austin
Senior Member
Join Date: Oct 2005
Old 10-08-2021 , 19:51   [CSGO] I can’t block CSGO Events
Reply With Quote #1

According to these Sourcemod docs we can block events and they give this example to block headshots.
https://wiki.alliedmods.net/Events_(...Mod_Scripting)

I adding the logging line and built this for CSGO
and the “Blocking Headshot “ message is printed to the console when a player takes a headshot but it doesn’t block the headshots.

PHP Code:
public void OnPluginStart()
{
    
HookEvent("player_death"Event_PlayerDeathEventHookMode_Pre);
}
 
public 
Action Event_PlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    if (
event.GetBool("headshot"))
    {
      
PrintToServer("Blocking Headshot");
      return 
Plugin_Handled;
    }
    return 
Plugin_Continue;

I am interested in blocking these events and tried blocking them the same way (both Pre and Post) and no events are ever blocked.

round_end
hostage_rescued
hostage_rescued_all

Is there something different we have to do for CSGO to block events?
Austin is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 10-09-2021 , 02:46   Re: [CSGO] I can’t block CSGO Events
Reply With Quote #2

What are you actually trying to block, the headshot message or block the ability for a player to kill another with a headshot?

In the example you're referencing it's blocking the event message not the action.

Because you're hooking "player_death", which means the player has already died. If you want to block headshot damage you need something like this -
PHP Code:
#include <sdkhooks>

public void OnPluginStart()
{
    for (
int i 1<= MaxClientsi++)
    {
        if (!
IsClientInGame(i)) continue;
        
OnClientPutInServer(i);
    }
}

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

public 
Action Hook_OnTraceAttack(int victimint &attackerint &inflictorfloat &damageint &damagetypeint &ammotypeint hitboxint hitgroup)
{
    if (!(
attacker <= MaxClients))
        return 
Plugin_Continue;

    if (
IsClientInGame(attacker))
    {
        if (
hitgroup == 1)
            return 
Plugin_Continue;
        else
            return 
Plugin_Handled;
    }

    return 
Plugin_Continue;

or
PHP Code:
#include <sdkhooks>

public void OnPluginStart()
{
    for (
int i 1<= MaxClientsi++)
    {
        if (!
IsClientInGame(i)) continue;
        
OnClientPutInServer(i);
    }
}

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

public 
Action Hook_OnTakeDamage(int victimint &attackerint &inflictorfloat &damageint &damagetype)
{
    if (
IsClientInGame(victim))
    {
        if (
victim)
        {
            if (
damagetype DMG_HEADSHOT)
                return 
Plugin_Continue;
            else
                return 
Plugin_Handled;
        }
        else
            return 
Plugin_Handled;
    }

    return 
Plugin_Continue;

Maxximou5 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-09-2021 , 14:52   Re: [CSGO] I can’t block CSGO Events
Reply With Quote #3

events are messages, server is sending those to players.

And player own game is triggered by those, player game could play specific sound or print messages in they game.

Example if you pre hook bomb_planted and block it, player not hear sound "Bomb is planted" and can't get message of it.


...if you want to block actual bomb plant, you need dig deeper in game code and find offset/signature of it.
After that, you can change or break game behavior.


There is cvar in some games to stop round end or objective happening.
Code:
"mp_ignore_round_win_conditions" = "0"
 - Ignore conditions which would end the current round
__________________
Do not Private Message @me
Bacardi is offline
Austin
Senior Member
Join Date: Oct 2005
Old 10-11-2021 , 13:02   Re: [CSGO] I can’t block CSGO Events
Reply With Quote #4

Maxximou5
I was using the headshot example just because it was right from the SM docs. And not working as I expected.
I am right now only interested in blocking.
round_end
hostage_rescued
hostage_rescued_all

Thanks for the reply and example tho.
As a weird bit of info…
My #1 first ever plugin I wrote was to block humans from getting headshot from bots.
This was for condition zero in amx modx almost 20 years ago!

I since ported it to Sourcemod.
(I only reduce the headshot damage because the bots do weird things, or used to, if you totally remove it)
PHP Code:
public Action:HookTraceAttack(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotypehitboxHitGroup)
{
    if (!
attacker || attacker MaxClients)
        return 
Plugin_Continue;

    
// If a bot is the attacker and human being attacked, reduce the damage!
    
if(IsFakeClient(attacker) && !IsFakeClient(victim))
    {
        
//  head shot
        
if(HitGroup == 1)
        {
            
damage damage 0.001;
            return 
Plugin_Changed;
        } 
Bacardi
Thanks for the info.

I need to do more research obviously.

With SDKhook_ we block the Functions and I was hoping with
Hook() we could block the entire event before it is fired and thus would block the function call too.

Looking at what we can hook there isn’t anything to support hostage rescued events.
Is this the complete up to date list of what can be hooked?
Also where can I get a list of all events that can be used with Hook()?
https://forums.alliedmods.net/showthread.php?t=106748

And thanks for this setting
mp_ignore_round_win_conditions
I didn’t know about it but it dramatically affects the game like removing the time / removes all hostages / etc.

Can you please give me just the outline of where to look and what I would need to do to have totally control over hostage_rescued and hostage_rescued_all?

Would it be DHooks or would I finally have to be forced to learn sigscanning?

I actually would like to have SDKBotHook_ and wondering why no one has added better bot support in SM.
Austin is offline
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 11:47.


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