SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 09/06/2018, 04:41 PM   #471
youmasterd7
Little Clucker
 
Join Date: Jan 2014
Posts: 10
Reputation: 0
Default Re: PreviewModelDialog.inc - SAMP looking like dialog for preview models list

Quote:
Originally Posted by Gammix View Post

PreviewModelDialog.inc
v4.6 - Last Updated: 29 March, 2018

This include introduces you to a new dialog style: "DIALOG_STYLE_PREVIEW_MODEL". A SA-MP looking like dialog with both standard buttons but with preview models in a list form!

For preview of dialogs, skip down to examples for photos.

About/Functioning:
  • Define your own preview dialog size
    You can have as many listitems you want, just pre-define this constant before including this library, e.g.:
    PHP Code:
    #define MAX_DIALOG_PREVIEW_MODELS 15
    #include <PreviewModelDialog.inc> 
    Similar way you can also define each preview listitem text size:
    PHP Code:
    #define MAX_DIALOG_PREVIEW_MODELS 15
    #define MAX_DIALOG_PREVIEW_TEXTSIZE 32
    #include <PreviewModelDialog.inc> 
  • No pre-allocation of memory
    The include works with BigETI's pawn-memory plugin allowing dynamic memory management, so you won't get huge .amx sizes.
  • Big enough preview
    I had this complain about previous version dialog having very small preview models and text which was barely readable, now its not the case huh?!
  • Players rotate/zoom models in game
    Yes as you can see in this picture, those LEFT and RIGHT arrows let players to rotate their selected models to view it full.
    And UP and DOWN arrows later added in v4.5, lets you zoom in and out now!

    The number at bottom represents the rotation (Z angle).
    In v4.5, the middle right represents the zoom level.


  • Functions
    Support samp dialog function "ShowPlayerDialog". Check the examples for how to use.
    Anyways, those who like using array of data, there is also a function for passing arrays for showing a preview model dialog:
    PHP Code:
    ShowPreviewModelDialog(playeriddialogidcaption[], models[], labels[][], button1[], button2[], size sizeof models); 
  • Scripter can set each model rotation
    You can set each model rotation before even showing the dialog to player, just use this:
    PHP Code:
    SetDialogPreviewRotation(playeridlistitemFloat:rxFloat:ryFloat:rzFloat:zoom); 
    NOTE: if player changes the preview model rotation in game, the value is affected in your function too.
  • A perfect scroll bar
    Yep, i just discovered if you want to make scrollbars or even boxes with textdraws, always use Sprites. The textsize of sprites is comparable with positioning of textdraws, so you don't really need algorithms for comparison.
  • GameText codes in listitems
    Since the dialog is made with pure textdraws, you can use label codes (e.g. ~n~ - switch line or ~r~ - red color) in preview model's labeltext.

Example: ShowPlayerDialog

A simple skin selection dialog with all samp skins as listitems.



Source:
PHP Code:
CMD:skins(playerid) {
    const 
MAX_SKINS 312;
    static 
string[MAX_SKINS 16];
    
    if (
string[0] == EOS) {
        for (new 
iMAX_SKINSi++) {
            
format(stringsizeof string"%s%i\tID: %i\n"stringii);
        }
    }
    
    return 
ShowPlayerDialog(playerid0DIALOG_STYLE_PREVIEW_MODEL"Skin Selection Dialog"string"Select""Cancel");
}

public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[]) {
    if (
dialogid == 0) {
        if (
response) {
            
SetPlayerSkin(playeridlistitem);
            
GameTextForPlayer(playerid"~g~Skin Changed!"30003);
        }
    }
    return 
1;

Example: ShowPreviewModelDialog

A simple weapon selection dialog made using array method. This way is slightly faster than using strings in ShowPlayerDialog and it more readable but it hardly matters here!



Source:
PHP Code:
new WEAPON_MODELS[] = {
    
342343344359360361363366
};

new 
WEAPON_NAMES[][] = {
    
"Grenade""Tear Gas""Moltov""RPG""HS Rocket""Flamethrower""Satchel""Fire Extinguisher"
};

new 
WEAPON_IDS[] = {
    
WEAPON_GRENADEWEAPON_TEARGASWEAPON_MOLTOVWEAPON_ROCKETLAUNCHERWEAPON_HEATSEEKERWEAPON_FLAMETHROWERWEAPON_SATCHELWEAPON_FIREEXTINGUISHER
};

CMD:weapons(playerid) {
    return 
ShowPreviewModelDialog(playerid0"Weapon Selection Dialog"WEAPON_MODELSWEAPON_NAMES"Select""Cancel");
}

public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[]) {
    if (
dialogid == 0) {
        if (
response) {
            
GivePlayerWeapon(playeridWEAPON_IDS[listitem], 100);
            
GameTextForPlayer(playerid"~g~Weapon spawned!"30003);
        }
    }
    return 
1;

Download:
https://github.com/Agneese-Saini/SA-...odelDialog.inc

Dependencies:
pawn-memory (Plugin) - http://forum.sa-mp.com/showthread.php?t=645166

Convert From mSelection:
- Coming soon -
I need the inc memory plugins, the ones that are on the internet and the memory page is not compatible with the one you use here
youmasterd7 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] Items spawner dialogs (zcmd & dialogs include) Q_Lite Filterscripts 17 16/10/2016 11:09 AM
[FilterScript] [FS]Fighting Styles,5 most usable styles Like in SP By Don_(GH) HAYTXA Filterscripts 10 28/03/2013 06:39 AM
Making an OnFilterScriptInit in an include without adding anything in the .pwn exepct the #include r3k1lLz_ Help Archive 6 06/01/2011 06:49 AM
[FilterScript] [FS]Trans World Airlines v0.2 [TWA] - Bug Fixed - Adding Dialogs Soon. Toni Filterscripts 16 13/06/2010 02:57 PM
[FilterScript] [FS] Fighting Styles (0.3a) - |Save styles in Dini| MoBiL[e] Filterscripts 23 24/04/2010 11:12 AM


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


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