Raised This Month: $ Target: $400
 0% 

absolute nub and menu formatting


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 06-11-2005 , 19:54  
Reply With Quote #9

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..
xeroblood is offline
Send a message via MSN to xeroblood
 



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 16:42.


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