CLEO Help Auto select option from dialog

CLEO related
Status
Not open for further replies.

Costi7

Member
Joined
May 18, 2020
Messages
6
Reaction score
0
Location
Romania
How to automatically select an option from a dialog list?

I dont know really much about cleo scripting, i thought that it should be like this, but the game just crashes when it starts.

if
0B4C: samp is_dialog_active
then
0B49: samp set_current_dialog_list_item 2
0B47: samp close_current_dialog_with_button 1
end

Also, i would want the mod to check if there's an opened dialog after pressing a key.
 

real_fl1k

Active member
Joined
Apr 23, 2020
Messages
72
Reaction score
8
Location
Belgrade
Code:
             if
                    0B4C:  samp is_dialog_active -1
                    then                    
                        0B49: samp set_current_dialog_list_item 0 
                        0B47: samp close_current_dialog_with_button 0
                    end
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,104
Solutions
5
Reaction score
882
Location
Lithuania

PHP:
{$CLEO .cs}

0000: NOP

repeat
wait 0
until 0AFA:

while true
wait 0

if
0B4C:  samp is_dialog_active -1
then
    0AC8: 0@ = allocate_memory_size 260
    0BD8: samp get_dialog_caption 0@
    0AC8: 1@ = allocate_memory_size 260
    0AB1: @DeleteColorCodeFromText 4 text 0@ FirstCharacter 123 SecondCharacter 125  memory_to_store_characters_as_text 1@
    if
    0C29: $NOT_USED = stristr string1 1@ string2 "Mission Locations" // dialog title / caption
    then
        0AB1: @Set_current_dialog_list_item 0 itemID 2 // select itme
        0B47: samp close_current_dialog_with_button 1 // close dialog
    end
end


end

:DeleteColorCodeFromText
{
    0AB1: @DeleteColorCodeFromText 4 text 0@ FirstCharacter 91 SecondCharacter 93  memory_to_store_characters_as_text 1@
    In: 0@ = text , FirstCharacter , SecondCharacter
    Out: 1@ = pointer to memory where characters will be stored as text
}
5@ = FALSE // inbracket
0C17: 31@ = strlen 0@
    for 30@ = 0 to 31@
        0085: 29@ = 0@ // copy pointer
        005A: 29@ += 30@  // add offset make loop
        0A8D: 28@ = read_memory 29@ size 1 virtual_protect 1 // 28@ is the ascii number representing character
        if
        003B:   28@ == 1@  // (int)
        then
            5@ = TRUE // inbracket
        end

        if
        5@ == FALSE // inbracket
        THEN
            0A8C: write_memory 3@ size 1 value 28@ virtual_protect 1
            3@ += 1 // move to next address
        END

        if
        003B:   28@ == 2@  // (int)
        then
            5@ = FALSE // inbracket
        end
    end
0A8C: write_memory 3@ size 1 value 0 virtual_protect 1 // null-termination
0AB2: ret 0

:Set_current_dialog_list_item
{
    0.3.7 - R1
    0AB1: @Set_current_dialog_list_item 0 itemID 5
}
0AA2: 31@ = "samp.dll"
31@ += 0x21A0B8
0A8D: 31@ = read_memory 31@ size 4 virtual_protect 0
31@ += 0x20
0A8D: 31@ = read_memory 31@ size 4 virtual_protect 0
31@ += 0x143
0A8C: write_memory 31@ size 1 value 0@ virtual_protect 0
0AB2: ret 0
 

Costi7

Member
Joined
May 18, 2020
Messages
6
Reaction score
0
Location
Romania

PHP:
{$CLEO .cs}

0000: NOP

repeat
wait 0
until 0AFA:

while true
wait 0

if
0B4C:  samp is_dialog_active -1
then
    0AC8: 0@ = allocate_memory_size 260
    0BD8: samp get_dialog_caption 0@
    0AC8: 1@ = allocate_memory_size 260
    0AB1: @DeleteColorCodeFromText 4 text 0@ FirstCharacter 123 SecondCharacter 125  memory_to_store_characters_as_text 1@
    if
    0C29: $NOT_USED = stristr string1 1@ string2 "Mission Locations" // dialog title / caption
    then
        0AB1: @Set_current_dialog_list_item 0 itemID 2 // select itme
        0B47: samp close_current_dialog_with_button 1 // close dialog
    end
end


end

:DeleteColorCodeFromText
{
    0AB1: @DeleteColorCodeFromText 4 text 0@ FirstCharacter 91 SecondCharacter 93  memory_to_store_characters_as_text 1@
    In: 0@ = text , FirstCharacter , SecondCharacter
    Out: 1@ = pointer to memory where characters will be stored as text
}
5@ = FALSE // inbracket
0C17: 31@ = strlen 0@
    for 30@ = 0 to 31@
        0085: 29@ = 0@ // copy pointer
        005A: 29@ += 30@  // add offset make loop
        0A8D: 28@ = read_memory 29@ size 1 virtual_protect 1 // 28@ is the ascii number representing character
        if
        003B:   28@ == 1@  // (int)
        then
            5@ = TRUE // inbracket
        end

        if
        5@ == FALSE // inbracket
        THEN
            0A8C: write_memory 3@ size 1 value 28@ virtual_protect 1
            3@ += 1 // move to next address
        END

        if
        003B:   28@ == 2@  // (int)
        then
            5@ = FALSE // inbracket
        end
    end
0A8C: write_memory 3@ size 1 value 0 virtual_protect 1 // null-termination
0AB2: ret 0

:Set_current_dialog_list_item
{
    0.3.7 - R1
    0AB1: @Set_current_dialog_list_item 0 itemID 5
}
0AA2: 31@ = "samp.dll"
31@ += 0x21A0B8
0A8D: 31@ = read_memory 31@ size 4 virtual_protect 0
31@ += 0x20
0A8D: 31@ = read_memory 31@ size 4 virtual_protect 0
31@ += 0x143
0A8C: write_memory 31@ size 1 value 0@ virtual_protect 0
0AB2: ret 0
the game crashes instantly when i join the server :/
 

Attachments

  • gta_sa_YfaPrhxNHC.png
    gta_sa_YfaPrhxNHC.png
    29.5 KB · Views: 12

ItsRobinson

Active member
Joined
Nov 16, 2017
Messages
105
Reaction score
20
PHP:
while true
    wait 0
    if
        0B4C:  samp is_dialog_active -1
    then
        0AC8: 0@ = allocate_memory_size 256
        0BD8: samp get_dialog_caption 0@
        if
            0C29: $NOT_USED = stristr string1 0@ string2 "Mission Locations"
        then
            0AB1: @get_list_item 1 "Dillimore" return_to 1@
            0B49: samp set_current_dialog_list_item 1@
            0B47: samp close_current_dialog_with_button 1        
        end
        free 0@
    end
end

:get_list_item
{
Example:
0AB1: @get_list_item 1 0@ return_to 1@
0@ = List item text
1@ = returned ID of the list item
}
0B54: samp 1@ = listbox_items_count
1@ -= 1
2@ = 0
for 10@ = 0 to 1@
    0B5B: samp get_listbox_item 10@ text_to 3@
    if
        0C29: $NOT_USED = stristr string1 3@ string2 0@
    then  
        0006: 2@ = 10@
        break
    end
end
0AB2: ret 1 2@

Try this, not tested it, should work though, you can change this line:
PHP:
0AB1: @get_list_item 1 "Dillimore" return_to 1@
if you want to use a different mission
 
Status
Not open for further replies.
Top