Raised This Month: $ Target: $400
 0% 

Menus + Cvars


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 06-07-2010 , 20:03   Menus + Cvars
Reply With Quote #1

Is it possible to add the info from a cvar into a menu item? Such as:

PHP Code:
menu_additemmenu"%d HP""1"
%d = get_pcvar_num(pcvar)
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-07-2010 , 20:10   Re: Menus + Cvars
Reply With Quote #2

You have to format the cvar into a string and then pass the string to the menu_additem() function.
__________________
fysiks is offline
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 06-07-2010 , 20:18   Re: Menus + Cvars
Reply With Quote #3

PHP Code:
%get_pcvar_num(pcvar
-->

PHP Code:
%get_pcvar_string(pcvarstring[], len
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 06-07-2010 , 20:29   Re: Menus + Cvars
Reply With Quote #4

Quote:
Originally Posted by Alucard^ View Post
PHP Code:
%get_pcvar_num(pcvar
-->

PHP Code:
%get_pcvar_string(pcvarstring[], len
Fuck me, I don't have much experience with this. Example of a simple menu?

PHP Code:
public shopid )
{
    if( 
is_user_aliveid ) && cs_get_user_teamid ) == CS_TEAM_T )
    {
        new 
menu menu_create"Main Menu""menu_handler" )
        
menu_additemmenu"%d HP""1"
There, started it for you if you're willing to give an example of using a string with it.
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-07-2010 , 20:32   Re: Menus + Cvars
Reply With Quote #5

PHP Code:
new szString[32]
formatex(szStringcharsmax(szString), "%d HP"get_cvar_num("your_cvar_here"))
menu_additem(menuszString, ...) 
But, remember to use pcvars.
__________________
fysiks is offline
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 06-07-2010 , 20:39   Re: Menus + Cvars
Reply With Quote #6

Oh, is a number... not a string, sry... my mistake.

Here an example:

Code:
#include <amxmodx> #define PLUGIN  "New Plugin" #define AUTHOR  "Alucard" #define VERSION "0.0.1" new p_CvarSomething; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);         p_CvarSomething = register_cvar("cvar_something", "1");         register_clcmd("say /menu", "HookCmdMenu"); } public HookCmdMenu(id) {     new menu = menu_create("I am a menu", "FuckingMenuHandler");         new szItem[32];     formatex(szItem, 31, "%d HP", get_pcvar_num(p_CvarSomething) );         menu_additem(menu, szItem, "1");         menu_display(id, menu);     return PLUGIN_HANDLED; }

But if is an string, see the fysik's example.
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-07-2010 , 21:12   Re: Menus + Cvars
Reply With Quote #7

Quote:
Originally Posted by Alucard^ View Post
But if is an string, see the fysik's example.
No, my example is the same as yours (essentially). You just did the whole thing is all that is different (and you used pcvars).
__________________
fysiks is offline
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 06-07-2010 , 23:22   Re: Menus + Cvars
Reply With Quote #8

Ohhh, i saw bad, thought that you did it an example with a string (get_cvar_string), but no... sry.
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
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 05:28.


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