Raised This Month: $51 Target: $400
 12% 

HUD messages in multiple locations


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hagvan
Junior Member
Join Date: Apr 2018
Old 03-01-2019 , 05:24   HUD messages in multiple locations
Reply With Quote #1

Hello everyone,

I am making a plugin which makes use of the HUD feature. How can I have multiple channels assigned to different locations on the screen? For an example, I want some general info to be at top-center, buffs/debuffs panel at left-center and cooldowns on right-center.

Is it possible to do or I must use a separate plugin for each location?
Hagvan is offline
farawayf
Senior Member
Join Date: Jan 2019
Old 03-01-2019 , 05:40   Re: HUD messages in multiple locations
Reply With Quote #2

Use this include

Example: SendHudMessage(client, 3, -2.0, 0.0, 0xFF0000FF, 0xFFFFFFFF, 0, 2.0, 1.0, 1.5, 5.0,
* @param client Client index.
* @param channel Channel index (Only 1 channel can write message).
* @param posx Position x on monitor (-1.0 = center).
* @param posy Position y on monitor (-1.0 = center).
* @param color1 First color in HEX.
* @param color2 Second color in HEX.
* @param effect Effect index (0 is fade in/fade out; 1 is flickery credits; 2 is write out).
* @param fadetime FadeIn time.
* @param fadeouttime FadeOut time.
* @param holdtime Hold time.
* @param fxtime Effect time (Effect type 2 used)
* @param message Message
* @param ... Variable number of format parameters.
* @return 1 or 0.

PHP Code:
/**
** Created by horr0rjkee
** Thanks for Alex(tracker) for ColorHexToRGB function! Wiki link: [url]https://wiki.alliedmods.net/User_messages[/url]
** Date: 18 July 2014
*/
#if defined easy_hud_message
    #endinput
#endif
#define easy_hud_message
/**
 * Return colors from HEX to RGB format.
 *
 * @param color        HEX color with transparent (Example: 0xFF00FFFF - Fully red color). Get any color from colorpicker.com.
 * @param outr        Red color.
 * @param outg        Green color.
 * @param outb        Blue color.
 * @param outalpha    Transparent.
 * @return            1 or 0.            
 */
stock bool:ColorHexToRGB(color, &outr, &outg, &outb, &outalpha) { //by Alex (Tracker)
    
outr=(color 0xFF000000)>>>24;
    
outg=(color 0x00FF0000)>>16;
    
outb=(color 0x0000FF00)>>8;
    
outalpha=color 0x000000FF;
    return 
true;
}
/**
 * Prints hud message to player
 *
 * @param client        Client index.
 * @param channel        Channel index (Only 1 channel can write message).
 * @param posx            Position x on monitor (-1.0 = center).
 * @param posy            Position y on monitor (-1.0 = center).
 * @param color1        First color in HEX.
 * @param color2        Second color in HEX.
 * @param effect        Effect index (0 is fade in/fade out; 1 is flickery credits; 2 is write out).
 * @param fadetime        FadeIn time.
 * @param fadeouttime    FadeOut time.
 * @param holdtime        Hold time.
 * @param fxtime        Effect time (Effect type 2 used)
 * @param message        Message
 * @param ...            Variable number of format parameters.
 * @return                1 or 0.    
 */
stock bool:SendHudMessage(client,channel=3,Float:posx=-1.0Float:posy=-1.0,color1,color2,effect=0,Float:fadetime=1.0,Float:fadeouttime=1.0,Float:holdtime=1.5,Float:fxtime=5.0,const String:message[],any:...)
{
    if(
client == || !IsClientConnected(client) || effect || fadetime 0.0 || fadeouttime 0.0 || holdtime 0.0 || fxtime 0.0) return false;
    new 
String:buffer[256];
    
SetGlobalTransTarget(client);
    
VFormat(buffersizeof(buffer), message13);
    new 
Handle:hBf StartMessageOne("HudMsg"client), rgb[4];
    
BfWriteByte(hBfchannel); //channel
    
BfWriteFloat(hBfposx); // x ( -1 = center )
    
BfWriteFloat(hBfposy); // y ( -1 = center )
    // second color
    
ColorHexToRGB(color1rgb[0], rgb[1], rgb[2], rgb[3]);
    
BfWriteByte(hBfrgb[0]); //r1
    
BfWriteByte(hBfrgb[1]); //g1
    
BfWriteByte(hBfrgb[2]); //b1
    
BfWriteByte(hBfrgb[3]); //a1 // transparent?
    // init color
    
ColorHexToRGB(color2rgb[0], rgb[1], rgb[2], rgb[3]);
    
BfWriteByte(hBfrgb[0]); //r2
    
BfWriteByte(hBfrgb[1]); //g2
    
BfWriteByte(hBfrgb[2]); //b2
    
BfWriteByte(hBfrgb[3]); //a2
    
BfWriteByte(hBfeffect); //effect (0 is fade in/fade out; 1 is flickery credits; 2 is write out)
    
BfWriteFloat(hBffadetime); //fadeinTime (message fade in time - per character in effect 2)
    
BfWriteFloat(hBffadeouttime); //fadeoutTime
    
BfWriteFloat(hBfholdtime); //holdtime
    
BfWriteFloat(hBffxtime); //fxtime (effect type(2) used)
    
BfWriteString(hBfbuffer); //Message
    
EndMessage();
    return 
true;


Last edited by farawayf; 03-01-2019 at 05:42.
farawayf is offline
Hagvan
Junior Member
Join Date: Apr 2018
Old 03-01-2019 , 05:56   Re: HUD messages in multiple locations
Reply With Quote #3

So, I don't have to use HUD Synchronizer?
Hagvan is offline
farawayf
Senior Member
Join Date: Jan 2019
Old 03-01-2019 , 05:59   Re: HUD messages in multiple locations
Reply With Quote #4

Quote:
Originally Posted by Hagvan View Post
So, I don't have to use HUD Synchronizer?
no, you dont need. Just use 1 message per one channel.
farawayf is offline
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 03-01-2019 , 12:29   Re: HUD messages in multiple locations
Reply With Quote #5

Quote:
Originally Posted by Hagvan View Post
So, I don't have to use HUD Synchronizer?
You should use Synchronizer.
Each separate hud must have different synchronizer.

If you need 2 HUDs then create 2 Synchronizers and do what you want.

PHP Code:
Handle hHud1hHud2hHud3;
public 
void OnPluginStart()
{
    
hHud1 CreateHudSynchronizer();
    
hHud2 CreateHudSynchronizer();
    
hHud3 CreateHudSynchronizer();
}

/*somewhere/*
{
Format(szBuffer, sizeof(szBuffer), "something")
SetHudTextParams(0.2, 0.2, 5.0, 255,0, 0, 255, 0, 0.0, 0.0, 0.0);
ShowSyncHudText(client, hHud1, "%s", szBuffer);

Format(szBuffer, sizeof(szBuffer), "something")
SetHudTextParams(0.5, 0.5, 5.0, 255,0, 0, 255, 0, 0.0, 0.0, 0.0);
ShowSyncHudText(client, hHud2, "%s", szBuffer);
Format(szBuffer, sizeof(szBuffer), "something")

SetHudTextParams(0.1, 0.7, 5.0, 255,0, 0, 255, 0, 0.0, 0.0, 0.0);
ShowSyncHudText(client, hHud3, "%s", szBuffer);


Last edited by impossible_cc; 03-01-2019 at 12:43.
impossible_cc is offline
adma
Senior Member
Join Date: Oct 2015
Old 03-02-2019 , 04:30   Re: HUD messages in multiple locations
Reply With Quote #6

Quote:
Originally Posted by impossible_cc View Post
You should use Synchronizer.
Each separate hud must have different synchronizer.

If you need 2 HUDs then create 2 Synchronizers and do what you want.

PHP Code:
Handle hHud1hHud2hHud3;
public 
void OnPluginStart()
{
    
hHud1 CreateHudSynchronizer();
    
hHud2 CreateHudSynchronizer();
    
hHud3 CreateHudSynchronizer();
}

/*somewhere/*
{
Format(szBuffer, sizeof(szBuffer), "something")
SetHudTextParams(0.2, 0.2, 5.0, 255,0, 0, 255, 0, 0.0, 0.0, 0.0);
ShowSyncHudText(client, hHud1, "%s", szBuffer);

Format(szBuffer, sizeof(szBuffer), "something")
SetHudTextParams(0.5, 0.5, 5.0, 255,0, 0, 255, 0, 0.0, 0.0, 0.0);
ShowSyncHudText(client, hHud2, "%s", szBuffer);
Format(szBuffer, sizeof(szBuffer), "something")

SetHudTextParams(0.1, 0.7, 5.0, 255,0, 0, 255, 0, 0.0, 0.0, 0.0);
ShowSyncHudText(client, hHud3, "%s", szBuffer);

I don't know much about the background of HUD synchs, so I ask, why do you suggest using hud syncs over the stock mentioned?
adma is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 03-02-2019 , 09:04   Re: HUD messages in multiple locations
Reply With Quote #7

Quote:
Originally Posted by adma View Post
I don't know much about the background of HUD synchs, so I ask, why do you suggest using hud syncs over the stock mentioned?
To quote the CreateHudSynchronizer docs:

Quote:
This ensures that if you display text on a sync object, that the previous text displayed on it will always be cleared first.
and

Quote:
These are particularly useful for displaying repeating or refreshing HUD text, in addition to displaying multiple message sets in one area of the screen (for example, center-say messages that may pop up randomly that you don't want to overlap each other).
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Hagvan
Junior Member
Join Date: Apr 2018
Old 03-03-2019 , 06:08   Re: HUD messages in multiple locations
Reply With Quote #8

I used the first option, thanks to the channels it is working fine for updating the text. I'll later upload the plugin I made. It will still need some work, but maybe people will like it.
Hagvan is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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