AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   More Flexible HUD Msg (https://forums.alliedmods.net/showthread.php?t=69263)

[ --<-@ ] Black Rose 03-31-2008 14:09

More Flexible HUD Msg
 
Code:
/* * id * Player to send the message to. *   0 = everyone * * text[] *   Text to send. * * Float:X *   X position on screen. * * Float:Y *   Y position on screen. * * R *   Red color. * * G *   Green color. * * B *   Blue color. * * A *   Alpha. *   Default value: 255 * * Float:holdtime *   Float:fadeintime *   Time to fade in message *   Default value: 0.1 * * Float:fadeouttime *   Time to fade out message *   Default value: 0.1 * * channel *   Textchannel *   -1 = auto choose. *   Default value: -1 * * effect *   Effect of message. *   1 = Flicker with 2nd color. *   2 = Print out as 2nd color, fade into 1st color. *     effecttime decides fade time between colors. *     fadeintime decides how fast the letters should be printed out. *   Default value: 0 * * effect_R *   Red color of effect. *   Default value: 0 * * effect_G *   Green color of effect. *   Default value: 0 * * effect_B *   Blue color of effect. *   Default value: 0 * * effect_A *   Alpha of effect. *   Default value: 255 * * Float:effecttime *   Only for effect 2. *   Default value: 0.0 */ stock send_hudmessage(id,text[],Float:X,Float:Y,R,G,B,A=255,Float:holdtime=5.0,Float:fadeintime=0.1,Float:fadeouttime=0.1,channel=-1,effect=0,effect_R=0,effect_G=0,effect_B=0,effect_A=255,Float:effecttime=0.0) {         if ( id )         message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, {0,0,0}, id);     else         message_begin(MSG_BROADCAST, SVC_TEMPENTITY);     write_byte(TE_TEXTMESSAGE)     write_byte(channel)     write_short(coord_to_hudmsgshort(X))     write_short(coord_to_hudmsgshort(Y))     write_byte(effect)     write_byte(R)       write_byte(G)     write_byte(B)     write_byte(A)     write_byte(effect_R)     write_byte(effect_G)     write_byte(effect_B)     write_byte(effect_A)     write_short(seconds_to_hudmsgshort(fadeintime))     write_short(seconds_to_hudmsgshort(fadeouttime))     write_short(seconds_to_hudmsgshort(holdtime))     if ( effect == 2 )         write_short(seconds_to_hudmsgshort(effecttime));     write_string(text)     message_end() } /* 0.0 - 255.99609375 seconds */ stock seconds_to_hudmsgshort(Float:sec) {     new output = floatround(sec * 256);     return output < 0 ? 0 : output > 65535 ? 65535 : output; } stock coord_to_hudmsgshort(Float:coord) {     new output = floatround(coord * 8192);     return output < -32768 ? -32768 : output > 32767 ? 32767 : output; }

ConnorMcLeod 03-31-2008 14:13

Re: More Flexible HUD Msg
 
Nice, i was planing to test something like that one of those day.
Good job :up:

Alka 03-31-2008 15:11

Re: More Flexible HUD Msg
 
Woot thing! Good job

DaKo 07-20-2008 14:47

Re: More Flexible HUD Msg
 
Very nice! Good Job. :up:

Voi 10-06-2010 16:18

Re: More Flexible HUD Msg
 
Any chance this could support multilanguage ?

Exolent[jNr] 10-06-2010 16:23

Re: More Flexible HUD Msg
 
Quote:

Originally Posted by Voi (Post 1317275)
Any chance this could support multilanguage ?

Loop through players and format the message by ML, then pass the message to the function.

Voi 10-13-2010 14:26

Re: More Flexible HUD Msg
 
Quote:

Originally Posted by Exolent[jNr] (Post 1317282)
Loop through players and format the message by ML, then pass the message to the function.

I'm not sure how to do what you say. Could you provide an explanation or example ? Obviously I want each message sent to one player only.

Exolent[jNr] 10-14-2010 03:24

Re: More Flexible HUD Msg
 
Code:
new szMessage[ 192 ]; formatex( szMessage, charsmax( szMessage ), "%L", LANG_PLAYER, "LANG_KEY_HERE" ); send_hudmessage( 0, szMessage, /* other arguments here */ ); // -> new szMessage[ 192 ]; new iPlayers[ 32 ], iNum; get_players( iPlayers, iNum ); new iPlayer; for( new i = 0; i < iNum; i++ ) {     iPlayer = iPlayers[ i ];         formatex( szMessage, charsmax( szMessage ), "%L", iPlayer, "LANG_KEY_HERE" );         send_hudmessage( iPlayer, szMessage, /* other arguments here */ ); }

albert123 10-22-2010 02:49

Re: More Flexible HUD Msg
 
Oh,really useful.

xakintosh 11-25-2010 03:12

Re: More Flexible HUD Msg
 
In this way, can i put as much as you want hud messages on the screen of the user?


All times are GMT -4. The time now is 17:57.

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