Textdraw Menu - v2.0 -
Hirsw0w - 30.11.2014
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
- 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
Use
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
Simple Textdraw menu Handler:
Код:
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;
}
Simple Destroy Textdraw menu:
Код:
menu_destroy(playerid);
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:
Код:
#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;
}
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
- Hirsw0w - The creator of the include
- SA-MP Team
Re: Textdraw Menu - v1.0 -
Daewoo - 30.11.2014
Nice, i like it, but add a max char in button, because the text will come after you for the box
Translate by ****** translate
Re: Textdraw Menu - v1.0 -
Hirsw0w - 30.11.2014
Quote:
Originally Posted by Daewoo
Nice, i like it, but add a max char in button, because the text will come after you for the box
Translate by ****** translate
|
I will change it right now and edit the post,
thank you!
Re: Textdraw Menu - v1.0 -
Crayder - 30.11.2014
Very nice job, REP4U...
Re: Textdraw Menu - v1.0 -
Hirsw0w - 30.11.2014
Quote:
Originally Posted by Crayder
Very nice job, REP4U...
|
thank you!
Re: Textdraw Menu - v1.0 -
GuyYahood1 - 30.11.2014
Nice job!
Re: Textdraw Menu - v1.0 -
Hirsw0w - 30.11.2014
Quote:
Originally Posted by GuyYahood1
Nice job!
|
thanks you!
Re: Textdraw Menu - v1.0 -
coloN - 01.12.2014
looks nice, gj.
Re: Textdraw Menu - v1.0 -
Hirsw0w - 01.12.2014
Quote:
Originally Posted by coloN
looks nice, gj.
|
thanks you!
Re: Textdraw Menu - v1.0 -
JeaSon - 01.12.2014
nice work! .. Textdraws looks good + your code looks clean too
Re: Textdraw Menu - v1.0 -
Hirsw0w - 01.12.2014
Quote:
Originally Posted by Namer
nice work! .. Textdraws looks good + your code looks clean too
|
thank you!!
EDIT: Fixed bug with the pages.
Re: Textdraw Menu - v1.0 -
Amit_B - 01.12.2014
Nice one!
Re: Textdraw Menu - v1.0 -
Hirsw0w - 01.12.2014
Quote:
Originally Posted by Amit_B
Nice one! 
|
thank you!
Re: Textdraw Menu - v1.0 -
LorDWarS - 01.12.2014
good job!
Re: Textdraw Menu - v1.0 -
Hirsw0w - 01.12.2014
Quote:
Originally Posted by LorDWarS
good job!
|
thanks!
Re: Textdraw Menu - v1.0 -
Hirsw0w - 10.12.2014
Update: In the next few hours or tommrow will be version 2!
the version 2 will included: Textdraw menu with arrows, more one menu style menu, Setting the menu like you love that mean: button color,box color,header color, style , use box in buttons, and more!
be ready for version 2!
Re: Textdraw Menu - v1.0 -
quark - 16.12.2014
Well, this dont work m8
Re: Textdraw Menu - v1.0 -
$$inSane - 17.12.2014
Good job. I have some suggestions regarding the outlook:
- Improve texdraw size and fonts
- Custom colour for the menu
- Maybe keyboard controls like using arrow keys
Re: Textdraw Menu - v1.0 -
quark - 17.12.2014
It gives me errors on compiling. I'm the only one?
Re: Textdraw Menu - v1.0 -
bustern - 17.12.2014
Interesting, good job.