I can't help you on the NPC part, so I would look over Twilight Suzuka's
Awesome Creating an NPC Guide.
Well for the command to access the NPC you would need to register this:
Code:
register_clcmd("say /buy", "clcmd_buy", 0, "Activates the menu for jobs")
Then, you would have to make a menu where you could link to that:
Code:
register_menucmd(register_menuid("Job Menu"), 1023, "menucmd_JobMenu")
Then, for the menu to actually work you need to complete the client command function:
Code:
public clcmd_jobmenu(id)
{
new text[513]
format(text, 512, "\yJob Menu - ^n\w1. Waiter^n\w2. Janitor^n\w3. Exit^n^n")
new keys = (1<<0)|(1<<1)|(1<<2)
show_menu(id, keys, text, -1, "Job Menu")
return PLUGIN_HANDLED
}
Finally, you can set the code/actions that take place for the actual menu:
Code:
public menucmd_JobMenu(id, key)
{
switch(key)
{
case 0:
{
// Code for waiter here...
}
case 1:
{
// Code for Janitor here...
}
case 2:
{
// Exit
}
}
}
Well here's it all together:
Code:
#include <amxmodx>
#include <amxmisc> // Not sure if this is needed
public plugin_init()
{
register_clcmd("say /buy", "clcmd_buy", 0, "Activates the menu for jobs")
register_menucmd(register_menuid("Job Menu"), 1023, "menucmd_JobMenu")
}
public clcmd_jobmenu(id)
{
new text[513]
format(text, 512, "\yJob Menu - ^n\w1. Waiter^n\w2. Janitor^n\w3. Exit^n^n")
new keys = (1<<0)|(1<<1)|(1<<2)
show_menu(id, keys, text, -1, "Job Menu")
return PLUGIN_HANDLED
}
public menucmd_JobMenu(id, key)
{
switch(key)
{
case 0:
{
// Code for Waiter here...
}
case 1:
{
// Code for Janitor here...
}
case 2:
{
// Exit
}
}
}
This isn't perfect, might not work because I did it real fast without thinking straight. But it's just supposed to be helpful.