AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] Bump text on hudmessage? (https://forums.alliedmods.net/showthread.php?t=127705)

mysticssjgoku4 05-23-2010 22:11

[SOLVED] Bump text on hudmessage?
 
Anyone know how to bump the text down using format?
Say this function is called twice, I want to display the last text shown below the new text.

I have been playing around with it, but it has been so long since I last did any kind of tricks with format.

Any ideas?


Code:
g_Buffer += format(g_Message,sizeof(g_Message)-g_Buffer,"text^n");

fysiks 05-23-2010 22:13

Re: Bump text on hudmessage?
 
afaik it's automatic. When I do 3 tsay messages in a row they who one under the other.

mysticssjgoku4 05-23-2010 22:30

Re: Bump text on hudmessage?
 
Code:
new g_Messages[3][256]; fn() {         new message[256]     format(message,255,"Text!^nCongratulations!, %s^n^n",ANotify,g_Names[id]);         copy(g_Messages[0],255,g_Messages[1]);     copy(g_Messages[1],255,g_Messages[2]);     copy(g_Messages[2],255,message);         new Messages[768];     format(Messages,767,"%s%s%s",g_Messages[2],g_Messages[1],g_Messages[0]); }

Hmm...this is all I could come up with. There's gotta be a better way...no?

Alka 05-24-2010 16:56

Re: Bump text on hudmessage?
 
You can check this plugin.I don't know if it's exactly what your looking for, but w/e :-D

Exolent[jNr] 05-24-2010 17:05

Re: Bump text on hudmessage?
 
Code:
#define MAX_MESSAGES 3 new g_szMessages[ MAX_MESSAGES ][ 256 ]; new g_iMessageOffset; AddMessage( const szMessageFmt[ ], any:... ) {     vformat( g_szMessages[ g_iMessageOffset ], charsmax( g_szMessages[ ] ), szMessageFmt, 2 );         g_iMessageOffset = ++g_iMessageOffset % MAX_MESSAGES; } GetMessages( szOutput[ ], const iLen ) {     setc( szOutput, iLen, 0 );         for( new i = MAX_MESSAGES - 1; i >= 0; i-- )     {         add( szOutput, iLen, g_szMessages[ ( i + g_iMessageOffset ) % MAX_MESSAGES ] );     } }

Code:
YourFunction( ) {     AddMessage( "Text!^nCongratulations!, %s^n^n", ANotify, g_Names[ id ] );         new szMessages[ 768 ];     GetMessages( szMessages, charsmax( szMessages ) );         // .. }

Bugsy 05-24-2010 21:07

Re: Bump text on hudmessage?
 
Are you using an array of strings or just one string with a new-line between lines?

PHP Code:

#define AddText(%1,%2,%3)    (format(%1,%2,"%s^n%s",%3,%1))

//Usage:
AddTextszDestString charsmaxszDestString ) , "Add_to_Top" ); 

Example output when called 10 times with a number incrementing + 1 each pass:
Code:

10
9
8
7
6
5
4
3
2
1


mysticssjgoku4 05-25-2010 01:36

Re: Bump text on hudmessage?
 
Thank you exolent! Great code, had to change one line of your code, but implemented works exactly as I wanted. Strange that I could not do that with format. Hmm could've sworn I had done that before, but that is alright.
Thank you all!

----
PS change
Code:
copyc( szOutput, iLen, 0 );

to

Code:
copyc( szOutput, iLen, "", 0 );

Exolent[jNr] 05-25-2010 17:35

Re: Bump text on hudmessage?
 
Quote:

Originally Posted by mysticssjgoku4 (Post 1190434)
PS change
Code:
copyc( szOutput, iLen, 0 );

to

Code:
copyc( szOutput, iLen, "", 0 );

I meant to use setc() instead of copyc().


All times are GMT -4. The time now is 05:19.

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