Here's a little menu class I made a long time ago...it's useful in those cases where you just "can't be bothered". The instructions are commented inside the code.
NPC Code:
/* Strings, Variables and Arrays needed to be set: *
* - #v this.maxIndex: The lowest index so the images in this class don't overtake *
* the images from the calling npc. *
* - #s this.style: The style of the text. e.g. b - bold, c - centre etc... *
* - #sA this.menuOptions: String array of what you want the player to select from *
* - #v this.menux: x pos of menu items *
* - #v this.menuy: y pos of menu items *
* - *boolean* this.menuOpen: So this class knows when to show the menu items. *
* *
* To detect if a player has clicked on a menu item add this to the calling npc: *
* if (strequals(#s(this.select),ITEMNAME)) { <dostuff> } *
* Be sure to tell this class that afterwards no item is selected: *
* setstring this.select,; *
* Add that after the last command in the menu click detection. */
//#CLIENTSIDE
if (created) timeout = 0.05;
if (timeout) {
if (this.menuOpen == true) {
for (i=0;i<sarraylen(this.menuOptions);i++) {
showimg this.maxIndex-i,@verdana@/*delph*/#s(this.style)@#I(this.menuOptions,i),this.menux,t his.menuy + (i*15);
changeimgzoom this.maxIndex-i,0.7;
changeimgvis this.maxIndex-i,4;
if (this.maxLen < strlen(#I(this.menuOptions,i))) this.maxLen = strlen(#I(this.menuOptions,i));
if (mousescreenx in |this.menux,this.menux + this.maxLen*7| &&
mousescreeny in |this.menuy + (i*15),this.menuy + (i*15) + 15|) {
if (mousebuttons == 1 && this.mouseDown == false) {
setstring this.select,#I(this.menuOptions,i);
}
changeimgcolors this.maxIndex-i,1,1,0,1;
} else changeimgcolors this.maxIndex-i,1,1,1,1;
}
if (mousebuttons == 1) this.mouseDown = true;
else this.mouseDown = false;
} else for (i=0;i<sarraylen(this.menuOptions);i++) hideimg this.maxIndex-i;
timeout = 0.05;
}