CLEO Help dialog select

CLEO related
Status
Not open for further replies.

davidel

Well-known member
Joined
Jan 17, 2020
Messages
207
Reaction score
7
Location
Germania
Code:
{$CLEO .cs}

0000:

repeat
wait 0
until 0AFA:

0B34: samp register_client_command "dt" to_label @cmd_mycmd
0B34: samp register_client_command "cl" to_label @cmd_mycmd2
6@ = FALSE

while true
    wait 0
    if 6@ == TRUE
    then
    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 "Jobs"
        then
            0AB1: @get_list_item 1 "Trucker" return_to 1@
            0B49: samp set_current_dialog_list_item 1@
            0B47: samp close_current_dialog_with_button 1      
        end
        free 0@
        6@ = FALSE
        end
    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@

:cmd_mycmd
0B12: 6@ = 6@ XOR 1
SAMP.CmdRet()

:cmd_mycmd2
004E: end_thread
SAMP.CmdRet()

it crashes me when i activate.. what is the problem?

if i am using this one below, it will get only first column of the dialog which is the name. e.g. Ocean Docks, East Beach.. how can i get the distance?
Code:
//get number of dialog elements
0B54: samp 1@ = listbox_items_count

//substract one from total cout
1@ -= 1 //last item is actually the null terminator

chatmsg "num of elements %d" -1 1@

for 0@ = 0 to 1@
alloc 2@ = 256
0B5B: samp get_listbox_item 0@ text_to 2@    
chatmsg "element %d - text: %s" -1 0@ 2@
free 2@
end

this is the dialog
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,112
Solutions
5
Reaction score
878
Location
Lithuania
Wrong call structure...
PHP:
0AB1: @get_list_item 1 "Trucker" return_to 1@

Correction
PHP:
Alloc 30@ 260
Format 30@ "Trucker"
0AB1: @get_list_item 1 30@ return_to 1@
 

davidel

Well-known member
Joined
Jan 17, 2020
Messages
207
Reaction score
7
Location
Germania
Wrong call structure...
PHP:
0AB1: @get_list_item 1 "Trucker" return_to 1@

Correction
PHP:
Alloc 30@ 260
Format 30@ "Trucker"
0AB1: @get_list_item 1 30@ return_to 1@
It's selecting first item and trucker is 6th
I think might be something wrong at :get_list_item but i dont know what..
 

davidel

Well-known member
Joined
Jan 17, 2020
Messages
207
Reaction score
7
Location
Germania
So you made something wrong..
this wasn't working correctly idk why
0B49: samp set_current_dialog_list_item 1@

But i replaced it with your version without SAMPFUNCS and now it's working

had to thanks @Hidend because he helped me

Code:
{$CLEO .cs}

0000:

repeat
wait 0
until 0AFA:

0B34: samp register_client_command "dt" to_label @cmd_mycmd
0B34: samp register_client_command "cl" to_label @cmd_mycmd2
6@ = FALSE

while true
    wait 0
    if 6@ == TRUE
    then
    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 "Jobs"
        then
           Alloc 30@ 260
            Format 30@ "Trucker"
            0AB1: @get_list_item 1 30@ return_to 1@
            0AB1: @Set_current_dialog_list_item 1 ItemNumber 1@


            0B47: samp close_current_dialog_with_button 1     
        end
        free 0@
        6@ = FALSE
        end
    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@
alloc 3@ = 256
    0B5B: samp get_listbox_item 10@ text_to 3@
    if
        0C29: $NOT_USED = stristr string1 3@ string2 0@
    then
        0006: 2@ = 10@
        break
    end

    free 3@
end
0AB2: ret 1 2@

:Set_current_dialog_list_item
{
    0.3.7 - R1
    0AB1: @Set_current_dialog_list_item 0 item 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

:cmd_mycmd
0B12: 6@ = 6@ XOR 1
SAMP.CmdRet()

:cmd_mycmd2
004E: end_thread
SAMP.CmdRet()
 
Status
Not open for further replies.
Top