AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how to show translated text in hud? (https://forums.alliedmods.net/showthread.php?t=334121)

kww 08-30-2021 06:31

how to show translated text in hud?
 
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!"

CrazY. 08-30-2021 08:40

Re: how to show translated text in hud?
 
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")


kww 08-30-2021 11:40

Re: how to show translated text in hud?
 
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?


All times are GMT -4. The time now is 02:34.

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