CLEO Help help .ini value

CLEO related
Status
Not open for further replies.

davidel

Well-known member
Joined
Jan 17, 2020
Messages
207
Reaction score
7
Location
Germania
Code:
:money
0B35: samp 1@ = get_last_command_params
if
0AD4: 1@ = scan_string 1@ format "%d" 2@
then
IF 2@ < 100000
then
chatmsg "Value must be above 100000" -1
else
0AF8: "money value: %d" -1 2@
0AF1: write_int 2@ to_ini_file "cleo\bla.ini" section "blabla" key "money"
end
end
0b43:

Code:
while true
wait 0

                    IF 0B4C: samp is_dialog_active -1
                    then
                        0AC8: 1@ = allocate_memory_size 260
                        0BD8: samp get_dialog_caption 1@ /// Get dialot caption
                        0AF0: 3@ = get_int_from_ini_file "cleo\bla.ini" section "blabla" key "money"
                        IF 0C29: $NOT_USED = stristr string1 1@ string2 "Enter amount"
                        THEN
                            repeat
                            wait 0
                            until 0B4C: samp is_dialog_active -1
                            IF 0b4c: samp is_dialog_active -1
                            then
                            wait 200
                                alloc 4@ 240
                                format 4@ "%d" 3@
                                0AF8: "editbox %d" -1 4@
                                0B4B: samp set_current_dialog_editbox_text 4@
                                wait 100
                                0AB1: @CloseCurrentDialogWithButton 1 Button 1
                                free 1@
                            end
                        end
                    end
end

instead of getting the value with 0AF0: 3@ = get_int_from_ini_file "cleo\bla.ini" section "blabla" key "money" how can i put in the editbox the value what i set?
 

ajom

Well-known member
Joined
Apr 14, 2020
Messages
389
Solutions
2
Reaction score
270
Location
Pluto
Code:
...
0AB1: @CloseCurrentDialogWithButton 1 Button 1
...
Use opcode 0B47 instead of that snippet if you are using SAMPFUNCS already:
PHP:
0B47: samp close_current_dialog_with_button 1


how can i put in the editbox the value what i set?
Opcode 0B4B will automatically fill up the editbox. Take note that everytime this opcode executes, the editbox's text will be replaced by it:
Code:
...
0B4B: samp set_current_dialog_editbox_text 4@
...
If the script didn't pressed the button, try using different button ID:
PHP:
0B47: samp close_current_dialog_with_button 0 // keep changing it until the button works
 

davidel

Well-known member
Joined
Jan 17, 2020
Messages
207
Reaction score
7
Location
Germania
I know what are you saying. Opcode 0B47 sometimes makes fun of me and won't work. I will try to change the value as you said to see if it works. :D
And about editbox, I know how to fill it up using the opcode. But at the moment, the editbox will be filled up with the value from .ini file. I want to take it directly from script without involving .ini files if you you what i am saying.
 

ajom

Well-known member
Joined
Apr 14, 2020
Messages
389
Solutions
2
Reaction score
270
Location
Pluto
1. Initialize a variable that will hold the text you want to be automatically inputted through the textbox:
PHP:
const
    BUFFER = 31@ // special variable, do not use on operations other than storing string.
end
alloc BUFFER 240 // A permanent memory region, do not free it. This will be used always
2. Let the CMD hook store your typed string to the BUFFER:
PHP:
:money
    0B35: samp 0@ = get_last_command_params
    IF 0@ > 0 // NOT NULL pointer
    Then
        0C13: strcpy destination BUFFER source 0@
        Chatmsg "Saved String: %s" -1 BUFFER
    End
Cmd.Ret
3. No need to borrow(alloc and then free) memory region, just recycle the BUFFER Variable by feeding it to Opcode 0B4B:
PHP:
IF 0b4c: samp is_dialog_active -1
then
    0B4B: samp set_current_dialog_editbox_text BUFFER
    0B47: samp close_current_dialog_with_button 1
end
 

davidel

Well-known member
Joined
Jan 17, 2020
Messages
207
Reaction score
7
Location
Germania
1. Initialize a variable that will hold the text you want to be automatically inputted through the textbox:
PHP:
const
    BUFFER = 31@ // special variable, do not use on operations other than storing string.
end
alloc BUFFER 240 // A permanent memory region, do not free it. This will be used always
2. Let the CMD hook store your typed string to the BUFFER:
PHP:
:money
    0B35: samp 0@ = get_last_command_params
    IF 0@ > 0 // NOT NULL pointer
    Then
        0C13: strcpy destination BUFFER source 0@
        Chatmsg "Saved String: %s" -1 BUFFER
    End
Cmd.Ret
3. No need to borrow(alloc and then free) memory region, just recycle the BUFFER Variable by feeding it to Opcode 0B4B:
PHP:
IF 0b4c: samp is_dialog_active -1
then
    0B4B: samp set_current_dialog_editbox_text BUFFER
    0B47: samp close_current_dialog_with_button 1
end
thank you! it's working the way i wanted it to
 
Status
Not open for further replies.
Top