AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help! (https://forums.alliedmods.net/showthread.php?t=9776)

clubz 01-30-2005 06:35

Help!
 
Ok, im getting into making plugins and such. I wanna start making /buy menus at certain areas like the 7-11, etc.. I think thats a NPC. Can anyone help? Any tutorials, or can someone maybe teach me?


Thanks,
Kyle

Peli 01-30-2005 13:28

AMX Mod / AMX Mod X Menu tutorial by Xeroblood. This is a really useful tutorial , but if you want the actual code , here it is. :
Code:
#include <amxmodx> public plugin_init() {     register_clcmd( "say /menu","ShowMenu", -1, "Shows The menu" )     register_menucmd(register_menuid("\yFirst Menu:"), 1023, "MenuCommand" )     return PLUGIN_CONTINUE } public ShowMenu( id ) {     new szMenuBody[256]     new keys     format( szMenuBody, 255, "\yFirst Menu:^n" )     add( szMenuBody, 255, "^n\w1. First Option" )     add( szMenuBody, 255, "^n\w2. Second Option" )     add( szMenuBody, 255, "^n\w3. Third Option" )     add( szMenuBody, 255, "^n\w4. Fourth Option" )     add( szMenuBody, 255, "^n\w5. Fifth Option" )     add( szMenuBody, 255, "^n\w6. Sixth Option" )     add( szMenuBody, 255, "^n\w7. Seventh Option" )     add( szMenuBody, 255, "^n\w8. Eighth Option" )     add( szMenuBody, 255, "^n\w9. Ninth Option" )     add( szMenuBody, 255, "^n^n\w0. Exit" )     keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9)         show_menu( id, keys, szMenuBody, -1 )     return PLUGIN_CONTINUE } public MenuCommand( id, key ) {     client_print( id, print_console, "[AMX] Key=%d", key )     client_print( id, print_chat, "[AMX] Key=%d", key )     switch( key )     {         case 0: client_print( id, print_chat, "Menu Option #1" )         case 1: client_print( id, print_chat, "Menu Option #2" )         case 2: client_print( id, print_chat, "Menu Option #3" )         case 3: client_print( id, print_chat, "Menu Option #4" )         case 4: client_print( id, print_chat, "Menu Option #5" )         case 5: client_print( id, print_chat, "Menu Option #6" )         case 6: client_print( id, print_chat, "Menu Option #7" )         case 7: client_print( id, print_chat, "Menu Option #8" )         case 8: client_print( id, print_chat, "Menu Option #9" )         case 9: client_print( id, print_chat, "Menu Option EXIT" )     }     return PLUGIN_HANDLED }

clubz 01-30-2005 15:46

Hey thanks for the code. But, how would I put it at a certain location, like the diner or 7-11?

Thanks,
Kyle

Peli 01-30-2005 19:45

Well that gets more advanced , like making a model and putting it in an origin and making it accessable only there. I don't know how to do that sorry.

Da Bishop 01-30-2005 20:39

Thats actually a messy code. The command
Code:
add()

is a bad way to do it.

Peli 01-30-2005 20:42

Then how do you think he should do it?

twistedeuphoria 01-30-2005 21:31

If you go down on that topic theres an example by freecode (I think) that uses format().

Johnny got his gun 01-31-2005 02:28

I prefer defining the keys like this. Makes reading them alot easier IMO.

Code:
#define MENUBUTTON1             (1<<0) #define MENUBUTTON2             (1<<1) #define MENUBUTTON3             (1<<2) #define MENUBUTTON4             (1<<3) #define MENUBUTTON5             (1<<4) #define MENUBUTTON6             (1<<5) #define MENUBUTTON7             (1<<6) #define MENUBUTTON8             (1<<7) #define MENUBUTTON9             (1<<8) #define MENUBUTTON0             (1<<9) #define MENUSELECT1             0 #define MENUSELECT2             1 #define MENUSELECT3             2 #define MENUSELECT4             3 #define MENUSELECT5             4 #define MENUSELECT6             5 #define MENUSELECT7             6 #define MENUSELECT8             7 #define MENUSELECT9             8 #define MENUSELECT0             9

Then, if we take above example...

Code:
keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9) // Changes to keys = MENUBUTTON1|MENUBUTTON2|MENUBUTTON3|MENUBUTTON4|MENUBUTTON5|MENUBUTTON6|MENUBUTTON7|MENUBUTTON8|MENUBUTTON9|MENUBUTTON0

And in the same manner we replace the #s with MENUSELECT?s in the switch/case in the function called by the menu.

XxAvalanchexX 01-31-2005 16:18

As a matter of fact, in amxconst.inc:

Code:
/* Menu keys */ #define MENU_KEY_1      (1<<0) #define MENU_KEY_2      (1<<1) #define MENU_KEY_3      (1<<2) #define MENU_KEY_4      (1<<3) #define MENU_KEY_5      (1<<4) #define MENU_KEY_6      (1<<5) #define MENU_KEY_7      (1<<6) #define MENU_KEY_8      (1<<7) #define MENU_KEY_9      (1<<8) #define MENU_KEY_0      (1<<9)

They already have defines for you.

Peli 01-31-2005 19:50

Thanks Bishop , Johnny and Avalanche.


All times are GMT -4. The time now is 19:23.

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