This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Change color in menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tedaimlocks
Member
Join Date: Jan 2024
Old 04-23-2024 , 10:16   Change color in menu
Reply With Quote #1

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 is offline
tedaimlocks
Member
Join Date: Jan 2024
Old 04-23-2024 , 10:30   Re: Change color in menu
Reply With Quote #2

https://imgur.com/a/DiJ7aoQ

Last edited by tedaimlocks; 04-23-2024 at 10:31.
tedaimlocks is offline
Ace67
Senior Member
Join Date: Sep 2020
Location: France
Old 04-24-2024 , 18:56   Re: Change color in menu
Reply With Quote #3

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
__________________
CS:CZ > CS 1.6

Last edited by Ace67; 04-24-2024 at 19:51.
Ace67 is offline
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 04-24-2024 , 21:23   Re: Change color in menu
Reply With Quote #4

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)
__________________

Last edited by bigdaddy424; 04-24-2024 at 21:39.
bigdaddy424 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-26-2024 , 00:46   Re: Change color in menu
Reply With Quote #6

Quote:
Originally Posted by mlibre View Post
  • /r = red
  • /y = yellow
  • /d = gray (disabled)
  • /w = white
You're using the wrong slash here. Makes a huge difference.
__________________

Last edited by fysiks; 04-26-2024 at 00:47.
fysiks is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 04-26-2024 , 12:35   Re: Change color in menu
Reply With Quote #7

true, I did it intentionally to see if they were paying attention to me and they noticed the little detail
__________________
mlibre is offline
tedaimlocks
Member
Join Date: Jan 2024
Old 04-26-2024 , 13:38   Re: Change color in menu
Reply With Quote #8

Quote:
Originally Posted by mlibre View Post
true, I did it intentionally to see if they were paying attention to me and they noticed the little detail
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
tedaimlocks is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-26-2024 , 21:41   Re: Change color in menu
Reply With Quote #9

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").
__________________

Last edited by fysiks; 04-26-2024 at 21:47.
fysiks 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:33.


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