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

Menu to choose color for hud


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
amirwolf
Senior Member
Join Date: Feb 2019
Location: Iran
Old 08-31-2022 , 08:54   Menu to choose color for hud
Reply With Quote #1

Hello, can someone make a menu that I can use to change the HUD color as I want?
For example, it should be like this
Some colors are for admins
And there is an option to randomly choose between colors
amirwolf is offline
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 08-31-2022 , 10:47   Re: Menu to choose color for hud
Reply With Quote #2

hud colors for what?
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
amirwolf
Senior Member
Join Date: Feb 2019
Location: Iran
Old 08-31-2022 , 11:49   Re: Menu to choose color for hud
Reply With Quote #3

Quote:
Originally Posted by Nutu_ View Post
hud colors for what?
Display player information such as the amount of money and...
I just need an example to run it
amirwolf is offline
amirwolf
Senior Member
Join Date: Feb 2019
Location: Iran
Old 08-31-2022 , 11:56   Re: Menu to choose color for hud
Reply With Quote #4

It should be something like this, maybe I'm wrong
Code:
enum
{
	COLOR_RED,
	COLOR_BLACK,
	COLOR_WHITE,.....
	COLOR_RANDOM
}

new const Float:Color[][] = 
{
	{200, 0, 0},
	{0, 0, 0},
	{255, 255, 255},....
	and random
}

new const ColorName[][] = 
{
	"Red", ""
	"Black" "admin",
	"White" "",.....
        "random" "VIP"
}
and communication with menu and hud

Last edited by amirwolf; 08-31-2022 at 11:58.
amirwolf is offline
amirwolf
Senior Member
Join Date: Feb 2019
Location: Iran
Old 09-09-2022 , 17:36   Re: Menu to choose color for hud
Reply With Quote #5

How do I add an option for random color to it?
PHP Code:
#include <amxmodx>

new iRediGreeniBlue;

enum _:Colors
{
    
Name[32],
    
Red,
    
Green,
    
Blue
}

new const 
g_Colors[][Colors] =
{
    { 
"Red"2550},
    { 
"Green"0255},
    { 
"Blue"00255 }
}

public 
plugin_init()
{
    
register_clcmd("say /test""hudMenu")
    
set_task(1.0"Test", .flags "b")
}

public 
Test()
{
    
set_hudmessage(iRediGreeniBlue0.50.500.10.10.50.15,4)
    
show_hudmessage(0,"Test")
}

public 
hudMenu(id)
{
    new 
iMenu menu_create("Hud Menu""hudHandler")
    
    for(new 
isizeof(g_Colors); i++)
        
menu_additem(iMenug_Colors[i][Name])
    
menu_display(idiMenu0)

    return 
PLUGIN_HANDLED
}

public 
hudHandler(idiMenuiItem)
{
    if(
iItem != MENU_EXIT)
    {
        
iRed g_Colors[iItem][Red];
        
iGreen g_Colors[iItem][Green];
        
iBlue g_Colors[iItem][Blue];
        
hudMenu(id)
        
menu_destroy(iMenu)
    }
    return 
PLUGIN_HANDLED


Last edited by amirwolf; 09-09-2022 at 17:41.
amirwolf is offline
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 09-09-2022 , 21:26   Re: Menu to choose color for hud
Reply With Quote #6

PHP Code:
enum _:Colors
{
    
Name[32],
    
Red,
    
Green,
    
Blue,
    
Random
}

new const 
g_Colors[][Colors] =
{
    { 
"Red"2550},
    { 
"Green"0255},
    { 
"Blue"00255 },
    { 
"Random"random(0,255), random(0,255), random(0,255) }

and of course add the variable for random and call it in hudhandler
__________________
deprale is offline
amirwolf
Senior Member
Join Date: Feb 2019
Location: Iran
Old 11-17-2022 , 12:54   Re: Menu to choose color for hud
Reply With Quote #7

Up
__________________
amirwolf is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-17-2022 , 15:02   Re: Menu to choose color for hud
Reply With Quote #8

What is your question? You didn't respond to the last suggestion. If that last suggestion wasn't what you wanted, you need to say that.

If you're wanting it to be dynamically random, you simply create a flag to indicate that random was chosen and then generate the random numbers just before you use them in your Test() function.
__________________
fysiks is offline
amirwolf
Senior Member
Join Date: Feb 2019
Location: Iran
Old 11-17-2022 , 15:20   Re: Menu to choose color for hud
Reply With Quote #9

My question is clearly stated
The reason why I did not answer the suggestion of the previous question was that a long time had passed since it was raised and it was not practical at all
Because you cannot add random color to const
Anyway, thank you for your answer
__________________
amirwolf is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-17-2022 , 19:19   Re: Menu to choose color for hud
Reply With Quote #10

You can add the random color to constant but it will only change every map. The second sentence in my post explains how to do a dynamically random color value, what about that are you having issues implementing?
__________________
fysiks is offline
Old 11-18-2022, 01:30
amirwolf
This message has been deleted by amirwolf.
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 06:30.


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