CLEO Help deleting digits

CLEO related
Status
Not open for further replies.

davidel

Well-known member
Joined
Jan 17, 2020
Messages
207
Reaction score
7
Location
Germania
hello guys,
i am using call @GetDigitsToPrint param_count 2 text 1@ memory_to_store_digits_as_text 2@
2@
has up to 6 digits (100000 for example)
how can i delete first 2,3 or 4 digits for example?

Code:
while true
    wait 0
    0AC8: 1@ = allocate_memory_size 260
0AC8: 2@ = allocate_memory_size 260
        if 0C5D: samp textdraw 20 is_exists
        then
        
            0C5A: samp textdraw 20 get_string_to 1@
            call @GetDigitsToPrint param_count 2 text 1@ memory_to_store_digits_as_text 2@
 

davidel

Well-known member
Joined
Jan 17, 2020
Messages
207
Reaction score
7
Location
Germania
Code:
alloc 2@ 32
format 2@ "100420"
2@ += 3
alloc 1@ 32
format 1@ "%s" 2@
chatmsg 1@ -1
2@ -= 3
free 1@
free 2@
thank you!
do you have any idea why if i have something in loop it will cause the game crash? now i have 60 fps, after 50 minutes 50fps until it reaches 5 fps and then the game will crash
Code:
{$CLEO}
{$INCLUDE SF}
{$USE CLEO}
{$USE bitwise}
{$USE ini}
{$USE file}

THREAD "Distance"


0B34: "del" @cmd2



while true
    wait 0
    0AC8: 1@ = allocate_memory_size 260
0AC8: 2@ = allocate_memory_size 260
        if 0C5D: samp textdraw 20 is_exists
        then
        
            0C5A: samp textdraw 20 get_string_to 1@
            call @GetDigitsToPrint param_count 2 text 1@ memory_to_store_digits_as_text 2@
            0A8E: 4@ = 2@ + 1
            if 0AD4: 33@ = scan_string 4@ format "%d" 3@ //get the result
            then
                IF OR
                3@ == 000
                3@ == 001
                3@ == 002
                3@ == 003
                3@ == 004
                then
                wait 10000
                0C8F: samp process_chat_input "/onof"
                wait 3000
                0C8F: samp process_chat_input "/exx"

            end
            end
            0AC9: free_allocated_memory 1@
            0AC9: free_allocated_memory 2@
        end
end


:GetDigitsToPrint
{
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

:cmd1
0B12: 0@ = 0@ XOR 1
  SAMP.CmdRet()
 
:cmd2
004E: end_thread
SAMP.CmdRet()
 

JaggerJam

Active member
Joined
Sep 14, 2017
Messages
98
Solutions
1
Reaction score
21
thank you!
do you have any idea why if i have something in loop it will cause the game crash? now i have 60 fps, after 50 minutes 50fps until it reaches 5 fps and then the game will crash
Code:
{$CLEO}
{$INCLUDE SF}
{$USE CLEO}
{$USE bitwise}
{$USE ini}
{$USE file}

THREAD "Distance"


0B34: "del" @cmd2



while true
    wait 0
    0AC8: 1@ = allocate_memory_size 260
0AC8: 2@ = allocate_memory_size 260
        if 0C5D: samp textdraw 20 is_exists
        then
       
            0C5A: samp textdraw 20 get_string_to 1@
            call @GetDigitsToPrint param_count 2 text 1@ memory_to_store_digits_as_text 2@
            0A8E: 4@ = 2@ + 1
            if 0AD4: 33@ = scan_string 4@ format "%d" 3@ //get the result
            then
                IF OR
                3@ == 000
                3@ == 001
                3@ == 002
                3@ == 003
                3@ == 004
                then
                wait 10000
                0C8F: samp process_chat_input "/onof"
                wait 3000
                0C8F: samp process_chat_input "/exx"

            end
            end
            0AC9: free_allocated_memory 1@
            0AC9: free_allocated_memory 2@
        end
end


:GetDigitsToPrint
{
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

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

:cmd2
004E: end_thread
SAMP.CmdRet()

Bcs u are loop opcode 0AC8: without clearing memory when u exist from loop. Using 0C11: is easier to operate with allocated memory, using this u are reseting all memory with 0 and then u don't need to free the memory.
Code:
{$CLEO}
{$INCLUDE SF}
{$USE CLEO}
{$USE bitwise}
{$USE ini}
{$USE file}

THREAD "Distance"


0B34: "del" @cmd2

 0AC8: 1@ = allocate_memory_size 260
0AC8: 2@ = allocate_memory_size 260

while true
    wait 0

        if 0C5D: samp textdraw 20 is_exists
        then
            0C11: memset destination 1@ value 0 size 260
            0C11: memset destination 2@ value 0 size 260
            0C5A: samp textdraw 20 get_string_to 1@
            call @GetDigitsToPrint param_count 2 text 1@ memory_to_store_digits_as_text 2@
            0A8E: 4@ = 2@ + 1
            if 0AD4: 33@ = scan_string 4@ format "%d" 3@ //get the result
            then
                IF OR
                3@ == 000
                3@ == 001
                3@ == 002
                3@ == 003
                3@ == 004
                then
                wait 10000
                0C8F: samp process_chat_input "/onof"
                wait 3000
                0C8F: samp process_chat_input "/exx"

            end
            end
        end
end


:GetDigitsToPrint
{
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

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

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