Raised This Month: $ Target: $400
 0% 

Remove "x attacked a teammate" message


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 08-07-2014 , 06:13   Remove "x attacked a teammate" message
Reply With Quote #1

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.
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.

Last edited by aron9forever; 08-07-2014 at 06:14.
aron9forever is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-07-2014 , 08:36   Re: Remove "x attacked a teammate" message
Reply With Quote #2

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.
HamletEagle is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 08-08-2014 , 03:44   Re: Remove "x attacked a teammate" message
Reply With Quote #3

Quote:
Originally Posted by HamletEagle View Post
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 View Post
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
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever is offline
PreDominance
Member
Join Date: Jul 2014
Old 08-07-2014 , 11:33   Re: Remove "x attacked a teammate" message
Reply With Quote #4

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.
PreDominance is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 08-08-2014 , 07:45   Re: Remove "x attacked a teammate" message
Reply With Quote #5

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; }
Attached Files
File Type: sma Get Plugin or Get Source (D7_block_saytext_team_attack.sma - 1301 views - 527 Bytes)
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
Old 08-25-2014, 09:28
ArthHa
This message has been deleted by ArthHa. Reason: sorry
Dyskiu
Junior Member
Join Date: May 2014
Old 07-19-2016 , 17:10   Re: Remove "x attacked a teammate" message
Reply With Quote #7

I know is old post, but i cant do it with: #Cstrike_TitlesTXT_C4_Plant_At_Bomb_Spot.

could someone help me? thanks...
Dyskiu is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 07-19-2016 , 17:33   Re: Remove "x attacked a teammate" message
Reply With Quote #8

Quote:
Originally Posted by Dyskiu View Post
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
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
Dyskiu
Junior Member
Join Date: May 2014
Old 07-19-2016 , 17:38   Re: Remove "x attacked a teammate" message
Reply With Quote #9

Quote:
Originally Posted by georgik57 View Post
because it's not a SayText(chat) message
yeah i figured that much 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;
}
Dyskiu 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 13:15.


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