Raised This Month: $319 Target: $400
 79%   Almost there!

Print Valve Translations to clients


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 02-03-2019 , 14:22   Print Valve Translations to clients
Reply With Quote #1

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(clientnamesizeof(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.
Attached Files
File Type: inc printvalvetranslation.inc (4.2 KB, 185 views)
File Type: sp Get Plugin or Get Source (valvetranslationtest.sp - 168 views - 5.3 KB)
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 02-03-2019 at 17:51.
Powerlord is offline
sekac
Senior Member
Join Date: Nov 2016
Old 10-13-2021 , 07:46   Re: Print Valve Translations to clients
Reply With Quote #2

Destination_HintText not working in CSGO
sekac is offline
Reply


Thread Tools
Display Modes

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 19:45.


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