[Tutorial] Menu Plane Selection | Using mSelection
#1

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:
  • HideModelSelectionMenu(playerid)
    Hide menu for player.
    1. playerid: playerid
    2. returns: nothing

  • ShowModelSelectionMenu(playerid, ListID, header_text[], dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)
    Show menu for player.
    1. playerid: playerid
    2. ListID: The ID of the list/menu to be shown
    3. header_test[]: heading of the list/menu
    4. dialogBGcolor(optional): Look at the picture below for the color (*1)
    5. previewBGcolor(optional): Look at the picture below for the color (*2)
    6. tdSelectionColor(optional): Look at the picture below for the color (*3)
    7. returns: 1 success, 0 failed

  • OnPlayerModelSelection(playerid, response, listid, modelid)
    Called when a player selects a model or pressing esc
    1. playerid: playerid
    2. response: 1 = Model selected, 0 = canceled (esc)
    3. listid: The ID of the list
    4. 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.
    1. playerid: playerid
    2. items_array[]: Array of items to be shown
    3. item_amount: Amount of items in items_array[] (For example: item_amount = 3 would show items_array[0-2])
    4. header_test[]: heading of the list/menu
    5. extraid: extraid which gets passed to OnPlayerModelSelectionEx after selection
    6. Xrot: X rotation for the previews
    7. Yrot: Y rotation for the previews
    8. Zrot: Z rotation for the previews
    9. mZoom: Zoom for the previews
    10. dialogBGcolor(optional): Look at the picture below for the color (*1)
    11. previewBGcolor(optional): Look at the picture below for the color (*2)
    12. tdSelectionColor(optional): Look at the picture below for the color (*3)
    13. returns: 1 success, 0 failed

  • OnPlayerModelSelectionEx(playerid, response, extraid, modelid)
    Called when a player selects a model or pressing esc
    1. playerid: playerid
    2. response: 1 = Model selected, 0 = canceled (esc)
    3. extraid: The extraid used in ShowModelSelectionMenuEx
    4. 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
Tutorial

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
Open your gamemode/filterscript .pwn file using pawno, and add this on top of your script
PHP Code:
#include <mSelection> //This will add the include file to the script so that it's features can be used in the script. 
Add this somewhere ontop of your script, below the includes
PHP Code:
new planelist mS_INVALID_LISTID//Creates a variable named planelist 
Add this inside OnGamemodeInit
PHP Code:
    planelist LoadModelSelectionMenu("planes.txt"); 
For the command
PHP Code:
CMD:planevehicle(playeridparams[]) //Creates a command /planevehicle 
PHP Code:
    //Opening bracket 
PHP Code:
        ShowModelSelectionMenu(playeridplanelist"->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 
Whole command code
PHP Code:
CMD:planevehicle(playeridparams[]) //Creates a command /planevehicle
//Opening bracket
    
ShowModelSelectionMenu(playeridplanelist"->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 
Below your script
PHP Code:
public OnPlayerModelSelection(playeridresponselistidmodelid//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(playerid0xFF0000FF"Plane Spawned"); //Send the player a message 
PHP Code:
            new Float:pos[3]; GetPlayerPos(playeridpos[0], pos[1], pos[2]); //Creates a variable that gets the info of the player's position 
PHP Code:
            CreateVehicle(modelidpos[0] + 2.5pos[1], pos[2] + 2.50.0random(128), random(128), -1); //Creates a vehicle by the selected choice 
PHP Code:
        //Closing bracket 
PHP Code:
        else SendClientMessage(playerid0xFF0000FF"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 
Whole callback with functions
PHP Code:
public OnPlayerModelSelection(playeridresponselistidmodelid)
{
    if(
listid == planelist)
    {
        if(
response)
        {
            
SendClientMessage(playerid0xFF0000FF"Plane Spawned");
            new 
Float:pos[3]; GetPlayerPos(playeridpos[0], pos[1], pos[2]);
            
CreateVehicle(modelidpos[0] + 2.5pos[1], pos[2] + 2.50.0random(128), random(128), -1);
        }
        else 
SendClientMessage(playerid0xFF0000FF"Canceled plane selection");
        return 
1;
    }
    return 
1;

Reply
#2

This is by far worst tutorial I've read lately, a bunch copy-pastes, without literally adding a word to it.
Reply
#3

Sorry for that. It's my second tutorial. Please reply for suggestions so that I can learn from my mistakes. Again, I'm sorry for it. I'm a beginner in making tutorials, so please do help me. Thanks for the feedback
Reply
#4

strcmp is slowest method in command processing you should use any other command processors.
Reply
#5

Quote:
Originally Posted by GhostHacker
View Post
strcmp is slowest method in command processing you should use any other command processors.
Use ZCMD or even pawn.cmd.
Reply
#6

Thanks for the suggestion! Edited it.
Reply
#7

Quote:
Originally Posted by ALiScripter
View Post
Use ZCMD or even pawn.cmd.
they are command processors
Reply
#8

Quote:
Originally Posted by GhostHacker
View Post
strcmp is slowest method in command processing you should use any other command processors.
You are lacking knowledge of why commands that use strcmp even get slow. He only has one command, so for the purpose of this tutorial, switching was completely unnecessary.

---------------------------------------------------------------------------

You should have created a release thread instead, because this isn't a tutorial.
Reply
#9

Quote:
Originally Posted by SickAttack
View Post
You are lacking knowledge of why commands that use strcmp even get slow. He only has one command, so for the purpose of this tutorial, switching was completely unnecessary.
you lack common sense !!! no one would make use of this tutorial in one single script.This is a tutroial that involves a part of scripting process.Not a one single release lol.
Reply
#10

Quote:
Originally Posted by GhostHacker
View Post
you lack common sense !!! no one would make use of this tutorial in one single script.This is a tutroial that involves a part of scripting process.Not a one single release lol.
Now that makes absolutely no-sense (it's not even related to my reply). If you had common sense, you wouldn't have suggested that he uses ZCMD instead, because he only has one command! When one has multiple commands, that's when it starts getting "slow" (not all commands - not sure if you already realized why it's like that).

Every tutorial related to creating or how to do something involves "a part of scripting process", so I have no idea what you're talking about.

Even though this thread is just putting each line of the entire code within separate tags, people still use mSelection and might look at this tutorial at some point (they might even copy/paste the code, e.g. beginners), so everything you said is flawed
Reply
#11

NICE JOB!
Reply
#12

Despite the fact that you can't have commands that use strcmp as a base, and commands using ZCMD at the same time. You're wrong again. They would have to change it either way.

A command created using ZCMD isn't superior than one command using strcmp as its base. Logically, the command using strcmp should be faster, but would make no significant difference either way.

It's not outdated, and it's still valid. You just have to know when you should use it.
Reply
#13

Quote:
Originally Posted by SickAttack
View Post
Despite the fact that you can't have commands that use strcmp as a base, and commands using ZCMD at the same time. You're wrong again. They would have to change it either way.
And now you techinically agreeing with me lol
and why you shouldnt use strcmp
i will give eg
PHP Code:
if (!strcmp(cmdtext"/he"))
{
// Do something

now type /hello and you will understand.
Reply
#14

Quote:
Originally Posted by GhostHacker
View Post
And now you techinically agreeing with me lol
and why you shouldnt use strcmp
i will give eg
PHP Code:
if (!strcmp(cmdtext"/he"))
{
// Do something

now type /hello and you will understand.
strcmp(const string1[], const string2[], bool:ignorecase=false, length=cellmax);

Use length = 3 and /hello will stop working, only /he will.
Reply
#15

Quote:
Originally Posted by GhostHacker
View Post
And now you techinically agreeing with me lol
and why you shouldnt use strcmp
i will give eg
PHP Code:
if (!strcmp(cmdtext"/he"))
{
// Do something

now type /hello and you will understand.
You make no sense, I never agreed on anything you said. Nor what you're saying is relevant to this thread, nor is this a discussion about comparing both methods.

The point is, he didn't have to switch to ZCMD for the purpose of this tutorial. So if you have nothing useful to add to this thread, you maybe shouldn't reply to it.

One command using strcmp is faster than a command using ZCMD (if you know how ZCMD does the proccess). But then, it makes no significant difference.

Quote:
Originally Posted by GhostHacker
View Post
strcmp is slowest method in command processing you should use any other command processors.
Not true in this case.
Reply
#16

Quote:
Originally Posted by SickAttack
View Post
One command using strcmp is faster than a command using ZCMD (if you know how ZCMD does the proccess). But then, it makes no significant difference.



Not true in this case.
how many times i have to say that there will not be only one command bruh cant you understand what im saying?
Reply
#17

Quote:
Originally Posted by GhostHacker
View Post
how many times i have to say that there will not be only one command bruh cant you understand what im saying?
You're being stupid... Where was there any other commands in this script?

There is only one command, and there is no issue with using the strcmp method because of this...
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)