AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with ZP Hud (https://forums.alliedmods.net/showthread.php?t=320859)

sfjdfjdfj 01-12-2020 20:21

Help with ZP Hud
 
Hello, what I want is to change the color of the hud but change from several colors that transforms, for example, to green and then transforms to green

I don't know if it's possible? I had a zombie plague where that could be but I wanted to know how, My hud changes color but only blinks white

This is the part of the script where the hud is located


if(g_hud_type[ID_SHOWHUD] == 0) { // Default
set_hudmessage(40, 230, 76, -8.0, 0.75, 1, 6.0, 1.1, 0.0, 0.0, -1)
ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync[1], "|%s|^n|%L - %s| - |%L - %s|^n|%L - %s| - |%L - %s|^n", g_playername[ID_SHOWHUD], id, "ZOMBIE_ATTRIB1", add_point(get_user_health(ID_SHOWHUD)), id, "ZOMBIE_ATTRIB5", add_point(get_user_armor(ID_SHOWHUD)), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1",
add_point(g_ammopacks[ID_SHOWHUD]))

}

sfjdfjdfj 01-12-2020 20:22

Re: Help with ZP Hud
 
I clarify what I want is not to change color, what I want is for the same hud to change color as time goes by and change to several colors

OciXCrom 01-13-2020 14:19

Re: Help with ZP Hud
 
If you want to use random colors, simply replace the first 3 arguments in "set_hudmessage" with "random(256)".

If you want to use a predefined set of colors of your choioce, then things will get a little more complicated. You will need to create a 3-dimensional array that holds each set of colors, and then iterate that array and use its elements as arguments in "set_hudmessage".

Example of how the array should be created:

Code:
static const HUD_COLORS[][] = {     { 255, 0, 0 },     { 0, 255, 0 },     { 0, 0, 255 },     { 255, 255, 255 } }

* Note: I used "static" because I defined it as a local array. If you need to use it in more than one place, define it as a global variable using "new".

Add/remove as many colors as you want.

Then you will need a variable (global new or local static) that holds the current iteration, starting from 0, up to the size of the array.

Code:
static CURRENT_COLOR

Then, use the "set_hudmessage" function with the current color set:

Code:
set_hudmessage(HUD_COLORS[CURRENT_COLOR][0], HUD_COLORS[CURRENT_COLOR][1], HUD_COLORS[CURRENT_COLOR][2], /* all other arguments stay the same */)

Display the message and all other stuff related to it.

Next, add +1 to the "CURRENT_COLOR" variable. If it reached the end of the array, reset it back to 0.

Code:
if(++CURRENT_COLOR == sizeof(HUD_COLORS)) {     CURRENT_COLOR = 0 }

georgik57 01-13-2020 18:05

Re: Help with ZP Hud
 
I recommend keeping red to at least 50(random_num(50, 255)) if you're gonna use fully random colors or else you will just get washed out or ugly ones.

Abhinash 01-14-2020 09:32

Re: Help with ZP Hud
 
Quote:

Originally Posted by OciXCrom (Post 2680103)
If you want to use random colors, simply replace the first 3 arguments in "set_hudmessage" with "random(256)".

If you want to use a predefined set of colors of your choioce, then things will get a little more complicated. You will need to create a 3-dimensional array that holds each set of colors, and then iterate that array and use its elements as arguments in "set_hudmessage".

Example of how the array should be created:

Code:
static const HUD_COLORS[][] = {     { 255, 0, 0 },     { 0, 255, 0 },     { 0, 0, 255 },     { 255, 255, 255 } }

* Note: I used "static" because I defined it as a local array. If you need to use it in more than one place, define it as a global variable using "new".

Add/remove as many colors as you want.

Then you will need a variable (global new or local static) that holds the current iteration, starting from 0, up to the size of the array.

Code:
static CURRENT_COLOR

Then, use the "set_hudmessage" function with the current color set:

Code:
set_hudmessage(HUD_COLORS[CURRENT_COLOR][0], HUD_COLORS[CURRENT_COLOR][1], HUD_COLORS[CURRENT_COLOR][2], /* all other arguments stay the same */)

Display the message and all other stuff related to it.

Next, add +1 to the "CURRENT_COLOR" variable. If it reached the end of the array, reset it back to 0.

Code:
if(++CURRENT_COLOR == sizeof(HUD_COLORS)) {     CURRENT_COLOR = 0 }

Can you make a n Admin chat @ color for me ?

OciXCrom 01-14-2020 09:42

Re: Help with ZP Hud
 
Quote:

Originally Posted by Abhinash (Post 2680214)
Can you make a n Admin chat @ color for me ?

How is this related to the thread?

https://forums.alliedmods.net/showthread.php?t=272418


All times are GMT -4. The time now is 03:01.

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