AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [TF2] game_text_tf advertisements (https://forums.alliedmods.net/showthread.php?t=249770)

404UserNotFound 10-11-2014 19:56

[TF2] game_text_tf advertisements
 
1 Attachment(s)
So I reverse-engineered Mecha the Slag's Golden Wrench notification plugin and turned it into a message-displaying command.

Thing is, I'm at a brick wall in regards to what to do with this. The game_text_tf entity that the plugin calls on is so diverse and so easily modifiable that it could easily be used in so many ways.

Attached is an example plugin I made for this, and below is all the information you need on customizing this.


IDEAS FOR THIS
- TF2-specific "Advertisement" plugin that utilizes this to display adverts alongside the standard hint/top/chat/center/menu messages. - Would definitely like to see this made, just not sure on how to set it up properly. I'm thinking giving the option to choose the background color, icon, message text, which team to display it to.

- Incorporation into existing game mode plugins? - Could be neat in Jailbreak, TF2 Tower Defense, VS Saxton Hale/Freak Fortress 2



ICONS
For the "DispatchKeyValue(entity, "icon", "ico_build");" bit, you can use anything found within "tf/scripts/mod_textures.res" in place of "ico_build". This includes HUD elements (such as the Engineer's building status icons), killfeed icons and much more.


BACKGROUND VALUES
For DispatchKeyValue(entity, "background", "0");
0 - Grey
2 - Red
3 - Blue


TEAM-BASED DISPLAY
For DispatchKeyValue(entity, "display_to_team", "0");
0 - Everyone
2 - RED Team only
3 - BLU Team only


TARGETNAME
For DispatchKeyValue(entity, "targetname", "game_text1");

I don't know what this is. I've been trying to find info on "game_text1" in an effort to see if there's other things this can target (I'm thinking this could lead to different background styles)

Zephyrus 10-11-2014 20:03

Re: [TF2] game_text_tf advertisements
 
picture pls

404UserNotFound 10-11-2014 20:06

Re: [TF2] game_text_tf advertisements
 
Quote:

Originally Posted by Zephyrus (Post 2209995)
picture pls

Custom Weapons 2 just crashed my server (using Advanced Weaponiser 2 attributes plugin, Firkin' Flamer's alt-fire crashed it) so I can't grab a pic.

Gimme a few seconds and I'll grab some.

EDIT: Here you go! Grabbed a screenie of each background color and tried out 3 different HUD icons from mod_textures.txt (used to be mod_textures.res, I guess they renamed it):

http://www.unfgaming.net/imgs/HUDMessages.png

From top to bottom: hud_taunt_hint, hud_taunt_menu_icon and hud_spy_disguise_menu_icon.

You'll notice the lack of squishing. If you use icons whose height/width are the same, there won't be any squishing. For some icons however (such as ico_notify_golden_wrench from Mecha's plugin), they get squished due to being disproportioned (96w x 32h)

Zephyrus 10-11-2014 20:23

Re: [TF2] game_text_tf advertisements
 
this is nice, i wonder why it hasnt been used before, whats the max length of the message? does it support new line? btw i can tell you targetname is not used for anything :P its just an identifier for entities, can be anything

psychonic 10-11-2014 20:48

Re: [TF2] game_text_tf advertisements
 
Quote:

Originally Posted by Zephyrus (Post 2210000)
i wonder why it hasnt been used before

It has. I remember seeing it before, and a quick forum search shows references going back to 2008.

It can also be triggered by the HudNotifyCustom message as shown in the Snippets forum, https://forums.alliedmods.net/showthread.php?t=155911

404UserNotFound 10-11-2014 20:50

Re: [TF2] game_text_tf advertisements
 
Quote:

Originally Posted by psychonic (Post 2210005)
It has. I remember seeing it before, and a quick forum search shows references going back to 2008.

Mhm, it's been out for ages. As I've said before, I'd love to see a TF2-specific advertisement-type plugin that utilizes this.

I haven't figured out the max length of the message (not sure of the quickest way to go about this).

Quote:

Originally Posted by psychonic (Post 2210005)
It can also be triggered by the HudNotifyCustom message as shown in the Snippets forum, https://forums.alliedmods.net/showthread.php?t=155911

Oh beauty! Well if those natives in the INC had the fields for the icon, and had the background color/team display set separately, that would be perfect and could easily be merged into existing advertisements plugins.

pheadxdll 10-11-2014 21:12

Re: [TF2] game_text_tf advertisements
 
That explains the squishing. :up:

I think they are not used very much because they only show up for a few seconds (unless you hit the input repeatedly with a timer) and because these messages will not be seen by any players using the minimized TF2 HUD. And I don't believe they are multi-line, correct me if wrong.

friagram 10-13-2014 05:41

Re: [TF2] game_text_tf advertisements
 
I put them into some custom maps years ago, but never found much use aside from giving simple hints.
https://developer.valvesoftware.com/wiki/Game_text_tf

Iirc it also messages everyone on the team, which is quite annoying due to their placement.

ddhoward 10-17-2014 06:46

Re: [TF2] game_text_tf advertisements
 
someone test pls

http://ddhoward.bitbucket.org/script...me_text_tf.inc

Examples: These examples have been removed due to a change in how the order of arguments.

Also, the indentations of the different @param lines show up correctly in notepad and Notepad++, just not in a browser.

friagram 10-17-2014 14:26

Re: [TF2] game_text_tf advertisements
 
Quote:

Originally Posted by ddhoward (Post 2212068)
someone test pls

http://ddhoward.bitbucket.org/script...me_text_tf.inc

Examples:
PHP Code:

PrintTFText("this is a HUD message"TFTeam_Red_10.0); 

PHP Code:

PrintTFText("u r a butt"TFTeam_Unassigned30.0"hud_spy_disguise_menu_icon"); 

Also, the indentations of the different @param lines show up correctly in notepad and Notepad++, just not in a browser.

Gross..
I did this:
PHP Code:

public Action:MessageCmd(clientargs)
{
    if(
args >= 2)
    {
        new 
String:message[256];
        new 
String:time[3];
        new 
String:icon[64];
        new 
String:team[2];
        new 
String:color[2];
        
        
GetCmdArg(1message256);
        
GetCmdArg(2time3);
        
GetCmdArg(3icon64);
        
GetCmdArg(4team2);
        
GetCmdArg(5color2);
        
        
ReplaceString(message,512,"\\n","\n");
        
        
CreateTFmessage(messageStringToFloat(time), iconStringToInt(team), StringToInt(color));
    }
    else
    {
        
ReplyToCommand(client"[sm] usage: <message> <time> <icon> <team> <color>");
    }
    return 
Plugin_Handled;
}

CreateTFmessage(const String:message[], Float:time, const String:icon[]="leaderboard_streak"team 0color 0)
{
    new 
entity CreateEntityByName("game_text_tf");
    if(
entity != -1)
    {
        
DispatchKeyValue(entity"message"message);
        switch(
team)
        {
            case 
2DispatchKeyValue(entity"display_to_team""2");
            case 
3DispatchKeyValue(entity"display_to_team""3");
            default: 
DispatchKeyValue(entity"display_to_team""0");
        }
        switch(
color)
        {
            case 
2DispatchKeyValue(entity"background""3");
            case 
3DispatchKeyValue(entity"background""3");
            default: 
DispatchKeyValue(entity"background""3");
        }
        
DispatchKeyValue(entity"icon"icon);

        
DispatchSpawn(entity);
        
AcceptEntityInput(entity"Display");

        new 
Handle:data;
        
CreateDataTimer(3.0Timer_TFmessagedataTIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
        
WritePackCell(dataEntRefToEntIndex(entity));
        
WritePackFloat(dataGetEngineTime() + time);
    }
}

public 
Action:Timer_TFmessage(Handle:timerHandle:pack)
{
    
ResetPack(pack);
    new 
entity EntRefToEntIndex(ReadPackCell(pack));
    if(
entity != INVALID_ENT_REFERENCE)
    {
        if(
GetEngineTime() < ReadPackFloat(pack))
        {
            
AcceptEntityInput(entity"Display");

            return 
Plugin_Continue;
        }
        else
        {
            
AcceptEntityInput(entity"Kill");
        }
    }
    return 
Plugin_Stop;




All times are GMT -4. The time now is 11:23.

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