SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 15/05/2015, 02:15 PM   #1
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,768
Reputation: 809
Default GMenus Include (stylish GTA V themed* interaction menus!)

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 Code:
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 Code:
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 Code:
HidePlayerMenu(playerid); 
Hide any active GMenu from player.

Macros:
The following list of macros, you can redefine before inclusion:
PHP Code:
#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 Code:
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 Code:
#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
__________________

My GitHub:


Last edited by Gammix; 06/09/2017 at 12:43 PM.
Gammix is online now   Reply With Quote
Old 15/05/2015, 02:19 PM   #2
Sellize
Gangsta
 
Sellize's Avatar
 
Join Date: Jan 2013
Location: (ง ͠ ͟ل͜ ͡)ง fight me irl
Posts: 903
Reputation: 293
Default Re: GMenus Include (stylish GTA V themed* interaction menus!)

Very cool, good job Gammix.
__________________
dead
Sellize is offline   Reply With Quote
Old 15/05/2015, 02:22 PM   #3
Smileys
Huge Clucker
 
Smileys's Avatar
 
Join Date: Dec 2013
Location: Home.
Posts: 394
Reputation: 31
Default Re: GMenus Include (stylish GTA V themed* interaction menus!)

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 :/
Smileys is offline   Reply With Quote
Old 15/05/2015, 02:26 PM   #4
iSkyline
Big Clucker
 
iSkyline's Avatar
 
Join Date: Mar 2015
Location: Milky Way.
Posts: 77
Reputation: 16
Default Re: GMenus Include (stylish GTA V themed* interaction menus!)

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.
iSkyline is offline   Reply With Quote
Old 16/05/2015, 12:51 AM   #5
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,768
Reputation: 809
Default Re: GMenus Include (stylish GTA V themed* interaction menus!)

Thank you friends
Gammix is online now   Reply With Quote
Old 16/05/2015, 01:06 AM   #6
Crayder
High-roller
 
Crayder's Avatar
 
Join Date: Sep 2013
Location: Flames of Hell
Posts: 3,864
Reputation: 589
Default Re: GMenus Include (stylish GTA V themed* interaction menus!)

Ah, this is cool. Resolution friendly?
__________________
Those who deserve reputation, do not need to beg for it.
Also, don't expect the help you need when offering reputation, you'll just be attracting Rep Hunters.
Join SA-MP Discord!
Crayder is offline   Reply With Quote
Old 16/05/2015, 01:07 AM   #7
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,768
Reputation: 809
Default Re: GMenus Include (stylish GTA V themed* interaction menus!)

Quote:
Originally Posted by Crayder View Post
Ah, this is cool. Resolution friendly?
Thanks, i haven't taken care of resolution that much!
Gammix is online now   Reply With Quote
Old 16/05/2015, 01:30 AM   #8
Pottus
Godfather
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 5,424
Reputation: 1238
Default Re: GMenus Include (stylish GTA V themed* interaction menus!)

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.

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

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

Code:
	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.

Code:
    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.
Code:
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
Pottus is offline   Reply With Quote
Old 16/05/2015, 02:01 AM   #9
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,768
Reputation: 809
Default Re: GMenus Include (stylish GTA V themed* interaction menus!)

Quote:
Originally Posted by Pottus View Post
Code:
	new index = (gMenu[menuid][M_LISTITEMS] + 1);
    if(index > MAX_MENU_ITEMS) return -1;
    index -= 1;
Why not just do it like this.

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

Quote:
Originally Posted by Pottus View Post
The ordering in OnPlayerUpdate() could be done better for sure.

Code:
	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.

Code:
    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 View Post
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.
Code:
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
Code:
#define GUIValidIndex(%0) if(!GUIData[_:%0][GUIActive]) return 0
#define GUIValidElement(%0,%1) if(!GUIData[_:%0][GUIUsed][%1]) return 0
Or maybe this:
Code:
#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:
Code:
#if defined FILTERSCRIPT
	public OnFilterScriptExit()
#else
	public OnGameModeExit()
#endif
__________________

My GitHub:

Gammix is online now   Reply With Quote
Old 16/05/2015, 02:09 AM   #10
Pottus
Godfather
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 5,424
Reputation: 1238
Default Re: GMenus Include (stylish GTA V themed* interaction menus!)

Yes I know about that problem lol, it was built for Texture Studio and still a prototype design
Pottus is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Stylish login screen. CharlieSanchez Filterscripts 45 18/10/2017 06:22 AM
Interaction with objects Laurentziu Scripting Help 12 12/03/2015 09:29 AM
[FilterScript] ::: Sleek & Stylish Digital Speedometer ::: iPLEOMAX Filterscripts 70 28/10/2012 05:09 AM
[Map] New stylish map Vegetathebest Maps 2 14/04/2012 12:27 PM
The interaction between AMX and DLL webcode421F Plugin Development 8 13/10/2011 10:02 PM


All times are GMT. The time now is 08:15 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.