CLEO Help Need some help with dialog input script

CLEO related
Status
Not open for further replies.

Cape

Member
Joined
Aug 23, 2018
Messages
7
Reaction score
0
Hey, so for the past few hours I've been having some trouble getting this script to work, could use some help with it.

Here's the code:
Code:
{$CLEO .cs}
0000:

while not SAMP.Available() 
    wait 50
end

while true
    wait 0
    if
        0B4C: samp is_dialog_active 250
    then
        alloc 0@ 4096
        0BD7: samp get_dialog_text 0@
        if
            0AD4: $NOT_NEEDED = scan_string 0@ format "Enter %d" 5@
        then
            alloc 2@ 8
            format 2@ "%d" 5@
            0B4B: samp set_current_dialog_editbox_text 2@
            wait 2000
            free 2@
            free 5@
            0B47: samp close_current_dialog_with_button 0
        end
    end
end

The dialog ID is 250, here's a picture of the dialog:
F0gnWvV.jpg


The problem I'm having is that it doesn't do anything when the dialog appears.

Thanks in advance for any help you could give me!  :)
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,488
Reaction score
231
Location
( ͡° ͜ʖ ͡°)
I think the proble is the scan string opcode..

You should debug it.

alloc 0@ 4096
0BD7: samp get_dialog_text 0@
0AD1: show_formatted_text_highpriority "String: %s" time 3000 0@

like that and see if u even get the correct string you want.
If the string is correct then try using a different method than scanstring.
 

Cape

Member
Joined
Aug 23, 2018
Messages
7
Reaction score
0
Opcode.eXe said:
I think the proble is the scan string opcode..

You should debug it.

alloc 0@ 4096
0BD7: samp get_dialog_text 0@
0AD1: show_formatted_text_highpriority "String: %s" time 3000 0@

like that and see if u even get the correct string you want.
If the string is correct then try using a different method than scanstring.

I used strstr "Enter", then used scanstring on it and now it's working, thank you!
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
PHP:
{$CLEO}
0000:

wait 10000

while true
wait 0

if
0B4C:  samp is_dialog_active -1
then
    0B4E: samp 10@ = get_current_dialog_id
    if
    10@ == 250
    then
        0AC8: 0@ = allocate_memory_size 512
        0BD7: samp get_dialog_text 0@
        0AC8: 1@ = allocate_memory_size 260
        0AB1: call_scm_func @get_digits_to_print param_count 2 text 0@ memory_to_store_digits_as_text 1@
        0B4B: samp set_current_dialog_editbox_text 1@
    end
end

end

:get_digits_to_print
{
    0@ = text
    1@ = pointer to memory where digits will be stored as text
}
0C17: 31@ = strlen 0@
    for 30@ = 0 to 31@    
        0085: 29@ = 0@ // copy pointer
        005A: 29@ += 30@  // add offset (as the loop progresses it becomes pointers to first-last character)
        0A8D: 28@ = read_memory 29@ size 1 virtual_protect 1 // 28@ is the ascii number representing character
        if and
        28@ >= 0x30 // '0' 
        28@ <= 0x39 // '9' 
        then
        0A8C: write_memory 1@ size 1 value 28@ virtual_protect 1
        1@ += 1 // move to next address
        end
    end
0A8C: write_memory 1@ size 1 value 0 virtual_protect 1 // null-termination   
0AB2: ret 0
 
Status
Not open for further replies.
Top