30.08.2016, 01:43
(
Last edited by NealPeteros; 31/08/2016 at 09:20 AM.
Reason: Changed strcmp to ZCMD
)
Introduction
Hi, guys! It's my second tutorial in SAMP Forums. My first tutorial was a mess. It had so many mistakes, so I decided to make a new tutorial, in contrast with the first one, this one, I hope, would be better. So, let's start.
What is mSelection?
An include which adds the possibility to create Model Preview Menus with only a few lines of code. It shows a menu that gives a preview of all vehicles/skins available to use.
What are the things you need?
How mSelection works?
mSelection works like a dialog, but in mSelection, it shows a menu. Some of the functions of mSelection are:
Why should you choose mSelection?
mSelection is simpler and easier to identifiy the vehicles/skins. They show a preview of that vehicle/skin, in contrast with the command "/setskin [playerid] [skinid]". With this command you must go to ****** and search for the skin ID, or try to memorize them all. On the other hand, mSelection shows a preview of the available skins that can be chosen. With mSelection, you don't need to go to ****** and search for the skin ID, but you can just scroll with the skin previews and you'll find the skin you were looking for. In simple words, making a /setskin command is more complex than mSelection.
Credits:
To start, open the mSelection zip file, and extract all of them to their right places.
Open your gamemode/filterscript .pwn file using pawno, and add this on top of your script
Add this somewhere ontop of your script, below the includes
Add this inside OnGamemodeInit
For the command
Whole command code
Below your script
Whole callback with functions
Hi, guys! It's my second tutorial in SAMP Forums. My first tutorial was a mess. It had so many mistakes, so I decided to make a new tutorial, in contrast with the first one, this one, I hope, would be better. So, let's start.
What is mSelection?
An include which adds the possibility to create Model Preview Menus with only a few lines of code. It shows a menu that gives a preview of all vehicles/skins available to use.
What are the things you need?
How mSelection works?
mSelection works like a dialog, but in mSelection, it shows a menu. Some of the functions of mSelection are:
- HideModelSelectionMenu(playerid)
Hide menu for player.
- playerid: playerid
- returns: nothing
- ShowModelSelectionMenu(playerid, ListID, header_text[], dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)
Show menu for player.
- playerid: playerid
- ListID: The ID of the list/menu to be shown
- header_test[]: heading of the list/menu
- dialogBGcolor(optional): Look at the picture below for the color (*1)
- previewBGcolor(optional): Look at the picture below for the color (*2)
- tdSelectionColor(optional): Look at the picture below for the color (*3)
- returns: 1 success, 0 failed
- OnPlayerModelSelection(playerid, response, listid, modelid)
Called when a player selects a model or pressing esc
- playerid: playerid
- response: 1 = Model selected, 0 = canceled (esc)
- listid: The ID of the list
- modelid: selected model
- ShowModelSelectionMenuEx(playerid, items_array[], item_amount, header_text[], extraid, Float:Xrot = 0.0, Float:Yrot = 0.0, Float:Zrot = 0.0, Float:mZoom = 1.0, dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)
Show menu for player.
- playerid: playerid
- items_array[]: Array of items to be shown
- item_amount: Amount of items in items_array[] (For example: item_amount = 3 would show items_array[0-2])
- header_test[]: heading of the list/menu
- extraid: extraid which gets passed to OnPlayerModelSelectionEx after selection
- Xrot: X rotation for the previews
- Yrot: Y rotation for the previews
- Zrot: Z rotation for the previews
- mZoom: Zoom for the previews
- dialogBGcolor(optional): Look at the picture below for the color (*1)
- previewBGcolor(optional): Look at the picture below for the color (*2)
- tdSelectionColor(optional): Look at the picture below for the color (*3)
- returns: 1 success, 0 failed
- OnPlayerModelSelectionEx(playerid, response, extraid, modelid)
Called when a player selects a model or pressing esc
- playerid: playerid
- response: 1 = Model selected, 0 = canceled (esc)
- extraid: The extraid used in ShowModelSelectionMenuEx
- modelid: selected model
Why should you choose mSelection?
mSelection is simpler and easier to identifiy the vehicles/skins. They show a preview of that vehicle/skin, in contrast with the command "/setskin [playerid] [skinid]". With this command you must go to ****** and search for the skin ID, or try to memorize them all. On the other hand, mSelection shows a preview of the available skins that can be chosen. With mSelection, you don't need to go to ****** and search for the skin ID, but you can just scroll with the skin previews and you'll find the skin you were looking for. In simple words, making a /setskin command is more complex than mSelection.
Credits:
- a_samp: SAMP Team
- mSelection: d0
To start, open the mSelection zip file, and extract all of them to their right places.
Code:
filterscripts >> example.pwn, example2.pwn --------- filterscripts (OPTIONAL) pawno >> include >> mSelection.inc ------------ pawno >> include scriptfiles >> skins.txt, planes.txt -------------- scriptfiles
PHP Code:
#include <mSelection> //This will add the include file to the script so that it's features can be used in the script.
PHP Code:
new planelist = mS_INVALID_LISTID; //Creates a variable named planelist
PHP Code:
planelist = LoadModelSelectionMenu("planes.txt");
PHP Code:
CMD:planevehicle(playerid, params[]) //Creates a command /planevehicle
PHP Code:
{ //Opening bracket
PHP Code:
ShowModelSelectionMenu(playerid, planelist, "->Planes<-"); // Shows the player a menu with the caption.
PHP Code:
return 1; //Stops a function and goes back to the point in code which called the function in the first place
PHP Code:
} //Closing bracket
PHP Code:
CMD:planevehicle(playerid, params[]) //Creates a command /planevehicle
{ //Opening bracket
ShowModelSelectionMenu(playerid, planelist, "->Planes<-"); // Shows the player a menu with the caption.
return 1; //Stops a function and goes back to the point in code which called the function in the first place
} //Closing bracket
PHP Code:
public OnPlayerModelSelection(playerid, response, listid, modelid) //The callback
PHP Code:
{ //Opening bracket
PHP Code:
if(listid == planelist) //If the list id is equal to planelist...
PHP Code:
{ //Then...
PHP Code:
if(response) //If the player chooses the first option...
PHP Code:
{ //Then...
PHP Code:
SendClientMessage(playerid, 0xFF0000FF, "Plane Spawned"); //Send the player a message
PHP Code:
new Float:pos[3]; GetPlayerPos(playerid, pos[0], pos[1], pos[2]); //Creates a variable that gets the info of the player's position
PHP Code:
CreateVehicle(modelid, pos[0] + 2.5, pos[1], pos[2] + 2.5, 0.0, random(128), random(128), -1); //Creates a vehicle by the selected choice
PHP Code:
} //Closing bracket
PHP Code:
else SendClientMessage(playerid, 0xFF0000FF, "Canceled plane selection"); //If the player didn't select the 1st option, it will send the player a message.
PHP Code:
return 1;
PHP Code:
} //Closing bracket
PHP Code:
return 1;
PHP Code:
} //Closing bracket
PHP Code:
public OnPlayerModelSelection(playerid, response, listid, modelid)
{
if(listid == planelist)
{
if(response)
{
SendClientMessage(playerid, 0xFF0000FF, "Plane Spawned");
new Float:pos[3]; GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
CreateVehicle(modelid, pos[0] + 2.5, pos[1], pos[2] + 2.5, 0.0, random(128), random(128), -1);
}
else SendClientMessage(playerid, 0xFF0000FF, "Canceled plane selection");
return 1;
}
return 1;
}