SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 03/11/2017, 07:49 PM   #1
Lokii
Little Clucker
 
Join Date: Sep 2017
Posts: 25
Reputation: 28
Default L_Menu

L_Menu

L_Menu is a menu that displays for player (not clickable) but you will have to type in the text to choose

Functions

ShowPlayerMenu(playerid, header[], item1[], item2[], item3[], item4[], item5[], item6[], item7[], item8[], item9[],item10[], item11[], item12[], item13[], item14[], item15[], info[], main_box_color, header_box_color, info_box_color) - Create a menu for player

HidePlayerMenu(playerid) - Hide player menu

IsPlayerMenuActive(playerid) - Checks if player's menu is active


Callbacks

OnPlayerMenuResponse(playerid, choice) - Called when player input number

OnPlayerMenuClose(playerid) - Called when player closes Menu (presses LMB)




PASTEBIN: https://pastebin.com/LivcS3aT


PIC:


Click to see full picture




VIDEO: https://www.youtube.com/watch?v=EBoFPypPOGM




Script used in the video:



Code:
#include <a_samp>
#include <izcmd>

#undef MAX_PLAYERS
#define MAX_PLAYERS 20

new typee[MAX_PLAYERS];

#include <L_Menu>

#define  FILTERSCRIPT

CMD:menu(playerid, params[])
{
	typee[playerid] = 1; //youll need this if you want to create another menu that uses same number as others
	ShowPlayerMenu(playerid, "             ~g~~h~~h~Test", "~y~1. ~w~Heal", "~y~2. ~w~Armour", "~y~3. ~w~AK-47", "~y~4. ~w~MINIGUN", "~y~5. ~w~DEAGLE", "", "", "", "", "", "", "", "", "", "", "Type the number to choose to close press lmb", 0x00000066, 0xFFFFFF99, 0xFFFF0088);
	return 1;
}

CMD:menu2(playerid, params[])
{
	typee[playerid] = 2; //youll need this if you want to create another menu that uses same number as others //menu 3 will be 3 for example etc..
	ShowPlayerMenu(playerid, "             ~g~~h~~h~Test", "~g~~h~1. ~y~z+3", "~g~2. ~y~~h~z+10", "", "", "", "", "", "", "", "", "", "", "", "", "s", "Type the number to choose to close press lmb", 0xFF000088, 0x00000055, 0xFFFFFF77);
	return 1;
}

public OnPlayerMenuResponse(playerid, choice)
{
	switch(choice)
	{
	    case 1:
	    {
	        if(typee[playerid] == 1)
	        {
	        	SetPlayerHealth(playerid, 100.0);
	        	SendClientMessage(playerid, 0xFF0000FF, "Healed");
			}
			if(typee[playerid] == 2)
	        {
	        	new Float:x, Float:y, Float:z;
	        	GetPlayerPos(playerid, x, y, z);
	        	SetPlayerPos(playerid, x, y, z+3);
	        	SendClientMessage(playerid, -1, "z+3");
			}
		}
	    case 2:
	    {

	        if(typee[playerid] == 1)
	        {
				SetPlayerArmour(playerid, 100.0);
				SendClientMessage(playerid, -1, "Armour given");
			}
			if(typee[playerid] == 2)
	        {
	        	new Float:x, Float:y, Float:z;
	        	GetPlayerPos(playerid, x, y, z);
	        	SetPlayerPos(playerid, x, y, z+10);
	        	SendClientMessage(playerid, -1, "z+10");
			}
	    }
	    case 3:
	    {
	        if(typee[playerid] == 1) //if you have other menus that use those numbers use this
	        {
	        	GivePlayerWeapon(playerid, 30, 150);
	        	SendClientMessage(playerid, 0xFFFF00FF, "AK-47 given");
			}
		}
	    case 4:
	    {
	        if(typee[playerid] == 1)
	        {
	        	GivePlayerWeapon(playerid, 38, 580);
	        	SendClientMessage(playerid, 0xFFFF00FF, "MINIGUN given");
			}
		}
	    case 5:
	    {
	        if(typee[playerid] == 1)
	        {
	        	GivePlayerWeapon(playerid, 24, 125);
	        	SendClientMessage(playerid, 0xFFFF00FF, "DEAGLE given");
			}
		}
	}
	if(typee[playerid] == 1)
    {
		if(choice < 1 || choice > 5) return SendClientMessage(playerid, 0xFF0000FF, "Invalid choice");
	}
	else if(typee[playerid] == 2)
	{
		if(choice < 1 || choice > 2) return SendClientMessage(playerid, 0xFF0000FF, "Invalid choice");
	}
	return 1;
}

public OnPlayerMenuClose(playerid)
{
	if(typee[playerid] == 1) //if the first menu closed
	{
		SendClientMessage(playerid, 0xFF0000FF, "Menu 1 closed");
	}
	if(typee[playerid] == 2) //if the second menu closed
	{
	    SendClientMessage(playerid, 0xFF0000FF, "Menu 2 closed");
	}
	return  1;
}


Another way:



Code:
#include <a_samp>
#include <izcmd>

#undef MAX_PLAYERS
#define MAX_PLAYERS 20

#include <L_Menu>

#define FILTERSCRIPT

new pType[MAX_PLAYERS];

CMD:weapons(playerid, params[])
{
	pType[playerid] = 0;
	ShowPlayerMenu(playerid, "         ~g~~h~~h~Weapons", "~g~~h~~h~1~w~. ~y~Fist", "~g~~h~~h~2~w~. ~y~Brass Knuckle", "~g~~h~~h~3~w~. ~y~Golf Club", "~g~~h~~h~4~w~. ~y~Nite Stick", "~g~~h~~h~5~w~. ~y~Knife", "", "", "", "", "", "", "", "", "", "~g~~h~~h~15~w~. ~y~Vehicles Menu", "Weapons menu", 0xFFFFFF99, 0x00000066, 0x00000066);
	return 1;
}

CMD:vehicles(playerid, params[])
{
	pType[playerid] = 1;
	ShowPlayerMenu(playerid, "         Vehicles", "1. Infernus", "2. Cheetah", "3. Elegy", "", "", "", "", "", "", "", "", "", "", "", "Weapons menu", "Vehicles menu", 0x00FF0066, 0xFFFF0099, 0xFFFFFF88);
	return 1;
}

public OnPlayerMenuResponse(playerid, choice)
{
	new Float:x, Float:y, Float:z;
	switch(pType[playerid])
	{
	    case 0:
	    {
	    	switch(choice)
	    	{
	            case 1: GivePlayerWeapon(playerid, 0, 1);
				case 2: GivePlayerWeapon(playerid, 1, 1);
				case 3: GivePlayerWeapon(playerid, 2, 1);
				case 4: GivePlayerWeapon(playerid, 3, 1);
				case 5: GivePlayerWeapon(playerid, 4, 1);
				case 15: HidePlayerMenu(playerid), ShowPlayerMenu(playerid, "         Vehicles", "1. Infernus", "2. Cheetah", "3. Elegy", "", "", "", "", "", "", "", "", "", "", "", "15. Weapons menu", "Vehicles menu", 0x00FF0066, 0xFFFF0099, 0xFFFFFF88), pType[playerid] = 1;
				default: SendClientMessage(playerid, 0xFF0000FF, "Invalid choice");
			}
		}
		case 1:
		{
		    switch(choice)
		    {
		        case 1:
		        {
		            GetPlayerPos(playerid, x, y, z);
		            CreateVehicle(411, x+2, y+1, z+0.1, -1, -1, -1, -1);
		            SendClientMessage(playerid, 0xFFFF00FF, "Infernus spawned");
		        }
		        case 2:
		        {
		            GetPlayerPos(playerid, x, y, z);
		            CreateVehicle(415, x+2, y+1, z+0.1, -1, -1, -1, -1);
		            SendClientMessage(playerid, 0xFFFF00FF, "Infernus spawned");
		        }
		        case 3:
		        {
		            GetPlayerPos(playerid, x, y, z);
		            CreateVehicle(562, x+2, y+1, z+0.1, -1, -1, -1, -1);
		            SendClientMessage(playerid, 0xFFFF00FF, "Infernus spawned");
		        }
		        case 15: HidePlayerMenu(playerid), ShowPlayerMenu(playerid, "         ~g~~h~~h~Weapons", "~g~~h~~h~1~w~. Fist", "~g~~h~~h~2~w~. Brass Knuckle", "~g~~h~~h~3~w~. Golf Club", "~g~~h~~h~4~w~. Nite Stick", "~g~~h~~h~5~w~. Knife", "", "", "", "", "", "", "", "", "", "~g~~h~~h~15~w~. Vehicles Menu", "Weapons menu", 0xFFFFFF99, 0x00000066, 0x00000066), pType[playerid] = 0;
		        default: SendClientMessage(playerid, 0xFF0000FF, "Invalid choice");
		    }
		}
	}
	return 1;
}

public OnPlayerMenuClose(playerid)
{
	switch(pType[playerid])
	{
	    case 0: SendClientMessage(playerid, 0xFF0000FF, "Weapon menu closed");
	    case 1: SendClientMessage(playerid, 0xFF0000FF, "Vehicle menu closed");
	}
	return 1;
}


Requires: y_hooks



Credits

SAMP TEAM - for samp
ME - for L_Menu
Y_Less - for y_hooks
Adri1 - for his text draw editor

Last edited by Lokii; 06/11/2017 at 06:10 PM.
Lokii is offline   Reply With Quote
Old 04/11/2017, 03:46 AM   #2
RoyalEmpire
Banned
 
Join Date: Oct 2017
Location: Hacking Place
Posts: 51
Reputation: 2
Default Re: L_Menu

good release
i am gonna use it for my menus
RoyalEmpire is offline   Reply With Quote
Old 04/11/2017, 03:53 AM   #3
DonaldDuck
Huge Clucker
 
DonaldDuck's Avatar
 
Join Date: Jun 2017
Location: Tandag City, Philippines
Posts: 295
Reputation: 50
Default Re: L_Menu

Nice release.
__________________
County Island Roleplay A Whole New World

Click Me To Watch The Video

Dynamic Backpack System | Dynamic Land System | Dynamic House and Furniture System and much more!
DonaldDuck is offline   Reply With Quote
Old 04/11/2017, 03:54 AM   #4
Ponga
Big Clucker
 
Ponga's Avatar
 
Join Date: Oct 2017
Posts: 92
Reputation: 5
Default Re: L_Menu

Great work!
__________________
Ponga is offline   Reply With Quote
Old 04/11/2017, 07:47 PM   #5
Florin48
Little Clucker
 
Join Date: Nov 2015
Posts: 5
Reputation: 0
Default Re: L_Menu

Good job man!
Florin48 is offline   Reply With Quote
Old 06/11/2017, 02:56 PM   #6
Lokii
Little Clucker
 
Join Date: Sep 2017
Posts: 25
Reputation: 28
Default Re: L_Menu

Quote:
Originally Posted by RoyalEmpire View Post
good release
i am gonna use it for my menus
Quote:
Originally Posted by DonaldDuck View Post
Nice release.
Quote:
Originally Posted by Ponga View Post
Great work!
Quote:
Originally Posted by Florin48 View Post
Good job man!

Thnx!
Lokii is offline   Reply With Quote
Old 06/11/2017, 03:58 PM   #7
Xeon™
Huge Clucker
 
Xeon™'s Avatar
 
Join Date: Jul 2017
Location: Earth
Posts: 458
Reputation: 67
Default Re: L_Menu

Quote:
if(IsPlayerNPC(playerid)) return 0;
why this? you should return 1 instead of 0.

Quote:
E_P_MENU[MAX_PLAYERS][20];
hey force the user to define MAX_PLAYERS USE #undef, #if and #error to do it.


anything else, good job
Xeon™ is offline   Reply With Quote
Old 06/11/2017, 05:06 PM   #8
Xeon™
Huge Clucker
 
Xeon™'s Avatar
 
Join Date: Jul 2017
Location: Earth
Posts: 458
Reputation: 67
Default Re: L_Menu

Quote:
Originally Posted by Lokii View Post
1. it doesn't matter which value i return
2. why MAX_PLAYERS is defined in a_samp i undefined it and then defined it to 20 because my server max is 20
1: http://wiki.sa-mp.com/wiki/OnPlayerDisconnect

it's does matter
Quote:
0 - Will prevent other filterscripts from receiving this callback.
1 - Indicates that this callback will be passed to the next filterscript.
you should return 1, else you will make troubles to user.

2: so define it and force user to re define it using #error
something like:

PHP Code:
#define MAX_SLOTS -1

#if defined MAX_PLAYERS
  #undef MAX_PLAYERS
#define MAX_PLAYERS MAX_SLOTS
#endif

#if MAX_SLOTS == -1
  #error Please change MAX_SLOTS value to your server slots count
#endif 
Xeon™ is offline   Reply With Quote
Old 06/11/2017, 05:15 PM   #9
Lokii
Little Clucker
 
Join Date: Sep 2017
Posts: 25
Reputation: 28
Default Re: L_Menu

Quote:
Originally Posted by Xeon™ View Post
1: http://wiki.sa-mp.com/wiki/OnPlayerDisconnect

it's does matter


you should return 1, else you will make troubles to user.

2: so define it and force user to re define it using #error
something like:

PHP Code:
#define MAX_SLOTS -1

#if defined MAX_PLAYERS
  #undef MAX_PLAYERS
#define MAX_PLAYERS MAX_SLOTS
#endif

#if MAX_SLOTS == -1
  #error Please change MAX_SLOTS value to your server slots count
#endif 
Ok didnt knew that thx will update

EDIT: updated https://pastebin.com/LivcS3aT
but about max players you can just define the max players before l_menu like that:

PHP Code:
#undef MAX_PLAYERS
#define MAX_PLAYERS 20
#include <L_Menu> 

Last edited by Lokii; 06/11/2017 at 06:12 PM.
Lokii 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



All times are GMT. The time now is 11:27 AM.


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