Raised This Month: $51 Target: $400
 12% 

how to show translated text in hud?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 08-30-2021 , 06:31   how to show translated text in hud?
Reply With Quote #1

Hi. How can I show translated text keys (like "#Bomb_Planted", etc.) in HUD messages? So instead of "#Bomb_Planted" players will see "The bomb has been planted!"
__________________
Now working on: Side Weapons (Very lazy, tbh)
Avatar source: https://bit.ly/3BAk19g
Discord: kww#9951
kww is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 08-30-2021 , 08:40   Re: how to show translated text in hud?
Reply With Quote #2

You would use TextMsg to do that. I implemented the following code based on regamedll source, refer to for more examples. Make sure you to not pass a string with length greater than 190 characters, otherwise the server will probably crash.

Code:
enum
{
	HUD_PRINTNOTIFY = 1,
	HUD_PRINTCONSOLE,
	HUD_PRINTTALK,
	HUD_PRINTCENTER,
	HUD_PRINTRADIO
}

new gmsgTextMsg

...

public plugin_init()
{
	gmsgTextMsg = get_user_msgid("TextMsg")
}

...

// Print to everyone
UTIL_ClientPrintAll(msg_dest, msg_name[], param1[]="", param2[]="", param3[]="", param4[]="")
{
	message_begin(MSG_ALL, gmsgTextMsg)
	write_string(msg_name)
	if (param1[0])
		write_string(param1)
	if (param2[0])
		write_string(param2)
	if (param3[0])
		write_string(param3)
	if (param4[0])
		write_string(param4)
	message_end()
}

// Print to single client
UTIL_ClientPrint(client, msg_dest, msg_name[], param1[]="", param2[]="", param3[]="", param4[]="")
{
	message_begin(MSG_ONE, gmsgTextMsg, _, client)
	write_string(msg_name)
	if (param1[0])
		write_string(param1)
	if (param2[0])
		write_string(param2)
	if (param3[0])
		write_string(param3)
	if (param4[0])
		write_string(param4)
	message_end()
}

// Usage
UTIL_ClientPrintAll(HUD_PRINTCENTER, "#Bomb_Defused")
__________________









Last edited by CrazY.; 08-30-2021 at 08:43.
CrazY. is offline
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 08-30-2021 , 11:40   Re: how to show translated text in hud?
Reply With Quote #3

tysm for this useful snippet i will steal it, but i wanted a bit different (maybe I asked the question incorrectly). Is it possible to show that texts with hud_showmessage?
__________________
Now working on: Side Weapons (Very lazy, tbh)
Avatar source: https://bit.ly/3BAk19g
Discord: kww#9951

Last edited by kww; 08-30-2021 at 11:41.
kww 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 07:01.


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