[Include] GMenus Include (stylish GTA V themed* interaction menus!)
#1

GMenu.inc
Version: 2.2.0 | Last Updated: 5 Sept, 2017
GTA V themed interaction menus for SA-MP. Works almost the same way and so does the design. You can customize the menu, like changing the colors and background sprite.
Menu callbacks are handled the same way easydialog.inc does.

Screenshot:


Functions:
PHP код:
ShowPlayerMenu(playeridmenuid[], caption[], type[] = "INTERACTION MENU"captionTextColor 0xf7f7f7ffcaptionBoxColor 0xdb0dd0bbcaptionSprite[] = "loadsc12:loadsc12"); 
Show player a GMenu!
  • "menuid" - Just like easydialog include, you can put any name and you dont need to define it.
  • "caption" - heading of menu
  • "type" - Little text to descript menu (don't make this longer than 30 characters)
  • "captionTextColor" - self explainatory
  • "captionBoxColor" - self explainatory
  • "captionSprite" - The background picture of caption
PHP код:
AddPlayerMenuItem(playeridtext[], info[] = ""); 
Add a listitem to your menu, plug'n'play feature. You can add anytime while the menu is shown.
  • "text" - The listitem's text
  • "info" - A side note/information about the listitem. Optional, leave this param empty for no information box will be shown
PHP код:
HidePlayerMenu(playerid); 
Hide any active GMenu from player.

Macros:
The following list of macros, you can redefine before inclusion:
PHP код:
#define MENU_SOUND_UPDOWN \
    
1054 // the sound id which will be played when you go up/down listitems
#define MENU_SOUND_CLOSE \
    
1084 // the sound id which will be played when you close menu
#define MENU_SOUND_SELECT \
    
1083 // the sound id which will be played when you select a listitem
#define MENU_MAX_LISTITEMS \
    
24 // maximum listitems a menu can have, the array size holding menu information
#define MENU_MAX_LISTITEM_SIZE \
    
128 // maximum string size of a listitem
#define MENU_MAX_LISTITEMS_PERPAGE \
    
// how many lisitems you want to be shown in a page 
The following are constants (i.e. cannot be changed). You can use them in handling response in callback:
PHP код:
MENU_RESPONSE_UP // used in callback (when player press UP key to go upwards in menu)
MENU_RESPONSE_DOWN  // used in callback (when player press DOWN key to go downwards in menu)
MENU_RESPONSE_SELECT  // used in callback (when player press SPACE key to select a listitem)
MENU_RESPONSE_CLOSE  // used in callback (when player press ENTER key to close menu) 
Example - Weapons Menu:
Shows player a weapon menu on every spawn:
[Notice how menu callbacks are handled, if you are not familiar with how easydialog.inc works]
PHP код:
#define FILTERSCRIPT
#include <a_samp>
#include <gmenu>
public OnPlayerSpawn(playerid)
{
    
ShowPlayerMenu(playeridWEAPONS"Weapons Menu");
    
AddPlayerMenuItem(playerid"Katana");
    
AddPlayerMenuItem(playerid"Chainsaw");
    
AddPlayerMenuItem(playerid"Grenade""Lethal weapon, will cost you $5,000 per grenade!");
    
AddPlayerMenuItem(playerid"Molotov Cocktail""Lethal weapon, will cost you $5,000 per moltov!");
    
AddPlayerMenuItem(playerid"Desert Eagle");
    
AddPlayerMenuItem(playerid"RPG""Lethal weapon, will cost you $10,000 per rocket!");
    
AddPlayerMenuItem(playerid"Minigun""Best weapon of game, this is surely worth $100,000!");
    return 
1;
}
Menu:WEAPONS(playeridresponselistitem)
{
    if (
response == MENU_RESPONSE_SELECT)
    {
        switch (
listitem)
        {
            case 
0:
            {
                
GivePlayerWeapon(playerid81);
            }
            
            case 
1:
            {
                
GivePlayerWeapon(playerid91);
            }
            case 
2:
            {
                if (
GetPlayerMoney(playerid) < 5000)
                {
                    return 
SendClientMessage(playerid0xFF0002FF"You need $5,000 to purchase a Greande.");
                }
                
GivePlayerMoney(playerid, -5000);
                
GivePlayerWeapon(playerid161);
            }
            case 
3:
            {
                if (
GetPlayerMoney(playerid) < 5000)
                {
                    return 
SendClientMessage(playerid0xFF0002FF"You need $5,000 to purchase a Molotov Cocktail.");
                }
                
GivePlayerMoney(playerid, -5000);
                
GivePlayerWeapon(playerid181);
            }
            case 
4:
            {
                
GivePlayerWeapon(playerid2450);
            }
            case 
5:
            {
                if (
GetPlayerMoney(playerid) < 10000)
                {
                    return 
SendClientMessage(playerid0xFF0002FF"You need $10,000 to purchase a RPG.");
                }
                
GivePlayerMoney(playerid, -10000);
                
GivePlayerWeapon(playerid351);
            }
            case 
6:
            {
                if (
GetPlayerMoney(playerid) < 100000)
                {
                    return 
SendClientMessage(playerid0xFF0002FF"You need $100,000 to purchase a Minigun.");
                }
                
GivePlayerMoney(playerid, -100000);
                
GivePlayerWeapon(playerid381000);
            }
        }
    }
    return 
1;

Download - Source:
https://github.com/Agneese-Saini/SA-...lude/gmenu.inc
Reply
#2

Very cool, good job Gammix.
Reply
#3

Yet another great release, well done Gammix!

I love the way you can customize colors and whatnot, the sounds and the use of keys instead of the mouse to navigate, excellent idea!

+REP, I'll probs use this in my future projects!

EDIT: darn, can't give rep to you for some reason, says I have to rep someone else first :/
Reply
#4

God damn it, this is sick!
Now I can finally add some amazing textdraw-ed menus into my script (if you don't mind ).

+rep.
Reply
#5

Thank you friends
Reply
#6

Ah, this is cool. Resolution friendly?
Reply
#7

Quote:
Originally Posted by Crayder
Посмотреть сообщение
Ah, this is cool. Resolution friendly?
Thanks, i haven't taken care of resolution that much!
Reply
#8

I was taking a look into it and it looks like it is coded pretty good here is one thing I picked up on reading through.

Код:
	new index = (gMenu[menuid][M_LISTITEMS] + 1);
    if(index > MAX_MENU_ITEMS) return -1;
    index -= 1;
Why not just do it like this.

Код:
	new index = (gMenu[menuid][M_LISTITEMS]);
    if(index >= MAX_MENU_ITEMS) return -1;
The ordering in OnPlayerUpdate() could be done better for sure.

pawn Код:
new keys, updown, leftright;
    GetPlayerKeys(playerid, keys, updown, leftright);

    if(updown == KEY_DOWN)
    {
        if(GetPlayerMenuID(playerid) != INVALID_MENU_ID)
        {
You are already making function calls when you don't have to, this would be a better logical order.

Код:
    if(GetPlayerMenuID(playerid) != INVALID_MENU_ID)
	{
		new keys, updown, leftright;
		GetPlayerKeys(playerid, keys, updown, leftright);

		if(updown == KEY_DOWN)
		{
Another thing to keep in mind is you are using == to check for keys which will work but you can not be pressing any other keys! Usually keys are checked like below. I won't say this method as long as it was your intention for it to be that way.
Код:
if(updown & KEY_DOWN)
What I really need to do myself is polish off my GUI system that is used in Texture Studio the idea is to actually build an GUI editor using it's own GUI includes this way the system is developed on top of it's self for proof of concept.
Here - https://github.com/Pottus/Texture-St...ts/tstudio/gui
Reply
#9

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Код:
	new index = (gMenu[menuid][M_LISTITEMS] + 1);
    if(index > MAX_MENU_ITEMS) return -1;
    index -= 1;
Why not just do it like this.

Код:
	new index = (gMenu[menuid][M_LISTITEMS]);
    if(index >= MAX_MENU_ITEMS) return -1;
Oh, yes.

Quote:
Originally Posted by Pottus
Посмотреть сообщение
The ordering in OnPlayerUpdate() could be done better for sure.

pawn Код:
new keys, updown, leftright;
    GetPlayerKeys(playerid, keys, updown, leftright);

    if(updown == KEY_DOWN)
    {
        if(GetPlayerMenuID(playerid) != INVALID_MENU_ID)
        {
You are already making function calls when you don't have to, this would be a better logical order.

Код:
    if(GetPlayerMenuID(playerid) != INVALID_MENU_ID)
	{
		new keys, updown, leftright;
		GetPlayerKeys(playerid, keys, updown, leftright);

		if(updown == KEY_DOWN)
		{
Yes, thats right.

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Another thing to keep in mind is you are using == to check for keys which will work but you can not be pressing any other keys! Usually keys are checked like below. I won't say this method as long as it was your intention for it to be that way.
Код:
if(updown & KEY_DOWN)
No that will work but for both KEY_DOWN and KEY_UP as well other keys. So that will probably collapse.


Updated the download !




playergui.pwn
You hooking mistake:
Quote:

#else
#if defined _ALS_OnGameModeInit
#undef OnGameModeInit
#else
#define _ALS_OnGameModeInit
#endif
#define OnFilterScriptInit GUIP_OnGameModeInit
forward GUIP_OnGameModeInit();

#endif

pawn Код:
#define GUIValidIndex(%0) if(!GUIData[_:%0][GUIActive]) return 0
#define GUIValidElement(%0,%1) if(!GUIData[_:%0][GUIUsed][%1]) return 0
Or maybe this:
pawn Код:
#define GUIValidIndex(%0) return GUIData[_:%0][GUIActive]
#define GUIValidElement(%0,%1) return GUIData[_:%0][GUIUsed][%1]

The coding of your GUI is pretty good.
I like this method:
pawn Код:
#if defined FILTERSCRIPT
    public OnFilterScriptExit()
#else
    public OnGameModeExit()
#endif
Reply
#10

Yes I know about that problem lol, it was built for Texture Studio and still a prototype design
Reply
#11

Amazing work Gammix (lovely design)!

REP+

EDIT: can't give right now!
Reply
#12

Very impressive.

BTW, when you have selected set to any other value, the rows starts with the number specified rather taking care of the page. I think you should make a better version of it or just remove it(not really required at the moment)!
Reply
#13

really good job :O
Reply
#14

Very nice!!
Reply
#15

Another awesome release from you. Good work!!
Reply
#16

Very nice, Gonna switch to GMenus from SAMP menus
Reply
#17

It's creative, nice work! I reckon if you removed the shadows on the list items it would balance well aesthetically.
Reply
#18

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
It's creative, nice work! I reckon if you removed the shadows on the list items it would balance well aesthetically.
Lol, those shadows make it look creative. And as its themed on GTA V interaction menus
Reply
#19

Thanks all for support.


Update | R2 - 24 May, 2015
  • Fixed menu first item switch bug
  • Now editing menu dynamically
  • Functions to edit menu Title anytime (instant change)
  • Function to edit menu items' text (instant change)
  • You can hide "Interaction Menu" bar when showing menus
  • New 2 functions
    pawn Код:
    native Menu_EditItem(menuid, itemid, itemtext[]);
    native Menu_EditTitle(menuid, newtitle[]);
  • Modified function:
    pawn Код:
    native Menu_Show(playerid, menuid, selectioncolor = 0x0000AAFF, bool:showitemid = true);
Download available in thread.
Reply
#20

May I ask, how do you calculate the total amount of pages in this include?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)