View Single Post
Muhlex
Junior Member
Join Date: Mar 2019
Old 06-04-2020 , 18:38   Re: [CS:GO] Replace regular Scoreboard with Deathmatch Scoreboard
Reply With Quote #7

I'll just paste in the code I threw together rather quickly. Might clean it up further and release it as a small helper plugin later.

This blocks the respawn sound that can be heard by everyone in the vicinity. (There does seem to be a small metal sound on respawn that can't be heard in the world. I didn't block this yet but it should be possible as well. It's barely noticable though.)

It also blocks dominations (maybe in an ugly way?); removes the ear-shattering killsound; blocks all of the 'you got X points for a kill' chat-messages; and prevents any chickens from spawning.

Additionally you can use the convars
Code:
mp_dm_time_between_bonus_max "99999"
mp_dm_time_between_bonus_min "99999"

mp_tdm_healthshot_killcount "0"
to get rid of bonus weapons and the healthshot on X kills.

PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <cstrike>

public void OnPluginStart()
{
    
AddNormalSoundHook(SoundHook_Normal);
    
HookEvent("player_death"GameEvent_PlayerDeathEventHookMode_Pre);
    
HookUserMessage(GetUserMessageId("TextMsg"), Event_TextMsgtrue);
}

public 
Action SoundHook_Normal(int iClients[MAXPLAYERS], int &iNumClientschar szSample[PLATFORM_MAX_PATH], int &iEntityint &iChannelfloat &fVolumeint &iLevelint &iPitchint &iFlagschar szSoundEntry[PLATFORM_MAX_PATH], int &iSeed)
{
    
// Prevent player respawning sounds
    
if (StrContains(szSample"player/pl_respawn.wav") != -1) return Plugin_Stop;

    return 
Plugin_Continue;
}

public 
Action GameEvent_PlayerDeath(Event eEvent, const char[] szNamebool bDontBroadcast)
{
    
int iVictim GetClientOfUserId(GetEventInt(eEvent"userid"));
    
int iAttacker GetClientOfUserId(GetEventInt(eEvent"attacker"));

    if (
iVictim && IsClientInGame(iVictim))
        
// Remove being dominated from Victim
        
SetEntProp(iVictimProp_Send"m_bPlayerDominatingMe"false_iAttacker);

    if (
iAttacker && IsClientInGame(iAttacker))
    {
        
// Remove dominations from Attacker
        
SetEntProp(iAttackerProp_Send"m_bPlayerDominated"false_iVictim);
        
eEvent.SetBool("dominated"false);

        
// Prevent Killsound
        // seems to not work sometimes, so we do it again in the request frame
        
StopSound(iAttackerSNDCHAN_ITEM"buttons/bell1.wav");

        
RequestFrame(RequestFrame_PlayerGetKillGetClientUserId(iAttacker));
    }

    return 
Plugin_Continue;
}

void RequestFrame_PlayerGetKill(int iUserID)
{
    
int iClient GetClientOfUserId(iUserID);
    if (!
iClient || !IsClientInGame(iClient)) return;

    
// Prevent Killsound
    
StopSound(iClientSNDCHAN_ITEM"buttons/bell1.wav");
}

public 
Action Event_TextMsg(UserMsg msgIDHandle hPb, const int[] iPlayersint iPlayersNumbool bReliablebool bInit)
{
    if (
bReliable)
    {
        
// Block chat messages for DM-Points on Kill
        
char szText[64];
        
PbReadString(hPb"params"szTextsizeof(szText),0);
        if (
StrContains(szText"#Player_Point_Award_"false) != -1)
            return 
Plugin_Handled;
    }
    return 
Plugin_Continue;
}

// Block Chicken Spawning
public void OnEntityCreated(int iEntity, const char[] szClassName)
{
    if (
StrContains(szClassName"chicken"false) == -1) return;
    
SDKHook(iEntitySDKHook_SpawnHook_ChickenSpawned);
}

public 
Action Hook_ChickenSpawned(int iChicken) {
    if (
IsValidEntity(iChicken))
        
AcceptEntityInput(iChicken"Kill");

    return 
Plugin_Stop;


Last edited by Muhlex; 06-04-2020 at 18:39.
Muhlex is offline