[Include] Textdraw Menu - v1.0
#1

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
Reply
#2

Nice, i like it, but add a max char in button, because the text will come after you for the box

Translate by ****** translate
Reply
#3

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!
Reply
#4

Very nice job, REP4U...
Reply
#5

Quote:
Originally Posted by Crayder
Посмотреть сообщение
Very nice job, REP4U...
thank you!
Reply
#6

Nice job!
Reply
#7

Quote:
Originally Posted by GuyYahood1
Посмотреть сообщение
Nice job!
thanks you!
Reply
#8

looks nice, gj.
Reply
#9

Quote:
Originally Posted by coloN
Посмотреть сообщение
looks nice, gj.
thanks you!
Reply
#10

nice work! .. Textdraws looks good + your code looks clean too
Reply
#11

Quote:
Originally Posted by Namer
Посмотреть сообщение
nice work! .. Textdraws looks good + your code looks clean too
thank you!!

EDIT: Fixed bug with the pages.
Reply
#12

Nice one!
Reply
#13

Quote:
Originally Posted by Amit_B
Посмотреть сообщение
Nice one!
thank you!
Reply
#14

good job!
Reply
#15

Quote:
Originally Posted by LorDWarS
Посмотреть сообщение
good job!
thanks!
Reply
#16

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!
Reply
#17

Well, this dont work m8
Reply
#18

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
Reply
#19

It gives me errors on compiling. I'm the only one?
Reply
#20

Interesting, good job.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)