Raised This Month: $ Target: $400
 0% 

My WeaponMenu Doesn't work


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NiGHTFiRE
Senior Member
Join Date: Dec 2004
Location: Sweden
Old 03-20-2005 , 01:30   My WeaponMenu Doesn't work
Reply With Quote #1

My weapon menu doesn't work. I get six errors with this: What did I do wrong?

Code:
#include <amxmodx> #include <amxmisc> #include <fun> public plugin_init() {   register_plugin("Weapon Menu", "0.10", "NiGHTFiRE")   new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2| MENU_KEY_3   register_menucmd(register_menuid("Which Weapon?"), keys, "giveWeapon")   register_clcmd("giveme", "showWeaponmenu")   public showWeaponMenu(id) {      new menu[192]      new keys = MENU_KEY_0 |MENU_KEY_1 |MENU_KEY_2|MENU_KEY_3            format(menu, 191, "Which Weapon?^n^n1. AK47^n2. M4A1^n3. AWP^n4. Deagle")      show_menu(id, keys, menu)      return PLUGIN_HANDLED } public giveWeapon(id, key) {     if (key == 0)     {         give_item(id, "weapon_ak47")       } else if  (key == 1) {        give_item(id, "weapon_m4a1")       } else if (key == 2) {         give_item(id, "weapon_awp")       } else if (key == 3) {        give_item(id, "weapon_deagle"         } }

Please give me examples with code so I can learn.
Thanks
NiGHTFiRE is offline
Send a message via AIM to NiGHTFiRE Send a message via MSN to NiGHTFiRE
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 03-20-2005 , 01:42  
Reply With Quote #2

Umm, try this:
Code:
#include <amxmodx> #include <amxmisc> #include <fun> public plugin_init() {   register_plugin("Weapon Menu", "0.10", "NiGHTFiRE")   register_menucmd(register_menuid("\yWhich Weapon?"), 1023, "giveWeapon")   register_clcmd("giveme","showWeaponMenu", ADMIN_SLAY, "Shows the menu for giving weapons")   register_clcmd("say /giveme","showWeaponMenu", ADMIN_SLAY, "Shows the menu for giving weapons")   return PLUGIN_CONTINUE } public showWeaponMenu(id) {     new szMenuBody[256]     new keys     new len = format(szMenuBody, 255, "\yWhich weapon?:^n")     len += format(szMenuBody[len], 255-len, "^n\w1. AK-47")     len += format(szMenuBody[len], 255-len, "^n\w2. M4A1")     len += format(szMenuBody[len], 255-len, "^n\w3. AWP")     len += format(szMenuBody[len], 255-len, "^n\w4. Deagle")     len += format(szMenuBody[len], 255-len, "^n^n\w0. Exit")     keys = (1<<0|1<<1|1<<2|1<<3|1<<9)         show_menu(id, keys, szMenuBody, -1)     return PLUGIN_CONTINUE } public giveWeapon(id, key) {     switch(key) {         case 0:         {             give_item(id, "weapon_ak47")         }         case 1: {             give_item(id, "weapon_m4a1")         }         case 2: {             give_item(id, "weapon_awp")         }         case 3: {             give_item(id, "weapon_deagle")         }     }     return PLUGIN_HANDLED }

Also, I changed all of those else if's into one simple switch statement.

*Edited (x2)*
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
NiGHTFiRE
Senior Member
Join Date: Dec 2004
Location: Sweden
Old 03-20-2005 , 02:07  
Reply With Quote #3

Thanks i will test it, but what does this do?

Code:
len += format(szMenuBody[len], 255-len new len = format(szMenuBody, 255
How can you know like what numbers you should have? Like you typed:
Code:
register_menucmd(register_menuid("Which Weapon?"), 1023, "giveWeapon")
But why did you take 1023 and this with 255-len and the new szmenubody[256]?
Thanks

edit: Where did you learn where to script? If you know any good website(I have read the documents on this website) that I could learn I would be very thankfull!
NiGHTFiRE is offline
Send a message via AIM to NiGHTFiRE Send a message via MSN to NiGHTFiRE
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 03-20-2005 , 02:12  
Reply With Quote #4

Take a look @ this thread:
http://forums.alliedmods.net/showthread.php?t=9736
It will help clear up a few things.

Also, I might have messed up on my keys or something, since I'm pretty new to menus.

Where did I learn?
1. Already had some prior coding knowledge (PHP).
2. Posting questions here.
3. A friend helps me out when I'm stuck.

Edit: Yes, I did mess up on my keys (try the new one). But I'm not to sure as to why it's not giving the weapon.
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
Reply


Thread Tools
Display Modes

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 14:14.


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