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
Old 25/06/2018, 09:12 AM   #472
JaKe Elite
High-roller
 
JaKe Elite's Avatar
 
Join Date: Apr 2012
Location: Philippines
Posts: 3,692
Reputation: 484
Default Re: Dialogs include - Adding new styles to SAMP GUI

RESOLVED: A separate dialog include is interfering with the include.

Why can't I click on anything? I tried re-adjusting the preview (through the arrows) and it won't let me do it. I tried pressing the Select or Cancel button and they aren't responding either. However, if I press ESC, the arrows disappear but the preview dialog itself doesn't get hidden. What seems to be the problem here?

PHP Code:
#include     <a_samp>
//-------------//
#undef         MAX_PLAYERS
#define     MAX_PLAYERS         100
//-------------//
#include     <PreviewModelDialog>
#include     <zcmd>
#include     <sscanf2>
#include     <streamer>
#include     <foreach>

#define     MAX_ITEMS           1000

// Preview Model Dialogs
#define     DIALOG_ADD_ITEM     0

enum ITEM_ENUM {
    
itemID,
    
bool:itemTaken,
    
itemObject,
    
Float:itemX,
    
Float:itemY,
    
Float:itemZ,
    
Float:itemRX,
    
Float:itemRY,
    
Float:itemRZ
};
new 
ItemInfo[MAX_ITEMS][ITEM_ENUM];

enum PLAYER_ENUM {
    
p_Item,
};
new 
PlayerInfo[MAX_PLAYERS][PLAYER_ENUM];

new 
ITEM_MODELS[] = {
    
11736
};

new 
ITEM_NAMES[][] = {
    
"Bandage"
};

public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    new 
string[129];
    
    if(
dialogid == DIALOG_ADD_ITEM) {
        if(
response) {
            new 
itemid GetNewItemID();
            new 
Float:xFloat:yFloat:z;
            
GetPlayerPos(playeridxyz);

            if(
itemid != -1) {
                
format(stringsizeof(string), "** Now inserting: object ID (#%d) - adding as new game item..."ITEM_MODELS[listitem]);
                
SendClientMessage(playerid0x33AA33FFstring);

                
PlayerInfo[playerid][p_Item] = itemid;

                
ItemInfo[itemid][itemX] = x;
                
ItemInfo[itemid][itemY] = y;
                
ItemInfo[itemid][itemZ] = z;
                
ItemInfo[itemid][itemRX] = 0;
                
ItemInfo[itemid][itemRY] = 0;
                
ItemInfo[itemid][itemRZ] = 0;

                
ItemInfo[itemid][itemObject] = CreateDynamicObject(ITEM_MODELS[listitem], xyz000);
                
EditDynamicObject(playeridItemInfo[itemid][itemObject]);

            } else {
                
SendClientMessage(playerid, -1"** Server failed to retrieve a new itemID.");
                
SendClientMessage(playerid, -1"** No itemID retrieved, failed to insert a new item.");
            }
        }
    }
    return 
0;
}

public 
OnPlayerEditDynamicObject(playeridobjectidresponseFloat:xFloat:yFloat:zFloat:rxFloat:ryFloat:rz)
{
    new 
itemid PlayerInfo[playerid][p_Item], string[128];

    if(
objectid) {
        if(
IsValidDynamicObject(objectid)) return 1;
        
SetDynamicObjectPos(objectidxyz);
        
SetDynamicObjectRot(objectidrxryrz);
    }

    if(
response == EDIT_RESPONSE_FINAL) {
        
format(stringsizeof(string), "** You have finished editing item #%d."itemid);
        
SendClientMessage(playerid0x33AA33FFstring);
    
           
ItemInfo[itemid][itemX] = x;
        
ItemInfo[itemid][itemY] = y;
        
ItemInfo[itemid][itemZ] = z;
        
ItemInfo[itemid][itemRX] = rx;
        
ItemInfo[itemid][itemRY] = ry;
        
ItemInfo[itemid][itemRZ] = rz;
        
        
SetObjectPos(ItemInfo[itemid][itemObject], ItemInfo[itemid][itemX], ItemInfo[itemid][itemY], ItemInfo[itemid][itemZ]);
        
SetObjectRot(ItemInfo[itemid][itemObject], ItemInfo[itemid][itemRX], ItemInfo[itemid][itemRY], ItemInfo[itemid][itemRZ]);
    }
    if(
response == EDIT_RESPONSE_CANCEL) {
        
SendClientMessage(playerid0xFF0606FF"** You have cancelled editing an item.");
    
        
SetObjectPos(ItemInfo[itemid][itemObject], ItemInfo[itemid][itemX], ItemInfo[itemid][itemY], ItemInfo[itemid][itemZ]);
        
SetObjectRot(ItemInfo[itemid][itemObject], ItemInfo[itemid][itemRX], ItemInfo[itemid][itemRY], ItemInfo[itemid][itemRZ]);
    }
    return 
1;
}

CMD:additem(playeridparams[])
{
    
ShowPreviewModelDialog(playeridDIALOG_ADD_ITEM"Select an Item"ITEM_MODELSITEM_NAMES"Select""Cancel");
    return 
1;
}

stock GetNewItemID() {
    for(new 
iMAX_ITEMSi++) {
        if(
ItemInfo[i][itemTaken] != true) {
            return 
i;
        }
    }
    return -
1;

__________________



Last edited by JaKe Elite; 25/06/2018 at 01:50 PM.
JaKe Elite is offline   Reply With Quote
Old 25/06/2018, 09:44 AM   #473
CodeStyle175
Banned
 
Join Date: Apr 2014
Posts: 481
Reputation: 35
Default Re: Dialogs include - Adding new styles to SAMP GUI

if(IsValidDynamicObject(objectid)) return 1;
to
if(!IsValidDynamicObject(objectid)) return 1;
but you dont have to check this, because this wouldnt be called if it isnt dynamic.
and
SetObjectPos
SetObjectRot
to
SetDynamicObjectPos
SetDynamicObjectRot
PHP Code:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[]) 

    new 
string[129]; 
     
    if(
dialogid == DIALOG_ADD_ITEM) { 
        if(!
response)return SendClientMessage(playerid, -1"** You didn't select anything!");        
        new 
itemid GetNewItemID(); 
        if(
itemid == -1)return 
            
SendClientMessage(playerid, -1"** Server failed to retrieve a new itemID."), 
            
SendClientMessage(playerid, -1"** No itemID retrieved, failed to insert a new item."); 
        
        
PlayerInfo[playerid][p_Item] = itemid
        
ItemInfo[itemid][itemTaken]=true;
        
        
GetPlayerPos(playerid,ItemInfo[itemid][itemX],ItemInfo[itemid][itemY],ItemInfo[itemid][itemZ]);
        
ItemInfo[itemid][itemObject] = CreateDynamicObject(ITEM_MODELS[listitem], ItemInfo[itemid][itemX],ItemInfo[itemid][itemY], 0.00.00.0); 
        
        
EditDynamicObject(playeridItemInfo[itemid][itemObject]); 
        
        
format(stringsizeof(string), "** Now inserting: object ID (#%d) - adding as new game item..."ITEM_MODELS[listitem]); 
        
SendClientMessage(playerid0x33AA33FFstring); 
    } 
    return 
1
}
public 
OnPlayerEditDynamicObject(playeridobjectidresponseFloat:xFloat:yFloat:zFloat:rxFloat:ryFloat:rz

    new 
itemid PlayerInfo[playerid][p_Item], string[50];  
    if(
response == EDIT_RESPONSE_FINAL) {            
        
ItemInfo[itemid][itemX] = x
        
ItemInfo[itemid][itemY] = y
        
ItemInfo[itemid][itemZ] = z
        
ItemInfo[itemid][itemRX] = rx
        
ItemInfo[itemid][itemRY] = ry
        
ItemInfo[itemid][itemRZ] = rz
    
SetDynamicObjectPos(ItemInfo[itemid][itemObject], ItemInfo[itemid][itemX], ItemInfo[itemid][itemY], ItemInfo[itemid][itemZ]); 
        
SetDynamicObjectRot(ItemInfo[itemid][itemObject], ItemInfo[itemid][itemRX], ItemInfo[itemid][itemRY], ItemInfo[itemid][itemRZ]);    
        
format(stringsizeof(string), "** You have finished editing item #%d."itemid); 
        
SendClientMessage(playerid0x33AA33FFstring); 
    } 
    if(
response == EDIT_RESPONSE_CANCEL) {             
        
SetDynamicObjectPos(ItemInfo[itemid][itemObject], ItemInfo[itemid][itemX], ItemInfo[itemid][itemY], ItemInfo[itemid][itemZ]); 
        
SetDynamicObjectRot(ItemInfo[itemid][itemObject], ItemInfo[itemid][itemRX], ItemInfo[itemid][itemRY], ItemInfo[itemid][itemRZ]); 
        
        
SendClientMessage(playerid0xFF0606FF"** You have cancelled editing an item."); 
    } 
    return 
1

CodeStyle175 is offline   Reply With Quote
Old 25/06/2018, 01:45 PM   #474
JaKe Elite
High-roller
 
JaKe Elite's Avatar
 
Join Date: Apr 2012
Location: Philippines
Posts: 3,692
Reputation: 484
Default Re: Dialogs include - Adding new styles to SAMP GUI

Thank you for telling me the mistakes but it seems like those spotted mistakes has nothing to do with the issue though.
__________________


JaKe Elite is offline   Reply With Quote
Old 29/06/2018, 04:36 PM   #475
Dignity
High-roller
 
Dignity's Avatar
 
Join Date: May 2013
Location: Belgium
Posts: 1,934
Reputation: 1107
Default Re: Dialogs include - Adding new styles to SAMP GUI

The latest update no longer works with y_inline and y_dialogs.

Would you mind making it compatible again?
Dignity is offline   Reply With Quote
Old 30/06/2018, 09:18 PM   #476
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,806
Reputation: 831
Default Re: Dialogs include - Adding new styles to SAMP GUI

Quote:
Originally Posted by Dignity View Post
The latest update no longer works with y_inline and y_dialogs.

Would you mind making it compatible again?
I didn't change any syntax or compatibility. The only thing in the latest update is using memory.inc plugin. Is that why its not working?
__________________

My GitHub:

Gammix is offline   Reply With Quote
Old 30/06/2018, 10:44 PM   #477
Dignity
High-roller
 
Dignity's Avatar
 
Join Date: May 2013
Location: Belgium
Posts: 1,934
Reputation: 1107
Default Re: Dialogs include - Adding new styles to SAMP GUI

Quote:
Originally Posted by Gammix View Post
I didn't change any syntax or compatibility. The only thing in the latest update is using memory.inc plugin. Is that why its not working?
I don't know. I'll do some testing and tell you what's up.
Dignity is offline   Reply With Quote
Old 28/07/2018, 10:11 AM   #478
MRM
Big Clucker
 
MRM's Avatar
 
Join Date: Mar 2016
Location: Egypt
Posts: 125
Reputation: 0
Default Re: Dialogs include - Adding new styles to SAMP GUI

I have problem with player dialog.
PHP Code:
if (dialogstr[0] == EOS) { 
    for (new 
isizeof(PlayerSkins); i++) 
    {
        if(
PlayerSkins[i][playerid] == 0) break;
                        
format(captionsizeof caption"%i\tID: %i\n"PlayerSkins[i][playerid], PlayerSkins[i][playerid]); 
                        
strcat(dialogstrcaption);
    } 
}                
ShowPlayerDialog(playeridDIALOG_ASHOP1DIALOG_STYLE_PREVIEW_MODEL"Special skins"dialogstr"Select""Cancel"); 
When player change skin rotation with scrolls for other player skins got change.
How to fix it?
MRM is offline   Reply With Quote
Old 29/07/2018, 12:09 AM   #479
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,806
Reputation: 831
Default Re: Dialogs include - Adding new styles to SAMP GUI

Quote:
Originally Posted by MRM View Post
I have problem with player dialog.
PHP Code:
if (dialogstr[0] == EOS) { 
    for (new 
isizeof(PlayerSkins); i++) 
    {
        if(
PlayerSkins[i][playerid] == 0) break;
                        
format(captionsizeof caption"%i\tID: %i\n"PlayerSkins[i][playerid], PlayerSkins[i][playerid]); 
                        
strcat(dialogstrcaption);
    } 
}                
ShowPlayerDialog(playeridDIALOG_ASHOP1DIALOG_STYLE_PREVIEW_MODEL"Special skins"dialogstr"Select""Cancel"); 
When player change skin rotation with scrolls for other player skins got change.
How to fix it?
Use this function in your loop:
PHP Code:
SetDialogPreviewRotation(playeridlistitemFloat:rxFloat:ryFloat:rzFloat:zoom); 
Example:
PHP Code:
for (new isizeof(PlayerSkins); i++) 
{
    if(
PlayerSkins[i][playerid] == 0) break;
    
format(captionsizeof caption"%i\tID: %i\n"PlayerSkins[i][playerid], PlayerSkins[i][playerid]); 
    
strcat(dialogstrcaption);
                        
    
SetDialogPreviewRotation(playeridi0.00.0, -0.451.0);

__________________

My GitHub:

Gammix is offline   Reply With Quote
Old 29/07/2018, 03:46 PM   #480
MRM
Big Clucker
 
MRM's Avatar
 
Join Date: Mar 2016
Location: Egypt
Posts: 125
Reputation: 0
Default Re: Dialogs include - Adding new styles to SAMP GUI

Quote:
Originally Posted by Gammix View Post
Use this function in your loop:
PHP Code:
SetDialogPreviewRotation(playeridlistitemFloat:rxFloat:ryFloat:rzFloat:zoom); 
Example:
PHP Code:
for (new isizeof(PlayerSkins); i++) 
{
    if(
PlayerSkins[i][playerid] == 0) break;
    
format(captionsizeof caption"%i\tID: %i\n"PlayerSkins[i][playerid], PlayerSkins[i][playerid]); 
    
strcat(dialogstrcaption);
                        
    
SetDialogPreviewRotation(playeridi0.00.0, -0.451.0);

Not working ...
MRM 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 11:52 AM.


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