30.11.2014, 18:46
(
Последний раз редактировалось Hirsw0w; 25.12.2014 в 08:39.
)
Introduction
Well, I saw the option of clickable textdraws, I thought to my-self we could do menu with this and this wonderful idea, The Programming method isn't the ordinary way in sa-mp its take from cs 1.6 , the menus in cs 1.6 ( Counter-Strike 1.6 ) is like this , only with numbers, the functions like the Programming method on CS 1.6.
Functions
Simple Textdraw menu Create ( without the handler ):
Simple Textdraw menu Handler:
Simple Destroy Textdraw menu:
Example
Well, I created here Weapons menu that when you click on weapon that give you the weapon with 999 ammo.
That is the code:
Bugs
1. Bug with the items in the pages [ FIXED v1.0.1 ]
2. Bug with whole code [ FIXED v2.0 ]
Pictures
Picture one:

Picture two:

Picture three : ( v2.0 pic )

that the pictures from the example code
Changelog
Version 1.0 - first release.
Version 1.0.1 - Fix bugs.
Version 2.0 - Fix Bugs and new Features:
1. edit the whole menu
2. new style added
Downloads
Pastebin - v2.0
Credits
Well, I saw the option of clickable textdraws, I thought to my-self we could do menu with this and this wonderful idea, The Programming method isn't the ordinary way in sa-mp its take from cs 1.6 , the menus in cs 1.6 ( Counter-Strike 1.6 ) is like this , only with numbers, the functions like the Programming method on CS 1.6.
Functions
- menu_create(Header[],Handler[])
Header - the header of the menu.
Handler - the handler name - that is what you control the menu.
- menu_additem(menuid,Item[])
menuid - menuid that return the menu_create
Item - what is will write to the players in the option
- menu_display(playerid,menuid,page=1)
playerid - the player-id you want to display to him the menu
menuid - menuid that return the menu_create
page - the page will show-up to the player | default : 1
- menu_destroy(playerid)
playerid - the player-id you want to destroy to him the menu - menu_edit(menu,edititem,value)
menu - menuid that return the menu_create
edititem - the item from that list:
MEDIT_STYLE // Menu Style
MEDIT_USEBOXBUTTON // Use box on button
MEDIT_BUTTONCOLOR // change button color
MEDIT_HEADERCOLOR // change header color
MEDIT_BOXCOLOR // change box color
value - change the color,style or use(1,0)
IMPORTANT: for style have 2 situations
1. First menu style ( THE NORMAL ) : MENU_NORMALSTYLE
2. Seconds menu style ( THE CENTER ) : MENU_CENTERSTYLE
Simple Textdraw menu Create ( without the handler ):
Код:
new menu = menu_create("header","sub_menu"); // create the menu and return the menuid menu_additem(menu,"Weapon 1"); // Item 1 menu_additem(menu,"Weapon 2"); // Item 2 menu_edit(menu,MEDIT_STYLE,MENU_CENTERSTYLE); // edit menu style menu_display(playerid,menu); // display the menu for player
Код:
forward sub_menu(playerid,menu,item); public sub_menu(playerid,menu,item) { if(item == MENU_EXIT) return SendClientMessage(playerid,-1, "you closed the menu"); switch(item) { case 0: SendClientMessage(playerid,-1,"that the option Weapon 1"); case 1: SendClientMessage(playerid,-1,"that the option Weapon 2"); } return 1; }
Код:
menu_destroy(playerid);
Well, I created here Weapons menu that when you click on weapon that give you the weapon with 999 ammo.
That is the code:
Код:
#include <a_samp> #include <tdmenu> new Weapon[11][20] = {"AK47","M4","Tec-9","Country Rifle","Sniper Rifle","Deagle","Shotgun", "RPG","HS Rocket","Grenade","9mm"}; new Weaponi[11] = {30, 31, 32,33, 34,24,25,35,36,16,22}; public OnPlayerCommandText(playerid, cmdtext[]) { if (!strcmp("/weaponsmenu", cmdtext, true)) { new menu = menu_create("Weapons Menu","sub_menu"); for(new i;i < 11;i++) menu_additem(menu,Weapon[i]); menu_edit(menu,MEDIT_STYLE,MEDIT_CENTERSTYLE); menu_edit(menu,MEDIT_USEBOXBUTTON,0); menu_edit(menu,MEDIT_BOXCOLOR,0x00688B); menu_edit(menu,MEDIT_HEADERCOLOR,0x8A2BE2); menu_edit(menu,MEDIT_BUTTONCOLOR ,0xCD3333); menu_display(playerid,menu); return 1; } return 0; } forward sub_menu(playerid,menu,item); // menu handler public sub_menu(playerid,menu,item) { if(item == MENU_EXIT) return 1; GivePlayerWeapon(playerid,Weaponi[item],999); return 1; }
1. Bug with the items in the pages [ FIXED v1.0.1 ]
2. Bug with whole code [ FIXED v2.0 ]
Pictures
Picture one:

Picture two:

Picture three : ( v2.0 pic )

that the pictures from the example code
Changelog
Version 1.0 - first release.
Version 1.0.1 - Fix bugs.
Version 2.0 - Fix Bugs and new Features:
1. edit the whole menu
2. new style added
Downloads
Pastebin - v2.0
Credits
- Hirsw0w - The creator of the include
- SA-MP Team