AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Change color in menu (https://forums.alliedmods.net/showthread.php?t=347409)

tedaimlocks 04-23-2024 10:16

Change color in menu
 
How can i change the color of the numbers in the menu?

HTML Code:

    menu_additem(menu, ArmorMenuItemRoundLimit, "1");
    menu_additem(menu, HealthMenuItemRoundLimit, "2");
    menu_additem(menu, ItemShiningHeartRodMapLimit, "3");

Full Code:
HTML Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#include <zp_buymenu>
#include <colorchat>
#include <zombieplague>

#define PLUGIN "PVIP Shop"
#define VERSION "1.0"
#define AUTHOR "tedaimlocks"

#define PVIP_FLAG ADMIN_LEVEL_D

#define MAX_USES_PER_ROUND 5
#define MAX_USES_PER_MAP 1

new HasUsedItemArmorPerRoundLimit[33][MAX_USES_PER_ROUND]
new HasUsedItemHealthPerRoundLimit[33][MAX_USES_PER_ROUND]
new HasUsedItem1PerMapLimit[33][MAX_USES_PER_MAP]

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_clcmd("say /pvip", "PVIPMenu")
    register_logevent("logevent_RoundStart", 2, "1=Round_Start");
}

public logevent_RoundStart() {
    new i, j;
    for (i = 0; i < sizeof(HasUsedItemArmorPerRoundLimit); i++) {
        for (j = 0; j < MAX_USES_PER_ROUND; j++) {
            HasUsedItemArmorPerRoundLimit[i][j] = false;
        }
    }
    for (i = 0; i < sizeof(HasUsedItemHealthPerRoundLimit); i++) {
        for (j = 0; j < MAX_USES_PER_ROUND; j++) {
            HasUsedItemHealthPerRoundLimit[i][j] = false;
        }
    }
}


public PVIPMenu(id) {
    if(!(get_user_flags(id) & PVIP_FLAG)) {
        return PLUGIN_HANDLED;
    }

    if(!is_user_alive(id)) {
        return PLUGIN_HANDLED;
    }

    new title[198];
    new money = zp_cs_get_user_money(id);
    formatex(title, charsmax(title), "\ySPK - Zombie Plague \r[CSO] \d | PVIP Shop^nMoney: %d", money);

    new menu = menu_create(title, "PVIPMenuHandler");

    new ArmorUsesRound = GetNumUsesRound(id, HasUsedItemArmorPerRoundLimit);
    new HealthUsesRound = GetNumUsesRound(id, HasUsedItemHealthPerRoundLimit);
    new ShiningHeartRodUsesMap = GetNumUsesMap(id, HasUsedItem1PerMapLimit);

    new ArmorMenuItemRoundLimit[128];
    new HealthMenuItemRoundLimit[128];
    new ItemShiningHeartRodMapLimit[128];

    format(ArmorMenuItemRoundLimit, sizeof(ArmorMenuItemRoundLimit), "100 Armor \d[\r%d\d/\y%d \rper round\d]    \y[\r2500$\y]", ArmorUsesRound, MAX_USES_PER_ROUND);
    format(HealthMenuItemRoundLimit, sizeof(HealthMenuItemRoundLimit), "100 Health \d[\r%d\d/\y%d \rper round\d]    \y[\r2500$\y]", HealthUsesRound, MAX_USES_PER_ROUND);
    format(ItemShiningHeartRodMapLimit, sizeof(ItemShiningHeartRodMapLimit), "Shining Heart Rod \d[\r%d\d/\y%d \rper map\d] \y[\r65000$\y]", ShiningHeartRodUsesMap, MAX_USES_PER_MAP);

    menu_additem(menu, ArmorMenuItemRoundLimit, "1");
    menu_additem(menu, HealthMenuItemRoundLimit, "2");
    menu_additem(menu, ItemShiningHeartRodMapLimit, "3");

    menu_setprop(menu, MPROP_EXITNAME, "Exit");
    menu_display(id, menu);

    return PLUGIN_CONTINUE;
}

public PVIPMenuHandler(id, menu, item) {
    switch(item) {
        case 0: {
            if(is_user_alive(id))
                PVIPMenuItemArmorPerRoundLimit(id);
            else
                return PLUGIN_HANDLED;
        }
        case 1: {
            if(is_user_alive(id))
                PVIPMenuItemHealthPerRoundLimit(id);
            else
                return PLUGIN_HANDLED;
        }
        case 2: {
            if(is_user_alive(id))
                PVIPMenuItem1PerMapLimit(id);
            else
                return PLUGIN_HANDLED;
        }
    }
    return PLUGIN_CONTINUE;
}

public PVIPMenuItemArmorPerRoundLimit(id) {
    new uses = GetNumUsesRound(id, HasUsedItemArmorPerRoundLimit);
    if (uses >
= MAX_USES_PER_ROUND) {
        ColorChat(id, GREEN, "^x01[^x04SPK ZM^x01]^x03 You have reached the maximum uses of armor for this round.");
        return PLUGIN_HANDLED;
    }
    if(zp_cs_get_user_money(id) <= 2499) {
        return PLUGIN_HANDLED;
    }
    zp_cs_set_user_money(id, zp_cs_get_user_money(id) - 2500);
    set_user_armor(id, get_user_armor(id) + 100);
    HasUsedItemArmorPerRoundLimit[id][uses] = true;
    return PLUGIN_CONTINUE;
}

public PVIPMenuItemHealthPerRoundLimit(id) {
    new uses = GetNumUsesRound(id, HasUsedItemHealthPerRoundLimit);
    if (uses >
= MAX_USES_PER_ROUND) {
        ColorChat(id, GREEN, "^x01[^x04SPK ZM^x01]^x03 You have reached the maximum uses of health for this round.");
        return PLUGIN_HANDLED;
    }
    if(zp_cs_get_user_money(id) <= 2499) {
        return PLUGIN_HANDLED;
    }
    zp_cs_set_user_money(id, zp_cs_get_user_money(id) - 2500);
    set_user_health(id, get_user_health(id) + 100);
    HasUsedItemHealthPerRoundLimit[id][uses] = true;
    return PLUGIN_CONTINUE;
}

public PVIPMenuItem1PerMapLimit(id) {
    new uses = GetNumUsesMap(id, HasUsedItem1PerMapLimit);
    if (uses >
= MAX_USES_PER_MAP) {
        ColorChat(id, GREEN, "^x01[^x04SPK ZM^x01]^x03 You have reached the maximum uses of Shining Heart Rod for this map.");
        return PLUGIN_HANDLED;
    }

    if (zp_get_extra_item_id("Shining Heart Rod") != -1) {
        if(zp_cs_get_user_money(id) <= 64999) {
            return PLUGIN_HANDLED;
        }
        zp_cs_set_user_money(id, zp_cs_get_user_money(id) - 65000);
        zp_force_buy_extra_item(id, zp_get_extra_item_id("Shining Heart Rod"), 1);
    }
    else {
        return PLUGIN_HANDLED;
    }
    HasUsedItem1PerMapLimit[id][uses] = true;
    return PLUGIN_CONTINUE;
}


public GetNumUsesRound(id, array[][])
{
    new uses = 0;
    new i;
    for (i = 0; i < MAX_USES_PER_ROUND; i++)
    {
        if (array[id][i])
        {
            uses++;
        }
    }
    return uses;
}

public GetNumUsesMap(id, array[][])
{
    new uses = 0;
    new i;
    for (i = 0; i < MAX_USES_PER_MAP; i++)
    {
        if (array[id][i])
        {
            uses++;
        }
    }
    return uses;
}


tedaimlocks 04-23-2024 10:30

Re: Change color in menu
 
https://imgur.com/a/DiJ7aoQ

Ace67 04-24-2024 18:56

Re: Change color in menu
 
PHP Code:

menu_additem(menu"^x01" ArmorMenuItemRoundLimit"1");
menu_additem(menu"^x01" HealthMenuItemRoundLimit"2");
menu_additem(menu"^x01" ItemShiningHeartRodMapLimit"3"); 

^x01 = red
^x02 = green
^x03 = blue

bigdaddy424 04-24-2024 21:23

Re: Change color in menu
 
https://github.com/alliedmodders/amx...wmenus.cpp#L94 see `m_ItemColor`
you have to recompile the source

Edit:
apparently youre able to change the number color
https://github.com/alliedmodders/amx...enus.cpp#L1103
https://github.com/alliedmodders/amx...newmenus.h#L32
Code:
#include <amxmodx> const MPROP_SET_NUMBER_COLOR = 10 public plugin_init()     register_clcmd("say f", "clcmd_f") public clcmd_f(id) {     new menu = menu_create("menu", "menu_handler")     menu_additem(menu, "item 1")     menu_additem(menu, "item 2")     menu_additem(menu, "item 3")     menu_setprop(menu, MPROP_SET_NUMBER_COLOR, "\w")     menu_display(id, menu) } public menu_handler(id, menu)     menu_destroy(menu)

mlibre 04-25-2024 09:19

Re: Change color in menu
 
  • /r = red
  • /y = yellow
  • /d = gray (disabled)
  • /w = white

PHP Code:

menu_additem(menu"\yitem \r1"

or traditional style "old"

PHP Code:

 static menu[500]; new len format(menusizeof menu 1"\ySelecciona un Equipo:^n^n")
 
 
len += format(menu[len], sizeof menu len"\r1.\w Terrorista^n")
 
len += format(menu[len], sizeof menu len"\r2.\w Anti-Terrorista^n^n^n")
 
len += format(menu[len], sizeof menu len"\r5.\w Autoseleccinar^n")
 
len += format(menu[len], sizeof menu len"\r6.\w Espectador"


fysiks 04-26-2024 00:46

Re: Change color in menu
 
Quote:

Originally Posted by mlibre (Post 2821600)
  • /r = red
  • /y = yellow
  • /d = gray (disabled)
  • /w = white

You're using the wrong slash here. Makes a huge difference.

mlibre 04-26-2024 12:35

Re: Change color in menu
 
true, I did it intentionally to see if they were paying attention to me and they noticed the little detail :up:

tedaimlocks 04-26-2024 13:38

Re: Change color in menu
 
Quote:

Originally Posted by mlibre (Post 2821658)
true, I did it intentionally to see if they were paying attention to me and they noticed the little detail :up:

trust me i know how to use colors mate. didnt need to show me them, just didnt know how to change the numbers cuz it wasnt working

fysiks 04-26-2024 21:41

Re: Change color in menu
 
It looks like you can change the number color in the "new menus" by setting the MPROP_NUMBER_COLOR property:

PHP Code:

menu_setprop(menuMPROP_NUMBER_COLOR"\r"

Obviously change the "\r" to one of the other valid colors mentioned by mlibre.


If you wanted to change them individually, I suspect you'd have to create the entire menu in the "old" menus method (the "new" menus are called "new" and the original method is often referred to as "old" but it would probably more apt to refer to the "old" as simply "advanced menus").


All times are GMT -4. The time now is 12:08.

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