PDA

View Full Version : Weapon Menu Plugin


Peli
04-02-2004, 14:39
Hello I am working on a Weapon Menu Plugin for practice. Maybe I will release it if there isn't one already. I need you guys to look over it for errors and tell me what I did wrong and explain it please , Okay here is the plugin :

#include <amxmodx>


public plugin_init()
{
register_plugin( "Weapon Menu", "1.0", "Peli" )
register_clcmd( "say /menu","ShowMenu", -1, "Shows a weapon menu" )
register_menucmd(register_menuid("\yWeapon Menu:"), 1023, "MenuCommand" )

return PLUGIN_CONTINUE
}

public ShowMenu( id )
{
new szMenuBody[256]
new keys

format( szMenuBody, 255, "\yWeapon Menu:^n" )
add( szMenuBody, 255, "^n\w1. AK47" )
add( szMenuBody, 255, "^n\w2. AK47" )
add( szMenuBody, 255, "^n\w3. AK47" )
add( szMenuBody, 255, "^n\w4. AK47" )
add( szMenuBody, 255, "^n\w5. AK47" )
add( szMenuBody, 255, "^n\w6. AK47" )
add( szMenuBody, 255, "^n\w7. AK47" )
add( szMenuBody, 255, "^n\w8. AK47" )
add( szMenuBody, 255, "^n\w9. AK47" )
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, "I gave you an ak47" )

case 1: client_print( id, print_chat, "I gave you an ak47" )

case 2: client_print( id, print_chat, "I gave you an ak47" )

case 3: client_print( id, print_chat, "I gave you an ak47" )

case 4: client_print( id, print_chat, "I gave you an ak47" )

case 5: client_print( id, print_chat, "I gave you an ak47" )

case 6: client_print( id, print_chat, "I gave you an ak47" )

case 7: client_print( id, print_chat, "I gave you an ak47" )

case 8: client_print( id, print_chat, "I gave you an ak47" )

case 9: client_print( id, print_chat, "I gave you an ak47" )

case 9: client_print( id, print_chat, EXIT )
}

return PLUGIN_HANDLED
}

dragonchaos
04-02-2004, 15:53
add( szMenuBody, 255, "^n\w1. "AK47" )
should be add( szMenuBody, 255, "^n\w1. AK47" ) (an extra quote was added next to AK47, note the weird coloring in the post.

client_print( id, print_chat, "give_item("weapon_ak47")" )
i would assume this cannot work.client_print( id, print_chat, "I gave you an AK-47" )
give_item( id, "weapon_ak47" )

you also may want to add ammo, but that would be something else

Peli
04-02-2004, 15:56
Thanks , Fixed it :)
Edit : How can I make this into a Rifle only plugin? How would I make it so this menu pops up when someone presses "B" as their regular buying menu? Any help would be much appreciated.

Peli
04-02-2004, 23:28
Anyone know?

knekter
04-03-2004, 15:23
well you could add a command like this:

client_putinserver(id)
{
client_cmd(id,"bind b 'say /menu'")
return PLUGIN_CONTINUE
}
client_disconnect(id)
{
client_cmd(id,"bind b buy")
return PLUGIN_CONTINUE
}

hope this helps :)

Peli
04-03-2004, 18:28
Thanks :) Okay , with that in there , how would it look after I put a cvar to make it on and off , to first check if the cvar is 1 then the rest of the code. How would it look?

QwertyAccess
04-03-2004, 19:27
well you could add a command like this:

client_putinserver(id)
{
client_cmd(id,"bind b 'say /menu'")
return PLUGIN_CONTINUE
}
client_disconnect(id)
{
client_cmd(id,"bind b buy")
return PLUGIN_CONTINUE
}

hope this helps :)

didnt think client_disconnect would be able to bind b to buy in time while they disconnect..

knekter
04-03-2004, 23:04
register_cvar("amx_buymenu","1")

client_putinserver(id)
{
if(get_cvar_num("amx_buymenu")==0)
{
return PLUGIN_HANDLED
}
client_cmd(id,"bind b 'say /menu'")
return PLUGIN_CONTINUE
}
client_disconnect(id)
{
if(get_cvar_num("amx_buymenu")==0)
{
return PLUGIN_HANDLED
}
client_cmd(id,"bind b buy")
return PLUGIN_CONTINUE
}

dragonchaos
04-04-2004, 23:40
you could just wait until they use the buy command ...

register_concmd("buy","usedBuyMenu",0)

public usedBuyMenu() {
ShowMenu()

return PLUGIN_HANDLED
}

Peli
04-05-2004, 00:12
How would I connect it to my plugin? Using If statements? Sorry I'm confused on how It will look if they are connected...