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.

meTaLiCroSS 02-03-2011 19:34

Re: [STOCK] Director Hud Message
 
Director HUDMessages style are the same as a common hudmessage? Or isn't?

Arkshine 02-03-2011 19:36

Re: [STOCK] Director Hud Message
 
Yes, basically. Except it doesn't use channel.

Quote:

Please tell me there's a way to remove an already displayed DHUD (that's how it'll be called from now on) message.
I have absolutely no idea. I don't think it's possible looking a the code, message are added each time. Will make some search though.

meTaLiCroSS 02-03-2011 19:39

Re: [STOCK] Director Hud Message
 
Oh, i'm gonna use this :D

Are the same as a HINT Message?

hleV 02-03-2011 19:40

Re: [STOCK] Director Hud Message
 
If you're gonna get the DHUD message removing to work, HUD messages will be replaced permanently :D. I'd finally release my Unreal Tournament 3 Reward Announcer.

Arkshine 02-03-2011 19:40

Re: [STOCK] Director Hud Message
 
Quote:

Are the same as a HINT Message?
Like said in the description, yes. Except you can use color and such.

meTaLiCroSS 02-03-2011 19:42

Re: [STOCK] Director Hud Message
 
Quote:

Originally Posted by hleV (Post 1406593)
If you'll get the DHUD message removing to work, HUD messages will be replaced permanently :D. I'd finally release my Unreal Tournament 3 Reward Announcer.

Agree.

Quote:

Originally Posted by Arkshine (Post 1406594)
Like said in the description, yes. Except you can use color and such.

Arkshine, we love you.

joaquimandrade 02-03-2011 19:44

Re: [STOCK] Director Hud Message
 
Congratulations and thanks.

Arkshine 02-03-2011 19:49

Re: [STOCK] Director Hud Message
 
It's possible to remove the message with 2 ugly ways :

- Resetting the hud (fullupdate) or whatever (offset?)
- Sending more than 8 blank messages. Here the declaration of the var : m_HUDMessageText[8][128];

Both are really a very poor solution. :/

meTaLiCroSS 02-03-2011 19:51

Re: [STOCK] Director Hud Message
 
Quote:

Originally Posted by Arkshine (Post 1406602)
It's possible to remove the message with 2 ugly ways :

- Resetting the hud (fullupdate) or whatever (offset?)
- Sending more than 8 blank messages. Here the declaration of the var : m_HUDMessageText[8][128];

Both are really a very poor solution. :/

It's possible to access that var?

joaquimandrade 02-03-2011 19:52

Re: [STOCK] Director Hud Message
 
Quote:

Originally Posted by Arkshine (Post 1406602)
It's possible to remove the message with 2 ugly ways :

- Resetting the hud (fullupdate) or whatever (offset?)
- Sending more than 8 blank messages. Here the declaration of the var : m_HUDMessageText[8][128];

Both are really a very poor solution. :/

what if you send a blank message and change

PHP Code:

 write_bytestrlenmessage ) + 31 ); 

to

PHP Code:

 write_byte128 31 ); 

Sorry if I'm saying bullshit.

Arkshine 02-03-2011 20:03

Re: [STOCK] Director Hud Message
 
Yes, you're saying bullshit. :mrgreen:

But thanks to try.

meTaLiCroSS 02-03-2011 20:21

Re: [STOCK] Director Hud Message
 
! character cannot be displayed :( (wrong)

How many ^n I can put?

Arkshine 02-03-2011 20:23

Re: [STOCK] Director Hud Message
 
"!" works for me.

^n as many you want until you don't go over 128 characters.

fezh 02-03-2011 20:50

Re: [STOCK] Director Hud Message
 
Quote:

Originally Posted by Arkshine (Post 1406614)
"!" works for me.

^n as many you want until you don't go over 128 characters.

In the case you pass the limit you can send another message :3

Ryokin 02-03-2011 22:28

Re: [STOCK] Director Hud Message
 
thx man, now i can set 4-8 hud msgs

5c0r-|3i0 02-03-2011 22:29

Re: [STOCK] Director Hud Message
 
Wow.....I never thought this could be done ^^.
Quote:

Great job.

drekes 02-03-2011 23:23

Re: [STOCK] Director Hud Message
 
Awesome, keep it up.

bibu 02-04-2011 03:21

Re: [STOCK] Director Hud Message
 
Great job, thanks for this. :)

xPaw 02-04-2011 07:50

Re: [STOCK] Director Hud Message
 
I'm xPaw :(

Arkshine 02-04-2011 07:51

Re: [STOCK] Director Hud Message
 
Fixed. ;)

xPaw 02-04-2011 07:57

Re: [STOCK] Director Hud Message
 
I wish this was added to amxx core, so we could still use set_hudmessage for it :D

EDIT: You forgot to add support for 0 index (all players)

Arkshine 02-04-2011 08:03

Re: [STOCK] Director Hud Message
 
Yes, I've seen that, I wanted to post asap. Will update later.

It's updated now. Added a new param reliableMsg also.

meTaLiCroSS 02-04-2011 13:22

Re: [STOCK] Director Hud Message
 
Which is the diff between a Reliable message, from an unreliable one?

bibu 02-04-2011 13:28

Re: [STOCK] Director Hud Message
 
Someone should make a new rules plugin by using these director hud messages.

Arkshine 02-04-2011 13:29

Re: [STOCK] Director Hud Message
 
Already explained somewhere, but basically, if you send the message into a reliable stream, the player will receive no matter what it happens the message but if there is a problem with the current stream or this message, server will crash. If you send the message into an unreliable stream, if there is a problem, the player might not receive the message or could be dropped but server will be fine.

Kreation 02-04-2011 13:52

Re: [STOCK] Director Hud Message
 
Thanks for this, it's going to be very very useful for me.

Great job. :mrgreen:

cFG 02-04-2011 15:33

Re: [STOCK] Director Hud Message
 
Niceeee!
As someone said before, it could be standard in newest amxmodx versions :wink:

@xPaw
knew it, rawr!

xPaw 02-04-2011 15:44

Re: [STOCK] Director Hud Message
 
Quote:

Originally Posted by cFG (Post 1407167)
Niceeee!
As someone said before, it could be standard in newest amxmodx versions :wink:

And requires minimal job to do that :grrr:

Lt.RAT 02-04-2011 18:20

Re: [STOCK] Director Hud Message
 
PHP Code:

    #define write_float(%0)      ( write_byte( ( _:%0 & 0xFF ) ),       \
                                   
write_byte( ( _:%>>  ) & 0xFF ), \
                                   
write_byte( ( _:%>> 16 ) & 0xFF ), \
                                   
write_byte( ( _:%>> 24 ) & 0xFF ) ) 

Isn`t complicated ?

PHP Code:

        write_long_:);
        
write_long_:);
        
write_long_:fadeInTime  );
        
write_long_:fadeOutTime  );
        
write_long_:holdTime );
        
write_long_:fxTime ); 

DHUD without Alpha channel :( And only 128 characters instead of 512 in regular HUD.

Exolent[jNr] 02-04-2011 21:15

Re: [STOCK] Director Hud Message
 
1 Attachment(s)
For those of you who wanted it to mimic the style of [set|show]_hudmessage(), here is an include that lets you do that.

All credits go to Arkshine (and others who helped) for making the original include.
The only thing I did was change how it is used.

Functions:
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:...)


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

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