AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Remove "x attacked a teammate" message (https://forums.alliedmods.net/showthread.php?t=245798)

aron9forever 08-07-2014 06:13

Remove "x attacked a teammate" message
 
Okay so I searched the web and couldn't find a solution for cs 1.6, only for css.
Apparently, this plugin removes said message, but I can't figure out how it does it.
Can anyone point me in the right direction? I'd like to remove the friendlyfire attack message because I run a jailbreak server and when 25 people start hitting eachother it spams the chat like hell.

Code:

/*        Copyright © 2008, ConnorMcLeod

        Free For All is free software;
        you can redistribute it and/or modify it under the terms of the
        GNU General Public License as published by the Free Software Foundation.

        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.

        You should have received a copy of the GNU General Public License
        along with Free For All; if not, write to the
        Free Software Foundation, Inc., 59 Temple Place - Suite 330,
        Boston, MA 02111-1307, USA.
*/

/*
v0.0.6
- Disable Forwards and registered message when plugin is disabled
v0.0.5
- Recursion should be fixed for all Ham forwards
- Removed Cvar, new command instead
- Hide Radar
v0.0.4
- Fixed HamKilled possible loop when a player kills himself
v0.0.3
- Removed useless vars
v0.0.2
- Block Radar
v0.0.1
- First shot
*/

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN "Free For All"
#define AUTHOR "ConnorMcLeod"
#define VERSION "0.0.6"

#define OFFSET_TEAM        114
#define fm_get_user_team(%1)        get_pdata_int(%1,OFFSET_TEAM)
#define fm_set_user_team(%1,%2)        set_pdata_int(%1,OFFSET_TEAM,%2)

new gmsgRadar
new g_iMaxPlayers
new mp_friendlyfire, g_iOldFFVal
new HamHook:g_hTraceAttack, HamHook:g_hTakeDamage, HamHook:g_hKilled, g_mRadarHook
new bool:g_bFFA

public plugin_init()
{
        register_plugin( PLUGIN, VERSION, AUTHOR )

        register_concmd("amx_set_ffa", "AdminCommand_SetFFA", ADMIN_CFG)
        register_clcmd("drawradar", "ClientCommand_DrawRadar") // not sure this is hookable but anyway Radar Msg is bloqued as well

        g_iMaxPlayers = get_maxplayers()
        mp_friendlyfire = get_cvar_pointer("mp_friendlyfire")
        g_iOldFFVal = get_pcvar_num(mp_friendlyfire)
        gmsgRadar = get_user_msgid("Radar")
}

public AdminCommand_SetFFA(id, level)
{
        if( !(get_user_flags(id) & level) )
        {
                return PLUGIN_HANDLED
        }

        if( read_argc() < 2 )
        {
                if( id )
                {
                        client_print(id, print_console, "Usage: amx_set_ffa <0|1>" )
                }
                else
                {
                        server_print( "Usage: amx_set_ffa <0|1>" )
                }
        }
        else
        {
                new szArg[3]
                read_argv(1, szArg, charsmax(szArg))
                if( g_bFFA && (szArg[0] == '0' || szArg[1] == 'f' || szArg[1] == 'F') )
                {
                        set_pcvar_num(mp_friendlyfire, g_iOldFFVal)
                        client_cmd(0, "drawradar")
                        Register_Forwards((g_bFFA=false))
                }
                else if( !g_bFFA && (szArg[0] == '1' || szArg[1] == 'n' || szArg[1] == 'N') )
                {
                        g_iOldFFVal = get_pcvar_num(mp_friendlyfire)
                        set_pcvar_num(mp_friendlyfire, 1)
                        client_cmd(0, "hideradar")
                        Register_Forwards((g_bFFA=true))
                }
        }
       
        if( id )
        {
                client_print(id, print_console, "FFA mode is %s", g_bFFA ? "On" : "Off" )
        }
        else
        {
                server_print( "FFA mode is %s", g_bFFA ? "On" : "Off" )
        }
        return PLUGIN_HANDLED
}

public client_connect(id)
{
        if( g_bFFA )
        {
                client_cmd(id, "hideradar")
        }
}

public TraceAttack(victim, attacker, Float:damage, Float:direction[3], tracehandle, damagebits)
{
        if( victim != attacker && (1 <= attacker <= g_iMaxPlayers) )
        {
                new vteam = fm_get_user_team(victim)
                if( vteam == fm_get_user_team(attacker) )
                {
                        fm_set_user_team(victim, vteam == 1 ? 2 : 1)
                        ExecuteHamB(Ham_TraceAttack, victim, attacker, damage, direction, tracehandle, damagebits)
                        fm_set_user_team(victim, vteam)
                        return HAM_SUPERCEDE
                }
        }
        return HAM_IGNORED
}

public TakeDamage(victim, idinflictor, attacker, Float:damage, damagebits)
{
        if( victim != attacker && (1 <= attacker <= g_iMaxPlayers) )
        {
                new vteam = fm_get_user_team(victim)
                if( vteam == fm_get_user_team(attacker) )
                {
                        fm_set_user_team(victim, vteam == 1 ? 2 : 1)
                        ExecuteHamB(Ham_TakeDamage, victim, idinflictor, attacker, damage, damagebits)
                        fm_set_user_team(victim, vteam)
                        return HAM_SUPERCEDE
                }
        }
        return HAM_IGNORED
}

public Killed(victim, attacker, shouldgib)
{
        if( victim != attacker && (1 <= attacker <= g_iMaxPlayers) )
        {
                new vteam = fm_get_user_team(victim)
                if( vteam == fm_get_user_team(attacker) )
                {
                        fm_set_user_team(victim, vteam == 1 ? 2 : 1)
                        ExecuteHamB(Ham_Killed, victim, attacker, shouldgib)
                        fm_set_user_team(victim, vteam)
                        return HAM_SUPERCEDE
                }
        }
        return HAM_IGNORED
}

public Message_Radar(iMsgId, MSG_DEST, id)
{
        return PLUGIN_HANDLED
}

public ClientCommand_DrawRadar(id)
{
        return _:g_bFFA
}

Register_Forwards(bool:bState)
{
        if(bState)
        {
                if( g_hTraceAttack )
                {
                        EnableHamForward( g_hTraceAttack )
                }
                else
                {
                        g_hTraceAttack = RegisterHam(Ham_TraceAttack, "player", "TraceAttack")
                }

                if( g_hTakeDamage )
                {
                        EnableHamForward( g_hTakeDamage )
                }
                else
                {
                        g_hTakeDamage = RegisterHam(Ham_TakeDamage, "player", "TakeDamage")
                }

                if( g_hKilled )
                {
                        EnableHamForward( g_hKilled )
                }
                else
                {
                        g_hKilled = RegisterHam(Ham_Killed, "player", "Killed")
                }

                if( !g_mRadarHook )
                {
                        g_mRadarHook = register_message( gmsgRadar, "Message_Radar")
                }
        }
        else
        {
                if( g_hTraceAttack )
                {
                        DisableHamForward( g_hTraceAttack )
                }

                if( g_hTakeDamage )
                {
                        DisableHamForward( g_hTakeDamage )
                }

                if( g_hKilled )
                {
                        DisableHamForward( g_hKilled )
                }

                if( g_mRadarHook )
                {
                        unregister_message(gmsgRadar, g_mRadarHook)
                        g_mRadarHook = 0
                }
        }
}

I know this is not really the proper section for this post but I just need some guidance, not necessarily an entire plugin, so no reason to request. Also I feel I'll get a faster answer here.

HamletEagle 08-07-2014 08:36

Re: Remove "x attacked a teammate" message
 
You want to remove that message, the plugin remove it, what's the problem ? If you can't understand the code, we can't help you. Read it more times, figure out how things are related.

PreDominance 08-07-2014 11:33

Re: Remove "x attacked a teammate" message
 
You could prehook the takedamage event, check if the victim and attacker teams are equal, deal the damage, then return plugin_handled. This should prevent the message from showing, I think.

aron9forever 08-08-2014 03:44

Re: Remove "x attacked a teammate" message
 
Quote:

Originally Posted by HamletEagle (Post 2180288)
You want to remove that message, the plugin remove it, what's the problem ? If you can't understand the code, we can't help you. Read it more times, figure out how things are related.

because I can't run a plugin like this on a jailbreak server
and I want to learn to do it myself

Quote:

Originally Posted by PreDominance (Post 2180380)
You could prehook the takedamage event, check if the victim and attacker teams are equal, deal the damage, then return plugin_handled. This should prevent the message from showing, I think.

thanks, I'll give it a shot

georgik57 08-08-2014 07:45

Re: Remove "x attacked a teammate" message
 
1 Attachment(s)
Code:
#include <amxmodx> public plugin_init() {     register_plugin("D7 block saytext team attack", "0.0.1", "D i 5 7 i n c T, Johnny got his gun")         register_message(get_user_msgid("SayText"), "message_SayText") } // Credits to Johnny got his gun public message_SayText() {     if (get_msg_args() > 4)         return PLUGIN_CONTINUE;         static szBuffer[40];     get_msg_arg_string(2, szBuffer, 39)         if (!equali(szBuffer, "#Cstrike_TitlesTXT_Game_teammate_attack"))         return PLUGIN_CONTINUE;         return PLUGIN_HANDLED; }

Dyskiu 07-19-2016 17:10

Re: Remove "x attacked a teammate" message
 
I know is old post, but i cant do it with: #Cstrike_TitlesTXT_C4_Plant_At_Bomb_Spot.

could someone help me? thanks...

georgik57 07-19-2016 17:33

Re: Remove "x attacked a teammate" message
 
Quote:

Originally Posted by Dyskiu (Post 2437885)
I know is old post, but i cant do it with: #Cstrike_TitlesTXT_C4_Plant_At_Bomb_Spot.

could someone help me? thanks...

because it's not a SayText(chat) message

Dyskiu 07-19-2016 17:38

Re: Remove "x attacked a teammate" message
 
Quote:

Originally Posted by georgik57 (Post 2437890)
because it's not a SayText(chat) message

yeah i figured that much :D thanks anyway.

If someone will need in future, this is solution:
Code:

    register_message(get_user_msgid("TextMsg"), "message_SayText");
Code:

public message_SayText()
{
    if (get_msg_args() > 4)
        return PLUGIN_CONTINUE;
   
    static szBuffer[23];
    get_msg_arg_string(2, szBuffer, 22)
   
    if (!equali(szBuffer, "#C4_Plant_At_Bomb_Spot") )
    {
        return PLUGIN_CONTINUE;
    }
    return PLUGIN_HANDLED;
}



All times are GMT -4. The time now is 13:15.

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