I thought I posted this a long time ago, but it turns out I didn't.
This is used to print Valve translations to chat, hint text, center text, or client console. Basically, this is a wrapper for the TextMsg usermessage. This plugin supports both Protobuffer (CSGO) and Bitbuffer (everything else) usermessages.
Note: These translations only exist on the client, so servers can't read them
Note 2: Translation strings always start with #
Note 3: These cannot be called inside a UserMessage handler because it sends another UserMessage.
Enums/Constants
PHP Code:
enum Destination
{
Destination_HintText = 1,
Destination_ClientConsole = 2,
Destination_Chat = 3,
Destination_CenterText = 4,
}
Functions
PHP Code:
stock void PrintValveTranslation(int[] clients,
int numClients,
Destination msg_dest,
const char[] msg_name,
const char[] param1="",
const char[] param2="",
const char[] param3="",
const char[] param4="")
stock void PrintValveTranslationToAll(Destination msg_dest,
const char[] msg_name,
const char[] param1="",
const char[] param2="",
const char[] param3="",
const char[] param4="")
stock void PrintValveTranslationToOne(int client,
Destination msg_dest,
const char[] msg_name,
const char[] param1="",
const char[] param2="",
const char[] param3="",
const char[] param4="")
You need to look up the translation string in the game's translation files, which are located on the client in the resource directory; if you don't find it, it may instead exist in the game's vpk files. Each translation also has between 0 and 4 parameters which are either normal strings or a different (0 parameter) translation string starting with #.
For example, in TF2's tf_english.txt, you have this line:
Code:
"game_player_left_game" "%s1 left the game (%s2)"
This is a translation string with 2 parameters. The first is a player's name and the second can either be anything you want or a translation string.
For instance, if we want to send the message that a player was kicked due to inactivity:
PHP Code:
char name[MAX_NAME_LENGTH];
if (GetClientName(client, name, sizeof(name)))
{
PrintValveTranslationToAll(Destination_Chat, "#game_player_left_game", name, "#TF_Idle_kicked");
}
(This is kind of a troll move, but it serves as a good example)
A sample plugin for TF2 and CS:GO is attached.