View Single Post
Author Message
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 02-05-2018 , 15:59   HUD and dHUD not playing along nicely?
Reply With Quote #1

Before I start, please know that there is a chance I misunderstood how huds and dhuds work and affect eachother in which case please correct my misassumptions.

The following code might look fat and unappealing at first but at a closer look, it's just some handy constants and stocks I created for use in my projects. All this code is doing is spamming 4 HUD messages on channels 1 to 4 every 0.5 seconds. It it also creating 5 DHUD messages every 5 seconds with a hold time of 5 seconds.

What I'm expecting is to have 9 permanent huds nicely sitting on my screen. What I have is 4 permanent HUDs, and a broken clusterfuck of dHUDS.

I was under the impression that dHUDs can also be used as a permanent display as long as the information does not need to be updated quicker than hold time (so not for health display, but maybe a clock?). However after creating a dHUD clock that displays every second with a holdtime of 1 second; other HUDs interfere and make my clock disappear even though there are no other dHUDs being displayed. So basically a single permanent dHUD is being broken by several other permanent HUDs once they pick up enough intensity.

Here's what it looks like: https://youtu.be/V0Is77y7Yh8

My problem in production (2 permanent HUDs, 1 dHUD and they don't work together) https://www.youtube.com/watch?v=FtyDvOJOvLg

Any help would be appreciated. I still have 1 hud channel free that I was saving for something else and now I'm worried everything will collide to crap because I am probably doing something wrong.
Code:
#include <amxmodx>

enum _:HUDLOCATIONS{
  HUD_CENTER,
  HUD_CENTER_UPPER,
  HUD_CENTER_LOWER,
  HUD_LEFT_CENTER,
  HUD_LEFT_UPPER,
  HUD_LEFT_LOWER,
  HUD_LEFT_LOWER_LOWER,
  HUD_RIGHT_CENTER,
  HUD_RIGHT_UPPER,
  HUD_RIGHT_LOWER,
  HUD_RIGHT_LOWER_LOWER
};

static const Float:HUD_COORDINATES[HUDLOCATIONS][] = {
  {-1.0, -1.0},
  {-1.0, 0.2},
  {-1.0, 0.9},
  {0.02, -1.0},
  {0.02, 0.2},
  {0.02, 0.75},
  {0.01, 0.92},
  {0.85, -1.0},
  {0.85, 0.2},
  {0.85, 0.85},
  {0.85, 0.92}
};

enum _:HUDCOLORS{
  HUD_COLOR_WHITE,
  HUD_COLOR_RED,
  HUD_COLOR_GREEN,
  HUD_COLOR_BLUE,
  HUD_COLOR_YELLOW,
  HUD_COLOR_MAGENTA,
  HUD_COLOR_CYAN,
  HUD_COLOR_ORANGE,
  HUD_COLOR_OCEAN,
  HUD_COLOR_MAROON
};

static const HUD_COLORS[HUDCOLORS][] = {
  {255, 255, 255},
  {255, 0, 0},
  {0, 255, 0},
  {0, 0, 255},
  {255, 255, 0},
  {255, 0, 255},
  {0, 255, 255},
  {227, 96, 8},
  {45, 89, 116},
  {103, 44, 38}
};

stock print_to_dhud_time(const id, const location, const color, const Float:holdtime, const input[], any:...) {
  static msg[191];
  vformat(msg, charsmax(msg), input, 6);

  set_dhudmessage(HUD_COLORS[color][0], HUD_COLORS[color][1], HUD_COLORS[color][2], HUD_COORDINATES[location][0], HUD_COORDINATES[location][1], 0, 3.0, holdtime, 0.15, 0.15);
  show_dhudmessage(id, msg);
}

stock print_to_hud_chan(const id, const location, const color, const chan = -1, const input[], any:...) {
  static msg[191];
  vformat(msg, charsmax(msg), input, 6);

  set_hudmessage(HUD_COLORS[color][0], HUD_COLORS[color][1], HUD_COLORS[color][2], HUD_COORDINATES[location][0], HUD_COORDINATES[location][1], 0, 3.0, 5.0, 0.15, 0.15, chan);
  show_hudmessage(id, msg);
}

public plugin_init() {
  set_task(1.0, "flash_stuff", 1337);

  set_task(1.0, "flash_Dstuff", 13379);
}

public flash_stuff() {
  print_to_hud_chan(0, HUD_LEFT_LOWER, HUD_COLOR_RED, 1, "XXXXXXXXXXXXXXXXX");
  print_to_hud_chan(0, HUD_RIGHT_LOWER, HUD_COLOR_RED, 2, "XXXXXXXXXXXXXXXXX");
  print_to_hud_chan(0, HUD_LEFT_UPPER, HUD_COLOR_RED, 3, "XXXXXXXXXXXXXXXXX");
  print_to_hud_chan(0, HUD_RIGHT_UPPER, HUD_COLOR_RED, 4, "XXXXXXXXXXXXXXXXX");
  set_task(0.5, "flash_stuff", 1337);
}

public flash_Dstuff() {
  print_to_dhud_time(0, HUD_CENTER_UPPER, HUD_COLOR_CYAN, 5.0, "DDDDDDDDDDDDDDDD");
  print_to_dhud_time(0, HUD_CENTER, HUD_COLOR_CYAN, 5.0, "DDDDDDDDDDDDDDDD");
  print_to_dhud_time(0, HUD_CENTER_LOWER, HUD_COLOR_CYAN, 5.0, "DDDDDDDDDDDDDDDD");
  print_to_dhud_time(0, HUD_LEFT_LOWER_LOWER, HUD_COLOR_CYAN, 5.0, "DDDDDDDDDDDDDDDD");
  print_to_dhud_time(0, HUD_RIGHT_LOWER_LOWER, HUD_COLOR_CYAN, 5.0, "DDDDDDDDDDDDDDDD");

  set_task(5.0, "flash_Dstuff", 13379);
}
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever is offline