CLEO Help Sanny Builder - text setting directly from the game! In file .ini

CLEO related

MTM

Member
Joined
Nov 6, 2018
Messages
8
Reaction score
0
Hello, I have a problem with the text setting dialogs for the /au1 command, I can set up to 100 characters maximum in one, and if I set more than 100 characters, the game crashes and I don't understand why, I I tried to increase its memory, to change the variables and in vain, still 100 characters is the maximum. Please help me!

The code for the text setting dialogs directly via the /au1 command in the game:

if 0B3C: samp is_dialog_responded id 7000 button $BUTTON list_item $LIST_ITEM input_text 0
then
if $BUTTON == 1
then
0AC8: $Competition_Automobiles_Set = allocate_memory_size 1024

if $LIST_ITEM == 0
then
0BFC: set_global_var "SELECTEDROW" = 1
0AD3: $Competition_Automobiles_Set = "{00FFFF}Enter below the text you want to set to Answer_au1%c%cThe text cannot exceed 109 characters" 0xA 0xA
0B3B: samp show_dialog id 7001 caption "{C2A2DA}(ES Helper) {00FFFF}Set to Answer_au1" text $Competition_Automobiles_Set button_1 "Set" button_2 "Close" style 1
end

if $LIST_ITEM == 1
then
0BFC: set_global_var "SELECTEDROW" = 2
0AD3: $Competition_Automobiles_Set = "{00FFFF}Enter below the text you want to set to Question_au1%c" 0xA
0AD3: $Competition_Automobiles_Set = "%sThe text must have a minimum of 5 and a maximum of 109 characters" $Competition_Automobiles_Set
0B3B: samp show_dialog id 7001 caption "{C2A2DA}ES Helper {FFFFFF}Set to Question_au1" text $Competition_Automobiles_Set button_1 "Set" button_2 "Close" style 1
end

else 0B47: samp close_current_dialog_with_button 0
end
end

if 0B3C: samp is_dialog_responded id 7001 button $BUTTON list_item $LIST_ITEM input_text 0
then
if $BUTTON == 1
then
0AC8: $Competition_Automobiles_Set = allocate_memory_size 1024
0C11: memset destination $Competition_Automobiles_Set value 0 size 1024
0B4A: samp $Competition_Automobiles_Set = get_current_dialog_editbox_text
0C17: 1@ = strlen $Competition_Automobiles_Set
0BFD: 2@ = get_global_var "SELECTEDROW"
0A8D: 3@ = read_memory $Competition_Automobiles_Set size 1 virtual_protect 1

if and
1@ >= 5
1@ <= 109
then
if 2@ == 1
then
0AF5: write_string $Competition_Automobiles_Set to_ini_file "CLEO\ESHelp - CMD (News Reporters).ini" section "Competition-Cars" key "Answer_Au1"
chatmsg "{C2A2DA}ES Helper {FFFFFF}The text on Answer_au1 has been successfully set." -1
end
if 2@ == 2
then
0AF5: write_string $Competition_Automobiles_Set to_ini_file "CLEO\ESHelp - CMD (News Reporters).ini" section "Competition-Cars" key "Question_Au1"
chatmsg "{C2A2DA}ES Helper {FFFFFF}The text on Question_au1 has been successfully set." -1
end
else
if 2@ == 1
then
0AD3: $Competition_Automobiles_Set = "{FFFFFF}Enter below the text you want to set to Answer_au1%c%c" 0xA 0xA
0AD3: $Competition_Automobiles_Set = "%sThe text must have a minimum of 5 and a maximum of 109 characters" $Competition_Automobiles_Set
0B3B: samp show_dialog id 7001 caption "{FFFFFF}({C2A2DA}ES Helper{FFFFFF}) Set to Answer_au1:" text $Competition_Automobiles_Set button_1 "Set" button_2 "Close" style 1
end
if and
2@ == 2
3@ <> 45
then
0AD3: $Competition_Automobiles_Set = "{FFFFFF}Enter below the text you want to set to Question_au1%c" 0xA
0B3B: samp show_dialog id 7001 caption "{FFFFFF}({C2A2DA}ES Helper{FFFFFF}) Set to Question_au1:" text $Competition_Automobiles_Set button_1 "Set" button_2 "Close" style 1
end
end

0AC9: free_allocated_memory $Competition_Automobiles_Set
else 0B47: samp close_current_dialog_with_button 0
end
end
 

Attachments

  • ESHelp - CMD (News Reporters).cs
    27.1 KB · Views: 2
  • ESHelp - CMD (News Reporters).ini
    46 bytes · Views: 1

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
227
Location
( ͡° ͜ʖ ͡°)
So, back when I coded CLEO, I was vibin' with those opcodes like 0C17, right? But turns out, that opcode couldn't handle more than 100 characters. So, I switched gears and used a different strlen function. Oh, and about those $VARS, rookie mistake! Gotta stick with the 0@ - 31@ crew and make sure to allocate that memory like a boss. Keep it clean, keep it smooth, ya feel?

Code:
:strlen
{
    Example: 0AB1: call @strlen 1 string 1@ return: 3@
    In: 0@ - text;
    Out: 1@ - size;
}
for 1@ = 0 to 256
    0A8D: 2@ = read_memory 0@ size 1 virtual_protect 0
    if not 2@ == 0
    jf break
    0@ += 1
end
0AB2: ret 1 1@

If you dont find a solution use this:
Code:
0AB1: @CAP_STRINGS_100_CHARS 1 pointer 2@   

:CAP_STRINGS_100_CHARS
0AB1: @STRLEN 1 string_ 0@ _store 10@
IF
10@ > 99
THEN
    0@ += 99
    0AB1: @memset 3 destination 0@ value 0 size 99
END
0AB2: 0
:memset

var
0@ : integer
1@ : integer
2@ : integer
3@ : integer
end

// 0@ - destination, 1@ - value, 2@ - size
// Example: 0AB1: @memset 3 destination 0@ value 32 size 1
2@ -= 1
for 3@ = 0 to 2@
0A8C: write_memory 0@ size 1 value 1@ virtual_protect 0
0@ += 1
end
0AB2: ret 0
 
Top