AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   [INC] Director Hud Message (https://forums.alliedmods.net/showthread.php?t=149210)

Arkshine 02-03-2011 16:47

[INC] Director Hud Message
 
2 Attachment(s)
Director Hud Message
- last updated : 14 feb 2011

Ever wanted to display message like the hints messages in CS or on HLTV?
It should work on all mods. It uses basically the same params as set_hudmessage. (except for channel)
As side-note, the size is bigger than normal hud message and it can't be changed.

[IMG]http://img830.**************/img830/5036/hudt.th.png[/IMG]


│ Credits
MPNumB : original idea.
xPaw : original idea.
Exolent[jNr] : put the code in a .inc.

│ Limitations
Max message length : 128 characters.
You can show only 8 messages at once.

│ Developer Notes
The tip were in hud_spectator.cpp (line 526) in the HLSDK (client).

│ Functions
The following functions mimic the style of set_hudmessage() and show_hudmessage().

Code:

set_dhudmessage( red = 0, green = 160, blue = 0, Float:x = -1.0, Float:y = 0.65, effects = 2, Float:fxtime = 6.0, Float:holdtime = 3.0, Float:fadeintime = 0.1, Float:fadeouttime = 1.5, bool:reliable = false )
show_dhudmessage( index, const message[], any:... )


MPNumB 02-03-2011 16:52

Re: [STOCK] Director Hud Message
 
You'r crazy. Awesome! Always wanted it, but never got as close to succeed as you. :)

JocAnis 02-03-2011 17:31

Re: [STOCK] Director Hud Message
 
oh i wanted yesterday to ask how to get 'hudmessage' like on HLTV, and here is the answer. Really nice Arkshine.

1. question:
Are changing color bugged? First was your color '0 ~50 0' and i changed to blue, and now i m trying to change the color to ~orange but its still previously color (blue)...

code:
PHP Code:

#include <amxmodx>

public plugin_init()
{
    
register_clcmd"say /test""ClientCommand_Test" );
}

public 
ClientCommand_Testclient )
{
    
sendHudMessage
    

        .
index       client
        .
message     "Welcome to our server,^nWE ARE TESTINGQWEQWRQ",//no matter
        
.red         255,
        .
green       120,
        .
blue        0,
        .
x           0.05,
        .
y           0.2,
        .
effect      2,
        .
fxTime      17.0,
        .
holdTime    15.0,
        .
fadeInTime  0.1,
        .
fadeOutTime 3.0
    
);
}

sendHudMessage( const index, const message[], const red=255, const green=120, const blue=0
        const 
Float:x, const Float:y, const effect, const Float:fxTime
        const 
Float:holdTime, const Float:fadeInTime, const Float:fadeOutTime)//also and here i changed
{
    
#define pack_color(%0,%1,%2) ( %0 + ( %1 << 8 ) + ( %2 << 16 ) )
    #define write_float(%0)      ( write_byte( ( _:%0 & 0xFF ) ),       \
    
write_byte( ( _:%>>  ) & 0xFF ), \
    
write_byte( ( _:%>> 16 ) & 0xFF ), \
    
write_byte( ( _:%>> 24 ) & 0xFF ) )
    
    
message_beginMSG_ONESVC_DIRECTOR, .player index );
    {
        
write_bytestrlenmessage ) + 31 ); // size of write_*
        
write_byteDRC_CMD_MESSAGE );
        
write_byteeffect );
        
write_longpack_colorredgreenblue ) );
        
write_float);
        
write_float);
        
write_floatfadeInTime  );
        
write_floatfadeOutTime  );
        
write_floatholdTime );
        
write_floatfxTime );
        
write_stringmessage );
    }
    
message_end();


2. question:
Is there any way to put client's current name in that message?

Thank you.

Arkshine 02-03-2011 17:48

Re: [STOCK] Director Hud Message
 
1/ Tell me what you have done exactly, RGB value, I mean. So far I've tested color is fine. 255 120 0 work fine for me.

2/ Format the string before with the name. Don't ask more here, that's not the place.

fezh 02-03-2011 17:53

Re: [STOCK] Director Hud Message
 
This is actually pretty nice, good job.

MPNumB 02-03-2011 17:54

Re: [STOCK] Director Hud Message
 
1. Yes, red and blue are switched between. =P
fix for it is to change:
Code:

#define pack_color(%0,%1,%2) ( %0 + ( %1 << 8 ) + ( %2 << 16 ) )
to:
Code:

#define pack_color(%0,%1,%2) ( %2 + ( %1 << 8 ) + ( %0 << 16 ) )
2. Format a message before you call this function.

Arkshine 02-03-2011 17:58

Re: [STOCK] Director Hud Message
 
Ok I was pretty sure I was done such typo.

Fixed. ;)

EDIT: Forgot to update the sma too.

PRoSToTeM@ 02-03-2011 18:29

Re: [STOCK] Director Hud Message
 
Very good work! Always dreamed about it.

hleV 02-03-2011 18:45

Re: [STOCK] Director Hud Message
 
Wow. This is so much better than regular HUD messages:
  • doesn't seem to have a limit of 4 channels;
  • bigger;
  • no random disappearing.
Please tell me there's a way to remove an already displayed DHUD (that's how it'll be called from now on) message.

EDIT: Tested in ESF, the messages there are displayed as normal HUD messages but with DHUD features, like more than 4 channels, etc.

Exolent[jNr] 02-03-2011 18:59

Re: [STOCK] Director Hud Message
 
Great job.


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

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