SA-MP Forums Archive
[Include] [0.3X] mSelection 1.1 R3 - Create Model Preview Menus with a few lines of code - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] [0.3X] mSelection 1.1 R3 - Create Model Preview Menus with a few lines of code (/showthread.php?tid=407045)

Pages: 1 2 3 4 5 6


[0.3X] mSelection 1.1 R3 - Create Model Preview Menus with a few lines of code - d0 - 12.01.2013

mSelection(For SA-MP 0.3x and above)

(Translation: German translation/Deutsche Ьbersetzung
)

A include which adds the possibility to create Model Preview Menus with only a few lines of code.

Updates
- 1.1 R3
Fixes Bug with blocking OnPlayerClick(Player)TextDraw
The selection menu instantly closed in all earlier verions if used/shown in OnDialogResponse

- 1.1 R2
Fixes bug when pressing ESC

- 1.1
Fixes bug when pressing ESC
Adds dynamic per player menus
Adds "cancel" button to the menus

- 1.0 R3:
Fixes bug with using ShowModelSelectionMenu in OnPlayerModelSelection

- 1.0 R2:
Adds possibility to use ShowModelSelectionMenu in OnPlayerModelSelection

Overview

pawn Код:
// for both (static and per player lists)
HideModelSelectionMenu(playerid)
//static lists
LoadModelSelectionMenu(f_name[])
ShowModelSelectionMenu(playerid, ListID, header_text[], dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)

forward OnPlayerModelSelection(playerid, response, listid, modelid);
//dynamic per player lists
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)

forward OnPlayerModelSelectionEx(playerid, response, extraid, modelid);
Example Script

Example #1 Static Lists
Scriptfiles: planes.txt - skins.txt
pawn Код:
#include <a_samp>
#include <mSelection>

new planelist = mS_INVALID_LISTID;
new skinlist = mS_INVALID_LISTID;
public OnFilterScriptInit()
{
    planelist = LoadModelSelectionMenu("planes.txt");
    skinlist = LoadModelSelectionMenu("skins.txt");
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/plane", true) == 0)
    {
        ShowModelSelectionMenu(playerid, planelist, "->Planes<-");
        return 1;
    }
    if(strcmp(cmdtext, "/changeskin", true) == 0)
    {
        ShowModelSelectionMenu(playerid, skinlist, "Select Skin");
        return 1;
    }
    return 0;
}

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;
    }
    if(listid == skinlist)
    {
        if(response)
        {
            SendClientMessage(playerid, 0xFF0000FF, "Skin Changed");
            SetPlayerSkin(playerid, modelid);
        }
        else SendClientMessage(playerid, 0xFF0000FF, "Canceled skin selection");
        return 1;
    }
    return 1;
}
Example #2 Dynamic per player lists
pawn Код:
#include <a_samp>
#include <mSelection>

#define CUSTOM_TRAILER_MENU 1

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/selectVehicleTrailer", true) == 0)
    {
        new cars[15];
        cars[0] = 435;
        cars[1] = 450;
        cars[2] = 569;
        cars[3] = 570;
        cars[4] = 584;
        cars[5] = 590;
        cars[6] = 591;
        cars[7] = 606;
        cars[8] = 607;
        cars[9] = 608;
        cars[10] = 610;
        cars[11] = 611;
        ShowModelSelectionMenuEx(playerid, cars, 12, "Select trailer", CUSTOM_TRAILER_MENU, 16.0, 0.0, -55.0);
        return 1;
    }
    return 0;
}

public OnPlayerModelSelectionEx(playerid, response, extraid, modelid)
{
    if(extraid == CUSTOM_TRAILER_MENU)
    {
        if(response)
        {
            SendClientMessage(playerid, 0xFF0000FF, "Trailer 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 trailer selection");
    }
    return 1;
}
Thanks to:
Kye: for creating vspawner.pwn


Downloads:
Include+Example Script+Scriptfiles: View attachments


Re: [0.3X] mSelection 1.0 - Create Model Preview Menus with a few lines of code - pasha97 - 12.01.2013

omg, i even can't express all my feelings!! This is awesome dude! THank you a lot!


Re: [0.3X] mSelection 1.0 - Create Model Preview Menus with a few lines of code - Black Wolf - 12.01.2013

Cool man thanks for it
You've maded it alot easier.


Respuesta: [0.3X] mSelection 1.0 - Create Model Preview Menus with a few lines of code - oOFotherOo - 12.01.2013

Nice ! Thanks you.


Re: [0.3X] mSelection 1.0 - Create Model Preview Menus with a few lines of code - Mean - 12.01.2013

Nice work, will definitely come useful.


Re: [0.3X] mSelection 1.0 - Create Model Preview Menus with a few lines of code - pasha97 - 12.01.2013

Can you help me, i dont undestand why this doesn't work
pawn Код:
if(listid == mainvlist)
    {

        if(response)
        {

            if(modelid==519)
            {
     
            ShowModelSelectionMenu(playerid, planelist, "Planes");
            }
            if(modelid==487)
            {
            ShowModelSelectionMenu(playerid, helicopterslist, "Helicopters");
            }
            if(modelid==522)
            {
            ShowModelSelectionMenu(playerid, bikeslist, "Bikes");
            }
            if(modelid==560)
            {
            ShowModelSelectionMenu(playerid, carslist, "Cars");
            }
            if(modelid==452)
            {
            ShowModelSelectionMenu(playerid, boatslist, "Boats");
            }
            if(modelid==19336)
            {
            ShowModelSelectionMenu(playerid, specialslist, "Specials");
            }
            if(modelid==501)
            {
            ShowModelSelectionMenu(playerid, rclist, "RC vehicles");
            }
        }
        return 1;
    }
every thing is ok, there are all required files in script files, and i used LoadModelSelectionMenu in OnGameModeINnit


Re: [0.3X] mSelection 1.0 - Create Model Preview Menus with a few lines of code - d0 - 12.01.2013

Quote:
Originally Posted by pasha97
Посмотреть сообщение
Can you help me, i dont undestand why this doesn't work
pawn Код:
if(listid == mainvlist)
    {

        if(response)
        {

            if(modelid==519)
            {
     
            ShowModelSelectionMenu(playerid, planelist, "Planes");
            }
            if(modelid==487)
            {
            ShowModelSelectionMenu(playerid, helicopterslist, "Helicopters");
            }
            if(modelid==522)
            {
            ShowModelSelectionMenu(playerid, bikeslist, "Bikes");
            }
            if(modelid==560)
            {
            ShowModelSelectionMenu(playerid, carslist, "Cars");
            }
            if(modelid==452)
            {
            ShowModelSelectionMenu(playerid, boatslist, "Boats");
            }
            if(modelid==19336)
            {
            ShowModelSelectionMenu(playerid, specialslist, "Specials");
            }
            if(modelid==501)
            {
            ShowModelSelectionMenu(playerid, rclist, "RC vehicles");
            }
        }
        return 1;
    }
every thing is ok, there are all required files in script files, and i used LoadModelSelectionMenu in OnGameModeINnit
A bug with using ShowModelSelectionMenu inside of OnPlayerModelSelection

Download R2 from the first post to be able to use ShowModelSelectionMenu in OnPlayerModelSelection


Re: [0.3X] mSelection 1.0 - Create Model Preview Menus with a few lines of code - pasha97 - 12.01.2013

Quote:
Originally Posted by D0erfler
Посмотреть сообщение
A bug with using ShowModelSelectionMenu inside of OnPlayerModelSelection

Download R2 from the first post to be able to use ShowModelSelectionMenu in OnPlayerModelSelection
thank you! but it doesn't work The next selection meny appears for fiew moments and then dissapears again. It sounds like when i click the selection, the next selection menu autimatically cancels.


Re: [0.3X] mSelection 1.0 - Create Model Preview Menus with a few lines of code - d0 - 12.01.2013

Quote:
Originally Posted by pasha97
Посмотреть сообщение
thank you! but it doesn't work The next selection meny appears for fiew moments and then dissapears again.
Show the whole script please

Edit: I see the problem, CancelSelectTextDraw is called after the first selection and the client takes a while to respond to that function which causes the new menu to get hidden as soon the sa-mp client responses to CancelSelectTextDraw.
Will add something like a minimum time of having the menu open(~1 second) to fix it.

Check back in a few moments and download R3

Edit: It's fixed and tested now, download R3
and thanks for reporting the problem


Re: [0.3X] mSelection 1.0 R2 - Create Model Preview Menus with a few lines of code - Baboon - 12.01.2013

This looks pretty neat ,
but could you perhaps modify the menu so we are able to do the same as CreateMenu? So we can use AddMenuItem?
This would be super usefull whenever people want to script inventories.


Re: [0.3X] mSelection 1.0 - Create Model Preview Menus with a few lines of code - pasha97 - 12.01.2013

Quote:
Originally Posted by D0erfler
Посмотреть сообщение
Show the whole script please

Edit: I see the problem, CancelSelectTextDraw is called after the first selection and the client takes a while to respond to that function which causes the new menu to get hidden as soon the sa-mp client responses to CancelSelectTextDraw.
Will add something like a minimum time of having the menu open(~1 second) to fix it.

Check back in a few moments and download R3

Edit: It's fixed and tested now, download R3
and thanks for reporting the problem
Thank you a lot, i will try the R3 version tomorrow!


Re: [0.3X] mSelection 1.0 R3 - Create Model Preview Menus with a few lines of code - admantis - 12.01.2013

Thank you for this very useful include,
It was annoying to edit the vspawner.pwn file accordingly to your needs, and this makes it much easier, I'll be using it now, but it is still static and can't use dynamic options, like with dialogs or menus. I'll not discard this include.


Re: [0.3X] mSelection 1.0 R3 - Create Model Preview Menus with a few lines of code - d0 - 12.01.2013

Quote:
Originally Posted by admantis
Посмотреть сообщение
Thank you for this very useful include,
It was annoying to edit the vspawner.pwn file accordingly to your needs, and this makes it much easier, I'll be using it now, but it is still static and can't use dynamic options, like with dialogs or menus. I'll not discard this include.
I already added dynamic lists/menus for the next version, should be ready for tomorrow.


Re: [0.3X] mSelection 1.0 R3 - Create Model Preview Menus with a few lines of code - zJordioz - 12.01.2013

Awesome, nice one


Re: [0.3X] mSelection 1.0 R3 - Create Model Preview Menus with a few lines of code - Memoryz - 12.01.2013

Do you think you could add a version with a button to close it instead of choosing something?


Re: [0.3X] mSelection 1.0 R3 - Create Model Preview Menus with a few lines of code - admantis - 12.01.2013

Quote:
Originally Posted by Memoryz
Посмотреть сообщение
Do you think you could add a version with a button to close it instead of choosing something?
You can press escape to close the menu, or you could create another button that will hide the selection textdraws.


Re: [0.3X] mSelection 1.0 R3 - Create Model Preview Menus with a few lines of code - pasha97 - 13.01.2013

I think it would be awesome, if we could write titles for each item. Perhaps, we could write a title for an item in the file. SO, every line would look like that:

modelID Title xRot yRot zRot Zoom

For example,

445 Saloon 0.0 0.0 45.0 1.0


Re: [0.3X] mSelection 1.0 R3 - Create Model Preview Menus with a few lines of code - Kevin FOx - 13.01.2013

pawn Код:
C:\Users\sawab center\Desktop\samp03x_svr_RC1_win32\pawno\include\mSelection.inc(178) : error 017: undefined symbol "TEXT_DRAW_FONT_MODEL_PREVIEW"
C:\Users\sawab center\Desktop\samp03x_svr_RC1_win32\pawno\include\mSelection.inc(182) : error 017: undefined symbol "PlayerTextDrawSetPreviewModel"
C:\Users\sawab center\Desktop\samp03x_svr_RC1_win32\pawno\include\mSelection.inc(183) : error 017: undefined symbol "PlayerTextDrawSetPreviewRot"
C:\Users\sawab center\Desktop\samp03x_svr_RC1_win32\pawno\include\mSelection.inc(175) : warning 203: symbol is never used: "mZoom"
C:\Users\sawab center\Desktop\samp03x_svr_RC1_win32\pawno\include\mSelection.inc(175) : warning 203: symbol is never used: "Zrot"
C:\Users\sawab center\Desktop\samp03x_svr_RC1_win32\pawno\include\mSelection.inc(175) : warning 203: symbol is never used: "Yrot"
C:\Users\sawab center\Desktop\samp03x_svr_RC1_win32\pawno\include\mSelection.inc(175) : warning 203: symbol is never used: "Xrot"
C:\Users\sawab center\Desktop\samp03x_svr_RC1_win32\pawno\include\mSelection.inc(175) : warning 203: symbol is never used: "modelindex"
Any help?!


Re: [0.3X] mSelection 1.0 R3 - Create Model Preview Menus with a few lines of code - Edvin - 13.01.2013

Lol, thanks a lot I will use this!


Re: [0.3X] mSelection 1.0 R3 - Create Model Preview Menus with a few lines of code - pasha97 - 13.01.2013

Quote:
Originally Posted by Kevin FOx
Посмотреть сообщение
pawn Код:
C:\Users\sawab center\Desktop\samp03x_svr_RC1_win32\pawno\include\mSelection.inc(178) : error 017: undefined symbol "TEXT_DRAW_FONT_MODEL_PREVIEW"
C:\Users\sawab center\Desktop\samp03x_svr_RC1_win32\pawno\include\mSelection.inc(182) : error 017: undefined symbol "PlayerTextDrawSetPreviewModel"
C:\Users\sawab center\Desktop\samp03x_svr_RC1_win32\pawno\include\mSelection.inc(183) : error 017: undefined symbol "PlayerTextDrawSetPreviewRot"
C:\Users\sawab center\Desktop\samp03x_svr_RC1_win32\pawno\include\mSelection.inc(175) : warning 203: symbol is never used: "mZoom"
C:\Users\sawab center\Desktop\samp03x_svr_RC1_win32\pawno\include\mSelection.inc(175) : warning 203: symbol is never used: "Zrot"
C:\Users\sawab center\Desktop\samp03x_svr_RC1_win32\pawno\include\mSelection.inc(175) : warning 203: symbol is never used: "Yrot"
C:\Users\sawab center\Desktop\samp03x_svr_RC1_win32\pawno\include\mSelection.inc(175) : warning 203: symbol is never used: "Xrot"
C:\Users\sawab center\Desktop\samp03x_svr_RC1_win32\pawno\include\mSelection.inc(175) : warning 203: symbol is never used: "modelindex"
Any help?!
update your samp includes to 0.3x!