SA-MP Forums Archive
[Include] Dialogs include - Adding new styles to SAMP GUI - 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] Dialogs include - Adding new styles to SAMP GUI (/showthread.php?tid=570213)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17


PreviewModelDialog.inc - SAMP looking like dialog for preview models list - Gammix - 06.04.2015

PreviewModelDialog.inc

Version: 4.7.2 || Last Updated: 14 October, 2019
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.

Functionality:
Example: Basic ShowPlayerDialog

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



Source:
PHP Code:
CMD:skins(playerid) {
    const 
MAX_SKINS 312;
    new 
subString[16];
    static 
string[MAX_SKINS sizeof(subString)];
    if (
string[0] == EOS) {
        for (new 
iMAX_SKINSi++) {
            
format(subStringsizeof(subString), "%i\tID: %i\n"ii);
            
strcat(stringsubString);
        }
    }
    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: Modified Rotations in ShowPlayerDialog

A simple weapon shop dialog, you can modify the array, add/delete weapons from it and the dialog shape itself!
You can also see i used custom rotations for each listitem in this dialog.



Source:
PHP Code:
enum E_WEAPON_SHOP_DATA {
    
WEAPON_MODELID,
    
WEAPON_NAME[35],
    
WEAPON_PRICE,
    
WEAPON_AMMO,
    
WEAPON_ID
};
new const 
WEAPON_SHOP[][E_WEAPON_SHOP_DATA] = {
    {
335"Knife"01WEAPON_KNIFE},
    {
341"Chainsaw"15001WEAPON_CHAINSAW},
    {
342"Grenade"15451WEAPON_GRENADE},
    {
343"Moltove"17451WEAPON_MOLTOV},
    {
347"Silenced 9mm"1500150WEAPON_SILENCED},
    {
348"Desert Eagle"3199150WEAPON_DEAGLE},
    {
350"Sawed Off Shotgun"4999100WEAPON_SAWEDOFF},
    {
351"Spas12 Shotgun"3870100WEAPON_SHOTGSPA},
    {
352"Micro-UZI"3500300WEAPON_UZI},
    {
353"MP5"2999200WEAPON_MP5},
    {
372"Tec-9"3500300WEAPON_TEC9},
    {
358"Sniper Rifle"499950WEAPON_SNIPER},
    {
355"Ak47"2999200WEAPON_AK47},
    {
356"M4"3155200WEAPON_M4},
    {
359"RPG"19991WEAPON_ROCKETLAUNCHER},
    {
361"Flamethrower"3500350WEAPON_FLAMETHROWER},
    {
362"Minigun"10000350WEAPON_MINIGUN},
    {
363"Satchel Charge"19992WEAPON_SATCHEL},
    {
365"Spray Can"800200WEAPON_SPRAYCAN},
    {
366"Fire Extinguisher"855200WEAPON_FIREEXTINGUISHER}
};
CMD:weapons(playerid) {
    new 
subString[64];
    static 
string[sizeof(WEAPON_SHOP) * sizeof(subString)];
    if (
string[0] == EOS) {
        for (new 
isizeof(WEAPON_SHOP); i++) {
            
format(subStringsizeof(subString), "%i(0.0, 0.0, -50.0, 1.5)\t%s~n~~g~~h~$%i\n"WEAPON_SHOP[i][WEAPON_MODELID], WEAPON_SHOP[i][WEAPON_NAME], WEAPON_SHOP[i][WEAPON_PRICE]);
            
strcat(stringsubString);
        }
    }
    return 
ShowPlayerDialog(playerid1DIALOG_STYLE_PREVIEW_MODEL"Weapon Shop Dialog"string"Purchase""Cancel");
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[]) {
    if (
dialogid == 1) {
        if (
response) {
            if (
GetPlayerMoney(playerid) < WEAPON_SHOP[listitem][WEAPON_PRICE]) {
                
SendClientMessage(playerid0xAA0000FF"Not enough money to purchase this gun!");
                return 
cmd_weapons(playerid);
            }
            
            
GivePlayerMoney(playerid, -WEAPON_SHOP[listitem][WEAPON_PRICE]);
            
GivePlayerWeapon(playeridWEAPON_SHOP[listitem][WEAPON_ID], WEAPON_SHOP[listitem][WEAPON_AMMO]);
            
            
GameTextForPlayer(playerid"~g~Gun Purchased!"30003);
        }
    }
    return 
1;

Download:

PreviewModelDialog.inc: https://github.com/Agneese-Saini/SA-...ginVersion.inc

PreviewModelDialog.inc (plugin-free-version): https://github.com/Agneese-Saini/SA-...reeVersion.inc

If you are using the recommended version i.e. memory plugin version, you'll need to download and install Pawn-Memory plugin, link below.
pawn-memory.dll/.so: https://sampforum.blast.hk/showthread.php?tid=645166


Re: Dialogs Include (new dialog functions and DIALOG_STYLE_PREVMODEL) - RaeF - 06.04.2015

Great job man!


Re: Dialogs Include (new dialog functions and DIALOG_STYLE_PREVMODEL) - Gammix - 06.04.2015

Thanks^

UPDATE R2 - 6th April, 2015


Re: Dialogs Include (new dialog functions and DIALOG_STYLE_PREVMODEL) - Kapersky™ - 06.04.2015

Nice work! Looks sick! *appreciated*.


Re: Dialogs Include (new dialog functions and DIALOG_STYLE_PREVMODEL) - R0 - 06.04.2015

Nice,btw i was working on an include like this to release too.


Re: Dialogs Include (new dialog functions and DIALOG_STYLE_PREVMODEL) - Pottus - 08.04.2015

pawn Code:
public OnPlayerConnect(playerid)
{
        Dialog_Reset(playerid);
Why bother? It's done in OnPlayerDisconnect().

Line 189:
pawn Code:
format(gPlayerList[playerid][i][E_desc], 28, "");
// Do this
gPlayerList[playerid][i][E_desc][0] = '\0';
You for got to clean up playerdraws in OnGameModeExit() / OnFilterScriptExit()


Re: Dialogs Include (new dialog functions and DIALOG_STYLE_PREVMODEL) - RaeF - 08.04.2015

Sorry, but it's look neat


Re: Dialogs Include (new dialog functions and DIALOG_STYLE_PREVMODEL) - Gammix - 08.04.2015

Quote:
Originally Posted by Pottus
View Post
pawn Code:
public OnPlayerConnect(playerid)
{
        Dialog_Reset(playerid);
Why bother? It's done in OnPlayerDisconnect().
Maybe because my dialog functions don't check if player is connected!

Quote:
Originally Posted by Pottus
View Post
Line 189:
pawn Code:
format(gPlayerList[playerid][i][E_desc], 28, "");
// Do this
gPlayerList[playerid][i][E_desc][0] = '\0';
You for got to clean up playerdraws in OnGameModeExit() / OnFilterScriptExit()
Player textdraws must be cleaned up when player disconnects.

R3 - 8th April, 2015 Please download the latest version.


Re: Dialogs Include (new dialog functions and DIALOG_STYLE_PREVMODEL) - Excel™ - 08.04.2015

Nice job buddy. I will use it!

When will this come out:



Re: Dialogs Include (new dialog functions and DIALOG_STYLE_PREVMODEL) - Gammix - 10.04.2015

Quote:
Originally Posted by ******
View Post
They should! Currently most of those will crash as they don't even check if the player is VALID, let alone connected:

pawn Code:
GetPlayerDialogID(-1); // Crash
Dialog_TotalPages(INVALID_PLAYER_ID); // Crash
// etc...
Why would anyone even perform that function on id -1.
AND, i personally think people have habit to perform such checks like IsPlayerConnected, or maybe a range check... So i didn't bothered to add that! Though now it is done in R4.

All the functions having Dialog_ as prefix are internal functions, i don't recommend people to use them!

Quote:
Originally Posted by ******
View Post
pawn Code:
stock Dialog_TotalPages(playerid)
{
        if((gPlayerTotalModels[playerid] >= MODELS_PER_PAGE) && (gPlayerTotalModels[playerid] % MODELS_PER_PAGE) == 0)
        {
                return (gPlayerTotalModels[playerid] / MODELS_PER_PAGE);
        }
        else return (gPlayerTotalModels[playerid] / MODELS_PER_PAGE) + 1;
}
That is much more simply expressed as:

pawn Code:
stock Dialog_TotalPages(playerid)
{
        return ceildiv(gPlayerTotalModels[playerid], MODELS_PER_PAGE);
}
ceildiv

Obviously with adequate connection checks.
Thats nice & short.

Quote:
Originally Posted by ******
View Post
Why are "Dialog_CreateGlobalTD()" and "Dialog_CreateGlobalButtonsTD()" stock and global? They shouldn't be stock because they are always used (they aren't API functions), and they shouldn't be global because they are purely internal (again, they aren't API functions).
Ok, that can be an alternative.
Why they shouldn't be global, i don't think so you need player textdraws for just a static display.

Quote:
Originally Posted by ******
View Post
Also, there are much better ways to hook the init functions now - both in terms of being script type agnostic, and using more modern ALS methods (applicable for your other callbacks too).
I don't know those new methods, And their benifits?


R4 - 10th April, 2015 Please download the latest version.


Re: Dialogs Include (new dialog functions and DIALOG_STYLE_PREVMODEL) - $$inSane - 15.04.2015

Pretty epic, nice one!


Re: Dialogs Include (new dialog functions and DIALOG_STYLE_PREVMODEL) - Q_Lite - 16.04.2015

Thats awesome, I will surely use this for making few selectable stuff.


Re: Dialogs Include (new dialog functions and DIALOG_STYLE_PREVMODEL) - Qu3esL - 17.04.2015

Very nice textdraw work there bro!
You surely get some rep+!

BTW, what happens when you run the Prevmodel dialog from a gamemode as well as from a filterscript?


Re: Dialogs Include (new dialog functions and DIALOG_STYLE_PREVMODEL) - Gammix - 18.04.2015

Quote:
Originally Posted by Qu3esL
View Post
Very nice textdraw work there bro!
You surely get some rep+!

BTW, what happens when you run the Prevmodel dialog from a gamemode as well as from a filterscript?
I have never tried that but maybe that can cause bugs. Cause the textdraws will be made in both the scripts. I think i must create textdraws only in gamemode(init). So it will become necessary to use the include in gamemode and for compatibility between other scripts, you have to include it in them too.


Re : Dialogs Include (new dialog functions and DIALOG_STYLE_PREVMODEL) - ArchB42 - 19.04.2015

Hello,

I've got a bug. I tried with 0.3z-R2 and 0.3.7-RC3 (client & server) and this happened.



I used the example script you gave in the initial post with the lastest include release you made.


Re: Re : Dialogs Include (new dialog functions and DIALOG_STYLE_PREVMODEL) - Gammix - 19.04.2015

Quote:
Originally Posted by ArchB42
View Post
Hello,

I've got a bug. I tried with 0.3z-R2 and 0.3.7-RC3 (client & server) and this happened.



I used the example script you gave in the initial post with the lastest include release you made.
Show your code and do you use player textdraws in your scripts?


Re: Dialogs Include (new dialog functions and DIALOG_STYLE_PREVMODEL) - Cassy_ - 20.04.2015

Its awesome.

Its working fine for me!


Re: Dialogs Include (new dialog functions and DIALOG_STYLE_PREVMODEL) - eXtaz36 - 20.04.2015

Можно код данного диалога?



Re : Re: Re : Dialogs Include (new dialog functions and DIALOG_STYLE_PREVMODEL) - ArchB42 - 20.04.2015

Quote:
Originally Posted by Gammix
View Post
Show your code and do you use player textdraws in your scripts?
Quote:
Originally Posted by ArchB42
View Post
I used the example script you gave in the initial post with the lastest include release you made.
I changed nothing in the script, just compiled it with SA-MP 0.3.7 RC3, wasn't working, then with SA-MP 0.3z RC2, wasn't working either. Seems like a texture problem since the blocks you see are the skins with a huge zoom on them.

Maybe I've done something wrong in the process, but as I said, I copy-pasted the example script given in the first post (and used it in a filterscript). I called the filterscript after the server was already launched, I'll try to call it during the launch process to see what happens.


Re: Re : Re: Re : Dialogs Include (new dialog functions and DIALOG_STYLE_PREVMODEL) - Gammix - 20.04.2015

Quote:
Originally Posted by ArchB42
View Post
I changed nothing in the script, just compiled it with SA-MP 0.3.7 RC3, wasn't working, then with SA-MP 0.3z RC2, wasn't working either. Seems like a texture problem since the blocks you see are the skins with a huge zoom on them.

Maybe I've done something wrong in the process, but as I said, I copy-pasted the example script given in the first post (and used it in a filterscript). I called the filterscript after the server was already launched, I'll try to call it during the launch process to see what happens.
Strange, it worked fine for me and other users. If you are using this in filterscript, make sure you have defined this:
pawn Code:
#define FILTERSCRIPT
at the top of the script.

I'll ask you again, do you use Prevmodel Textdraws in your gamemode or other filterscripts?

And about the model sizes, its default zoom is 0.0, thats why they are appearing like that. Try out
pawn Code:
SetupPrevModelDialog(Float:mx, Float:my, Float:mz, Float:mzoom = 1.0, mbgcolor = 0x4A5A6BFF, hovercolor = 0x8B0000FF, selectcolor = 0x8B0000FF);
.

set the mzoom param to 1.0 or whatever you suits.



EDIT: There will be a new update for the include where the base of dialogs will completely support Player textdraws rather than global textdraws. This will make the system compatible in multi platforms and more efficient.