I need help to change or delete the quote "Player has left the game" when someone leaves the server. (I don't need to change anything about the joining message, it's ok)
I know it's possible,i've seen this before on a server. I want to replace the original quote, not adding another line with a plugin.
Joce93, the default HL disconnect message is sent via a SayText MSG.
Try hooking that before trying TextMsg. If that doesn't work then try hooking
different messages until you find the right one: HudText , HudTextPro etc.
Joce93, the default HL disconnect message is sent via a SayText MSG.
Try hooking that before trying TextMsg. If that doesn't work then try hooking
different messages until you find the right one: HudText , HudTextPro etc.
Here you go, this is just an example of what to do. The type and usage of Connect/Disconnect messages
may depend on The MOD. For instance, TFC sends a TextMsg Disconnect message with a localized string
for the 2nd (string) parameter and the disconnecting player name for the 3rd (string) parameter.
The code is set to override the connect/disconnect message witha custom one,
to just block the messages, comment out the line: #define OVERRIDE
Spoiler
Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#pragma semicolon 1
#pragma ctrlchar '\'
#define PLUGIN_NAME "Join/Discon Test"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "SpannerSpammer"
#define HUD_PRINTNOTIFY 1
#define OVERRIDE
new g_max_players;
public plugin_init( )
{
register_plugin( PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR );
register_message( get_user_msgid( "TextMsg" ), "Msg_TextMsg" );
register_message( get_user_msgid( "SayText" ), "Msg_SayText" );
g_max_players = get_maxplayers();
}
public Msg_SayText( msg_id, msg_dest, msg_entity )
{
new szMsg[80], szText[80], szName[33];
new id = get_msg_arg_int( 1 ); // index of disconnecting player is sent to all clients.
if ( !pev_valid(id) || (id < 1) || (id > g_max_players) || is_user_hltv(id) ) return PLUGIN_CONTINUE; // invalid index, bail.
get_user_name( id, szName, charsmax(szName) );
format( szText, charsmax(szText), "- %s has left the game\n", szName );
get_msg_arg_string( 2, szMsg, charsmax(szMsg) );
if ( ( msg_dest == MSG_ALL ) && (equal( szMsg, szText ) || contain( szMsg, "has left the game" ) ))
{
#if defined OVERRIDE
format( szText, charsmax(szText), "- %s has RAGE QUIT, what a loser\n", szName );
set_msg_arg_string( 2, szText );
#else // Block Msg
// client_print( 0, print_chat, "Got Player Disconnect Message.\n" ); // uncomment to test if block works
return PLUGIN_HANDLED;
#endif
}
return PLUGIN_CONTINUE;
}
public Msg_TextMsg( msg_id, msg_dest, msg_entity )
{
new szMsg[80];
new iType = get_msg_arg_int( 1 );
if ( ( msg_dest == MSG_ALL ) && ( iType == HUD_PRINTNOTIFY ) )
{
get_msg_arg_string( 2, szMsg, charsmax(szMsg) );
if ( contain( szMsg, "has joined the game" ) || equal( szMsg, "#Game_playerjoin") )
{
#if defined OVERRIDE
new szName[33];
if ( ( szMsg[0] == '#' ) && (get_msg_args() > 2) ) // its a localized string, 3rd parameter sent is joining player name.
{
get_msg_arg_string( 3, szName, charsmax(szName) );
}
else
{
parse( szMsg, szName, charsmax(szName) );
}
// NOTE: This destroys any localized string functionality for connect message.
szMsg[0] = 0;
format( szMsg, charsmax(szMsg), "%s has joined the game, Welcome FRESH MEAT!\n", szName );
set_msg_arg_string( 2, szMsg );
if (get_msg_args() > 2)
set_msg_arg_string( 3, "" );
#else // Block Msg
// client_print( 0, print_chat, "Got Player Connect/Join Message.\n" ); // uncomment to test if block works
return PLUGIN_HANDLED;
#endif
}
}
return PLUGIN_CONTINUE;
}
Forgot to add: If the MOD uses a titles.txt file, check and see if there is a
localized text entry for a connection message ( %s has joined the game ) etc.
For TFC it looks like:
Code:
Game_playerjoin
{
%s has joined the game
}
This is sent via a TextMsg message as the 2nd parameter, all localized strings are preceded
with the # chracter so the string is sent as: #Game_playerjoin. The 3rd parameter
of the message is the player name.