AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   absolute nub and menu formatting (https://forums.alliedmods.net/showthread.php?t=14110)

SuperMechaCow 06-10-2005 02:29

absolute nub and menu formatting
 
hey, I looked around and couldn't find a good list of any of those commands that let you do the fancy formating with menus.

i know i can do ^n, and \w and stuff, but how can i do things such as
have part of one line aligned to the right, as often seen, and display the value of a variable?

is there a tutorial i'm missing somewhere or can i get some basic help or what?

v3x 06-10-2005 02:51

I don't think it's possible to align a menu.. :P

SuperMechaCow 06-10-2005 05:02

what? there has to be! how else could the front-end menus work?!

do you just add blank spaces? :P

but yea, any place i can just get a reference list or sumtin?

xeroblood 06-10-2005 13:24

\R or \r

One of them is right-align, and one of them is Red Text..

v3x 06-10-2005 14:34

o.O, I didn't know that. :D

\R

SuperMechaCow 06-10-2005 15:56

cool. thanks. it's \R i'm sure

but how do i display the value of a variable? the way i do it i'm sure would display a string being the actaul name of the variable, how do ishow the value?

also, i need help in basic math functions.

i got two variables to add, and i got one variable to subtract by adding a negative number, but when i try * or / or - everything ends up crazy! i ended up giving myself 17765486457 dollars in counter-strike and the hud actually displayed it (ran off the screen, but).

and i'm also having problems that are really basic. i declare a new variable inside several different if statments, and all the variables have the same name. the variable then adds two variables which are also declared in each seperate if statement. if works fine for the first if, but the second if is some god aweful crazy number, and the third if doesn't do anything.

it was copy and paste, i'm not even gonna post it cuz it was so flawless. i don't even know the syntax and i am 100% sure that the first if is identical to the second two ifs except the number added is slightly larger. it makes no sense, as far as i can tell it's not going thru one if then the other, which it's not supposed to.

my problem is i need to learn the fracking syntax. all the tutorials i've seen are extremely vague and i can't learn how to do simple crap like add and subtract cuz people just ASSUME you know how to do that. i need to learn the syntax and then i'll leave you guys alone. and not how to format parameters stuff. i've picked up on that. just really basic stuff.

xeroblood 06-11-2005 17:13

Would be easier to help you if you show us the problem code.. :wink:

SuperMechaCow 06-11-2005 18:19

Code:
//right now this is just basically a copy/paste job of one of the exapmles //in the amxmodx documentation. //i've been adding to it, but the stuff i'm adding is like mashing a square //block into a circular hole, cuz i have NO idea what i'm doing anymore. //I need to find an absolute newb guide, not have somebody fix all my //problems for me as i come across them. #include <amxmodx> #include <amxmisc> #include <fun> #include <cstrike> new PLUGIN[]="Extra Buy Menu" new AUTHOR[]="SuperMechaCow" new VERSION[]="0.1" public plugin_init() {         register_plugin(PLUGIN, VERSION, AUTHOR)     new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4     register_menucmd(register_menuid("Extra Buy Menu"), keys, "giveWeapon")     register_clcmd("extrabuymenu", "showExtraMenu") } public showExtraMenu(id) {         new menu[192]         new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4         format(menu, 191, "\yExtra Buy Menu^n^n\w1. AK47\R3750^n2. M4A1\R4650^n3. AWP\R7125^n4. Respawn\R5000^n^n3. Exit Menu")         show_menu(id, keys, menu)         return PLUGIN_HANDLED } public giveWeapon(id, key) {     new moolah = cs_get_user_money(id)     if (key == 0)         {         if (moolah >= 3750) {             new thecost = -3750;             new moolah = cs_get_user_money(id);             new pricetotal = moolah + thecost;                     give_item(id, "weapon_ak47");             cs_set_user_money(id, pricetotal, 1);         } else {             client_print(id, print_chat, "[AMXX] You do not have enough money");             return PLUGIN_HANDLED;             }                   } else if (key == 1) {         if (moolah >= 4650) {             new thecost = -4650;             new moolah = cs_get_user_money(id);             new pricetotal = moolah + thecost;                     give_item(id, "weapon_m4a1");             cs_set_user_money(id, pricetotal, 1);         } else {             client_print(id, print_chat, "[AMXX] You do not have enough money");             return PLUGIN_HANDLED;             }         } else if (key == 2) {                  if (moolah >= 7125) {             new thecost = -7125;             new moolah = cs_get_user_money(id);             new pricetotal = moolah + thecost                     give_item(id, "weapon_awp");             cs_set_user_money(id, pricetotal, 1);         } else {             client_print(id, print_chat, "[AMXX] You do not have enough money");             return PLUGIN_HANDLED;             }         } else if (key == 3) {         if (moolah >= 5000) {             new thecost = -5000;             new moolah = cs_get_user_money(id);             new pricetotal = moolah + thecost;                     spawn(id);             cs_set_user_money(id, pricetotal, 1);         } else {             client_print(id, print_chat, "[AMXX] You do not have enough money");             return PLUGIN_HANDLED;             }     } else if (key == 4) {         return PLUGIN_HANDLED;     } return PLUGIN_HANDLED; }

Nothing happens when I press keys 3, 4, 5 except the menu disappears. i don't think it's running the functions there at all.

xeroblood 06-11-2005 19:54

Try this:

Code:
//right now this is just basically a copy/paste job of one of the exapmles //in the amxmodx documentation. //i've been adding to it, but the stuff i'm adding is like mashing a square //block into a circular hole, cuz i have NO idea what i'm doing anymore. //I need to find an absolute newb guide, not have somebody fix all my //problems for me as i come across them. #include <amxmodx> #include <amxmisc> #include <fun> #include <cstrike> new PLUGIN[]="Extra Buy Menu" new AUTHOR[]="SuperMechaCow" new VERSION[]="0.1" // Item Prices (In order of menu options) new prices[4] = { 3750, 4650, 7125, 5000 } // Menu keys (defined globally) new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4     public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_menucmd(register_menuid("Extra Buy Menu"), keys, "giveWeapon")     register_clcmd("extrabuymenu", "showExtraMenu") } public showExtraMenu(id) {         new menu[192]         format(menu, 191, "\yExtra Buy Menu^n^n\w1. AK47\R%d^n2. M4A1\R%d^n3. AWP\R%d^n4. Respawn\R%d^n^n0. Exit Menu", prices[0], prices[1], prices[2], prices[3])         show_menu(id, keys, menu)         return PLUGIN_HANDLED } public giveWeapon(id, key) {     // Check if user has enough cash     new moolah = cs_get_user_money(id)     if( moolah < prices[key] )     {         client_print(id, print_chat, "[AMXX] You do not have enough money");         return PLUGIN_HANDLED;     }     // Remove Cash     cs_set_user_money(id, moolah - prices[key], 1);         // Give correct item     switch( key )     {         case 0: give_item(id, "weapon_ak47"); // Menu Option 1         case 1: give_item(id, "weapon_m4a1"); // Menu Option 2         case 2: give_item(id, "weapon_awp");  // Menu Option 3         case 3: spawn(id);     }         return PLUGIN_HANDLED; }

Notice how much code was removed by using a single array..

I hope that helps..

SuperMechaCow 06-11-2005 20:13

wow. see that looks nothing like my orignial code, but...

where can i learn how to do this? is there a tutoiral i missed or is it just assumed?

and where can i learn those little things, like \R? and where can i learn how to properly use format? i looked it up about four times in the functions list but it makes no sense to a newb like me


All times are GMT -4. The time now is 16:42.

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