CLEO Help Getting text from a listitem

CLEO related
Status
Not open for further replies.

habinabi

Active member
Joined
Nov 10, 2019
Messages
51
Reaction score
2
Location
Czech Republic
Hi, I would like to ask if you know anyone how to get the listit text of item 27 in the dialog which has id 1453 and style 4 and the caption "missions" dialog. I need the data to get to me all the time so that I don't have to have the dialogue open or have to confirm it, I just need it to get it all the time.

I use 0.3.7 - R1
 
Last edited:

[RP]Foolish

Active member
Joined
Mar 18, 2020
Messages
68
Reaction score
36
Location
sea
@Parazitas is a man ahead of time
PHP:
:GetCurrentDialogListboxItemText
{
    0.3.7 - R1
    0AB1: @GetCurrentDialogListboxItemText 1 ListItem 9 _Returned: FirstColumnText 6@ SecondColumnText 7@ ThirdColumnText 8@
}
IF 0AA2: 31@ = "samp.dll"
THEN
    0A8E: 30@ = 31@ + 0x21A0B8 // DIALOG_POINTER_OFFSET
    0A8D: 30@ = readMem 30@ sz 4 vp 0
    0A8E: 29@ = 30@ + 0x28 // DIALOG_OPEN_OFFSET
    0A8D: 29@ = readMem 29@ sz 4 vp 0
    IF 29@ == TRUE // DIALOG OPEN
    THEN
        0A8E: 27@ = 30@ + 0x20 // SAMP_DIALOG_PTR2_OFFSET       
        0A8D: 27@ = readMem 27@ sz 4 vp 0
     
        0A8E: 22@ = 27@ + 0x150 // SAMP_DIALOG_LINECOUNT_OFFSET       
        0A8D: 22@ = readMem 22@ sz 4 vp 0
        22@ -= 1 // LAST ITEM IS ACTUALLY THEN NULL TERMINATOR
     
        IF 001D:   0@ > 22@  // (int)
        THEN 0085: 0@ = 22@ // (int)
        END
     
        IF AND
        NOT 0@ < 0
        801D:   0@ > 22@  // (int)
        THEN
            0A8E: 26@ = 27@ + 0x14C // SAMP_DIALOG_LINES_OFFSET
            0A8D: 26@ = readMem 26@ sz 4 vp 0
            0@ *= 4
            005A: 26@ += 0@  // (int)
            0A8D: 26@ = readMem 26@ sz 4 vp 0
         
            0A8E: 28@ = 30@ + 0x2C // DIALOG_TYPE_OFFSET
            0A8D: 28@ = readMem 28@ sz 4 vp 0
         
            IF 28@ == 2 // DIALOG_STYLE_LIST
            THEN
                0A8E: 25@ = 26@ + 0x0 // SAMP_DIALOG_FIRST_COLUMN_TEXT_OFFSET
                0A8D: 21@ = readMem 25@ sz 1 vp 0
                IF NOT 21@ > 0
                THEN 25@ = 0
                END
                0AB2: 1 25@
            END
         
            IF 28@ == 4 // DIALOG_STYLE_TABLIST
            THEN
                0A8E: 25@ = 26@ + 0x0 // SAMP_DIALOG_FIRST_COLUMN_TEXT_OFFSET
                0A8E: 24@ = 26@ + 0x101 // SAMP_DIALOG_SECOND_COLUMN_TEXT_OFFSET
                0A8D: 21@ = readMem 25@ sz 1 vp 0
                IF NOT 21@ > 0
                THEN 25@ = 0
                END
                0A8D: 20@ = readMem 24@ sz 1 vp 0
                IF NOT 20@ > 0
                THEN 24@ = 0
                END
                0AB2: 2 25@ 24@
            END
         
            IF 28@ == 5 // DIALOG_STYLE_TABLIST_HEADERS
            THEN
                0A8E: 25@ = 26@ + 0x0 // SAMP_DIALOG_FIRST_COLUMN_TEXT_OFFSET
                0A8E: 24@ = 26@ + 0x101 // SAMP_DIALOG_SECOND_COLUMN_TEXT_OFFSET
                0A8E: 23@ = 26@ + 0x182 // SAMP_DIALOG_THIRD_COLUMN_TEXT_OFFSET
                0A8D: 21@ = readMem 25@ sz 1 vp 0
                IF NOT 21@ > 0
                THEN 25@ = 0
                END
                0A8D: 20@ = readMem 24@ sz 1 vp 0
                IF NOT 20@ > 0
                THEN 24@ = 0
                END
                0A8D: 19@ = readMem 23@ sz 1 vp 0
                IF NOT 19@ > 0
                THEN 23@ = 0
                END
                0AB2: 3 25@ 24@ 23@
            END
        END
    END   
END
0AB2: 3 0 0 0

There are good snippets here, I recommend checking
 

habinabi

Active member
Joined
Nov 10, 2019
Messages
51
Reaction score
2
Location
Czech Republic
thank you, but where do I specify the dialog id, style and caption? furthermore, if I understand it, it works if I have an open dialog, I need to get data from the specified dialog even though the dialog is not open and even though I play normally.
 

[RP]Foolish

Active member
Joined
Mar 18, 2020
Messages
68
Reaction score
36
Location
sea
The values remain stored in memory even after closing the dialog, but are replaced when another dialog is opened, because SAMP does not support multiple dialogs.

So, you don't need to get the id in client-side, but if you still want to, SAMPFUNCS provides some opcodes for that:

0B4E: samp 1@ = get_current_dialog_id
0BD8: samp get_dialog_caption 0@


GetCurrentDialogListboxItemText works for any dialog list, you don't need to provide the style, but if you really want to, you can easily add one 'if' inside the snippet...

About the dialog opened checker: you just need to remove (or comment) it

PHP:
:GetCurrentDialogListboxItemText
{
    0.3.7 - R1
    0AB1: @GetCurrentDialogListboxItemText 1 ListItem 9 _Returned: FirstColumnText 6@ SecondColumnText 7@ ThirdColumnText 8@
}
IF 0AA2: 31@ = "samp.dll"
THEN
    0A8E: 30@ = 31@ + 0x21A0B8 // DIALOG_POINTER_OFFSET
    0A8D: 30@ = readMem 30@ sz 4 vp 0
    //0A8E: 29@ = 30@ + 0x28 // DIALOG_OPEN_OFFSET
    //0A8D: 29@ = readMem 29@ sz 4 vp 0
    //IF 29@ == TRUE // DIALOG OPEN
    //THEN
        0A8E: 27@ = 30@ + 0x20 // SAMP_DIALOG_PTR2_OFFSET
        0A8D: 27@ = readMem 27@ sz 4 vp 0

        0A8E: 22@ = 27@ + 0x150 // SAMP_DIALOG_LINECOUNT_OFFSET
        0A8D: 22@ = readMem 22@ sz 4 vp 0
        22@ -= 1 // LAST ITEM IS ACTUALLY THEN NULL TERMINATOR

        IF 001D:   0@ > 22@  // (int)
        THEN 0085: 0@ = 22@ // (int)
        END

        IF AND
        NOT 0@ < 0
        801D:   0@ > 22@  // (int)
        THEN
            0A8E: 26@ = 27@ + 0x14C // SAMP_DIALOG_LINES_OFFSET
            0A8D: 26@ = readMem 26@ sz 4 vp 0
            0@ *= 4
            005A: 26@ += 0@  // (int)
            0A8D: 26@ = readMem 26@ sz 4 vp 0
 
            0A8E: 28@ = 30@ + 0x2C // DIALOG_TYPE_OFFSET
            0A8D: 28@ = readMem 28@ sz 4 vp 0 //<-------- 28@ stores the style id
 
            IF 28@ == 2 // DIALOG_STYLE_LIST
            THEN
                0A8E: 25@ = 26@ + 0x0 // SAMP_DIALOG_FIRST_COLUMN_TEXT_OFFSET
                0A8D: 21@ = readMem 25@ sz 1 vp 0
                IF NOT 21@ > 0
                THEN 25@ = 0
                END
                0AB2: 1 25@
            END
 
            IF 28@ == 4 // DIALOG_STYLE_TABLIST
            THEN
                0A8E: 25@ = 26@ + 0x0 // SAMP_DIALOG_FIRST_COLUMN_TEXT_OFFSET
                0A8E: 24@ = 26@ + 0x101 // SAMP_DIALOG_SECOND_COLUMN_TEXT_OFFSET
                0A8D: 21@ = readMem 25@ sz 1 vp 0
                IF NOT 21@ > 0
                THEN 25@ = 0
                END
                0A8D: 20@ = readMem 24@ sz 1 vp 0
                IF NOT 20@ > 0
                THEN 24@ = 0
                END
                0AB2: 2 25@ 24@
            END
 
            IF 28@ == 5 // DIALOG_STYLE_TABLIST_HEADERS
            THEN
                0A8E: 25@ = 26@ + 0x0 // SAMP_DIALOG_FIRST_COLUMN_TEXT_OFFSET
                0A8E: 24@ = 26@ + 0x101 // SAMP_DIALOG_SECOND_COLUMN_TEXT_OFFSET
                0A8E: 23@ = 26@ + 0x182 // SAMP_DIALOG_THIRD_COLUMN_TEXT_OFFSET
                0A8D: 21@ = readMem 25@ sz 1 vp 0
                IF NOT 21@ > 0
                THEN 25@ = 0
                END
                0A8D: 20@ = readMem 24@ sz 1 vp 0
                IF NOT 20@ > 0
                THEN 24@ = 0
                END
                0A8D: 19@ = readMem 23@ sz 1 vp 0
                IF NOT 19@ > 0
                THEN 23@ = 0
                END
                0AB2: 3 25@ 24@ 23@
            END
        END
    //END
END
0AB2: 3 0 0 0


If u want to get the caption w/o SAMPFUNCS:
PHP:
:GetDialogCaption
{
    0.3.7 - R1
    0AB1: @GetDialogCaption 0 caption_text 0@
}
0AA2: 1@ = "samp.dll"
1@ += 0x21A0B8
0A8D: 1@ = readMem 1@ sz 4 vp 0
0A8E: 3@ = 1@ + 0x40 //DialogCaptionOffset
0AB2: ret 1 3@
 
Last edited:

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
Well you can use this one if you working without SAMPFUCNS.
https://ugbase.eu/index.php?threads/some-snippets.20983/page-3#post-130929

Fresh made snippet
PHP:
:isDialogResponded
{
    0.3.7 - R1
    0AB1: @isDialogResponded 0 _Returned: ID 0@ Type 1@ ListboxItem 2@ Button 3@ Text 4@ InputText 5@ Caption 6@ LeftButtonText 7@ RightButtonText 8@
}
IF 0AA2: 31@ = "samp.dll"
THEN
    0A8E: 30@ = 31@ + 0x21A0B8 // DIALOG_POINTER_OFFSET
    0A8D: 30@ = readMem 30@ sz 4 vp 0
    0A8E: 29@ = 30@ + 0x28 // DIALOG_OPEN_OFFSET
    0A8D: 29@ = readMem 29@ sz 4 vp 0
    IF 29@ == TRUE // DIALOG OPEN
    THEN
    
        0A8E: 28@ = 30@ + 0x30 // DIALOG_ID_OFFSET
        0A8D: 28@ = readMem 28@ sz 4 vp 0
    
        0A8E: 27@ = 30@ + 0x2C // DIALOG_TYPE_OFFSET
        0A8D: 27@ = readMem 27@ sz 4 vp 0
        IF OR
        27@ == 2 // DIALOG_STYLE_LIST
        27@ == 4 // DIALOG_STYLE_TABLIST
        27@ == 5 // DIALOG_STYLE_TABLIST_HEADERS
        THEN
            0A8E: 26@ = 30@ + 0x20 // DIALOG_WITH_LIST_OFFSET           
            0A8D: 26@ = readMem 26@ sz 4 vp 0
            0A8E: 25@ = 31@ + 0x84850 // DIALOG_GET_LIST_ITEM_OFFSET
            0AA8: call_function_method 25@ struct 26@ num_params 1 pop 0 -1 _Returned: ListboxItem 24@
        ELSE 24@ = -1
        END
    
        IF OR
        27@ == 0 // DIALOG_STYLE_MSGBOX
        27@ == 1 // DIALOG_STYLE_INPUT
        27@ == 3 // DIALOG_STYLE_PASSWORD
        THEN
            0A8E: 14@ = 30@ + 0x34 // DIALOG_TEXT_OFFSET
            0A8D: 14@ = readMem 14@ sz 4 vp 0
        ELSE 14@ = 0
        END
    
        IF OR
        27@ == 1 // DIALOG_STYLE_INPUT
        27@ == 3 // DIALOG_STYLE_PASSWORD
        THEN
            0A8E: 23@ = 30@ + 0x24 // DIALOG_EDIT_BOX_OFFSET           
            0A8D: 23@ = readMem 23@ sz 4 vp 0
            0A8E: 22@ = 31@ + 0x81030 // DIALOG_GET_EDIT_BOX_TEXT_OFFSET
            0AA8: call_function_method 22@ struct 23@ num_params 0 pop 0 _Returned: InputText 21@
        ELSE 21@ = 0
        END
    
        0A8E: 20@ = 30@ + 0x40 // DIALOG_CAPTION_OFFSET
    
        0A8E: 19@ = 30@ + 0x20 // DIALOG_FIRST_POINTER_OFFSET           
        0A8D: 19@ = readMem 19@ sz 4 vp 0
    
        0A8E: 18@ = 19@ + 0x1AD // DIALOG_LEFT_BUTTON_TEXT_OFFSET
        0A8D: 16@ = readMem 18@ sz 1 vp 0
        IF NOT 16@ > 0
        THEN 18@ = 0
        END
    
        0A8E: 10@ = 19@ + 0x20
        0A8D: 10@ = readMem 10@ sz 4 vp 0
        10@ += 0x50
        0A8D: 10@ = readMem 10@ sz 4 vp 0
        0A8E: 17@ = 10@ + 0x4D // DIALOG_RIGHT_BUTTON_TEXT_OFFSET
        0A8D: 15@ = readMem 17@ sz 1 vp 0
        IF NOT 15@ > 0
        THEN 17@ = 0
        END
    
        0A8E: 13@ = 19@ + 0x166 // DIALOG_LEFT_BUTTON_CLICKED_OFFSET
        0A8D: 13@ = readMem 13@ sz 1 vp 0
    
        0A8E: 12@ = 10@ + 0x6 // DIALOG_RIGHT_BUTTON_CLICKED_OFFSET
        0A8D: 12@ = readMem 12@ sz 1 vp 0
        IF OR
        0AB0: 27 // ESC
        12@ == 1
        THEN 11@ = 0 // RIGHT_BUTTON_WAS_CLICKED
        ELSE
            IF OR
            0AB0: 13 // ENTER
            13@ == 1
            THEN  11@ = 1 // LEFT_BUTTON_WAS_CLICKED
            ELSE 11@ = -1 // RESET_CLICKED_BUTTONS
            END
        END
    ELSE
        11@ = -1 // RESET_CLICKED_BUTTONS   
    END
END   
0AB2: 9 28@ 27@ 24@ 11@ 14@ 21@ 20@ 18@ 17@
 
Status
Not open for further replies.
Top