CLEO Help a little help with this cleo please!

CLEO related
Status
Not open for further replies.

Edward.WB

New member
Joined
Mar 3, 2023
Messages
4
Reaction score
0
{$CLEO .cs} thread 'TowCars' 0@ = 0 // Initialize toggle variable to off :TowCars_Loop wait 0 if 0@ == 1 // If toggle variable is on then 0C8F: samp process_chat_input "/towcars" // Execute the "/towcars" command wait 30000 // Wait for 30 seconds end jump @TowCars_Loop :TowCars_Cmd wait 0 if 056D: actor $PLAYER_ACTOR defined // If player is defined then 0AD2: 0@ = get_console_variable "toggle_towcars" // Get the value of the "toggle_towcars" console variable if 0@ == 0 // If the variable is currently off then 0ACD: show_text_styled "Auto Tow-Cars: ~g~ON~w~" time 1500 // Show "Auto Tow-Cars: ON" message 0A96: 0@ = 1 // Set the variable to on else 0ACD: show_text_styled "Auto Tow-Cars: ~r~OFF~w~" time 1500 // Show "Auto Tow-Cars: OFF" message 0A96: 0@ = 0 // Set the variable to off end 0AD3: set_console_variable "toggle_towcars" 0@ // Set the value of the "toggle_towcars" console variable end jump @TowCars_Cmd
please can anyone help me with this code when /att sent the /towcars command gets executed every 60 seconds please
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,103
Solutions
5
Reaction score
882
Location
Lithuania
{$CLEO .cs} thread 'TowCars' 0@ = 0 // Initialize toggle variable to off :TowCars_Loop wait 0 if 0@ == 1 // If toggle variable is on then 0C8F: samp process_chat_input "/towcars" // Execute the "/towcars" command wait 30000 // Wait for 30 seconds end jump @TowCars_Loop :TowCars_Cmd wait 0 if 056D: actor $PLAYER_ACTOR defined // If player is defined then 0AD2: 0@ = get_console_variable "toggle_towcars" // Get the value of the "toggle_towcars" console variable if 0@ == 0 // If the variable is currently off then 0ACD: show_text_styled "Auto Tow-Cars: ~g~ON~w~" time 1500 // Show "Auto Tow-Cars: ON" message 0A96: 0@ = 1 // Set the variable to on else 0ACD: show_text_styled "Auto Tow-Cars: ~r~OFF~w~" time 1500 // Show "Auto Tow-Cars: OFF" message 0A96: 0@ = 0 // Set the variable to off end 0AD3: set_console_variable "toggle_towcars" 0@ // Set the value of the "toggle_towcars" console variable end jump @TowCars_Cmd
please can anyone help me with this code when /att sent the /towcars command gets executed every 60 seconds please
Will check this later today after job.
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
227
Location
( ͡° ͜ʖ ͡°)
Code:
{$CLEO .cs}
thread 'TowCars'
0@ = 0 // Initialize toggle variable to off
0B34: samp register_client_command "TOW" to_label @TOW


WHILE TRUE
    WAIT 0
    if
    0@ == 1 // If toggle variable is on
    then
        0C8F: samp process_chat_input "/towcars" // Execute the "/towcars" command
        wait 30000 // Wait for 30 seconds
    end
END

:TOW
IF
0@ == FALSE
THEN
    0@ = TRUE
    0ACD: show_text_styled "Auto Tow-Cars: ~g~ON~w~" time 1500 // Show "Auto Tow-Cars: ON" message
ELSE
    0@ = FALSE
    0ACD: show_text_styled "Auto Tow-Cars: ~r~OFF~w~" time 1500 // Show "Auto Tow-Cars: OFF" message
END
0B43: samp cmd_ret
 

Edward.WB

New member
Joined
Mar 3, 2023
Messages
4
Reaction score
0
Code:
{$CLEO .cs}
thread 'TowCars'
0@ = 0 // Initialize toggle variable to off
0B34: samp register_client_command "TOW" to_label @TOW


WHILE TRUE
    WAIT 0
    if
    0@ == 1 // If toggle variable is on
    then
        0C8F: samp process_chat_input "/towcars" // Execute the "/towcars" command
        wait 30000 // Wait for 30 seconds
    end
END

:TOW
IF
0@ == FALSE
THEN
    0@ = TRUE
    0ACD: show_text_styled "Auto Tow-Cars: ~g~ON~w~" time 1500 // Show "Auto Tow-Cars: ON" message
ELSE
    0@ = FALSE
    0ACD: show_text_styled "Auto Tow-Cars: ~r~OFF~w~" time 1500 // Show "Auto Tow-Cars: OFF" message
END
0B43: samp cmd_ret
the code got compiled but it makes the game crash
 

Edward.WB

New member
Joined
Mar 3, 2023
Messages
4
Reaction score
0
Code:
{$CLEO .cs}

0000: NOP

REPEAT
WAIT 1000
0A8D: 31@ = readMem 0xC8D4C0 sz 4 vp 0
UNTIL 31@ == 9 // SAMP_IS_READY

0AA8: call_function_method 0x6A0050 0xC1B340 num_params 1 pop 0 'CRED098' 30@
0AA5: call 0x718600 2 pop 2 30@ "Respawning cars in: ~1~ sec"

32@ = 0 // keep timer active

while true
wait 0

if
0256:   player $PLAYER_CHAR defined
then
    0AB1: @GetLastSentTextFromChatBox 0 _Return: Command 0@ Text 1@
    0AC8: 2@ = allocate_memory_size 260
    0AD3: 2@ = format "att" // format to check command
    if
    0AB1: @IfTextContains 2 String1 0@ String2 2@ _returned: Text 3@
    then
        0A8C: write_memory 1@ size 1 value 0 virtual_protect 0 // clear last enter text
        32@ = 0   // start count only when text is detected
        30@ = true // enable draw text
    end
end

if
30@ == true
then 
    03F0: enable_text_draw 1
    0342: set_text_draw_centered 1
    03E0: draw_text_behind_textures 0
    0349: set_text_draw_font 1
    0340: set_text_draw_RGBA 255 255 255 255
    033F: set_text_draw_letter_size width 0.255 height 0.955
    081C: draw_text_outline 1 RGBA 10 10 10 255
    0AB1: @Timer 2 Seconds 66 TimingVariable 32@ _Return: TimeLeft 29@ SetTimeCountEndStatus 30@
    045A: draw_text_1number 320.0 390.0 GXT 'CRED098' numbers 29@  // Respawning cars in: ~1~ sec
end

end

:GetLastSentTextFromChatBox
{
    0.3.7 - R1
    0AB1: @GetLastSentTextFromChatBox 0 _Return: 0@
}
if 0AA2: 2@ = "samp.dll"
then             
    0A8E: 3@ = 2@ + 0x21A0E8       
    0A8D: 3@ = readMem 3@ sz 4 vp 0   
    0A8E: 4@ = 3@ + 0x14E5 // command
    0A8E: 5@ = 3@ + 0x1565 // text
end
0AB2: 2 4@ 5@

:IfTextContains
//0AB1: @IfTextContains 2 String1 0@ String2 1@
0AB1: @strlen 1 string 0@ _length 31@
0AB1: @strlen 1 string 1@ _length 30@

//initial length check (the phrase can't be longer than the main text)
if 001D:   30@ > 31@  // (int)
then
059A:  return_false
0AB2: ret 1 0
end

31@ -= 1
26@ = 0 // counter of the same chars in a row
for 29@ = 0 to 31@ // for each char of the main text  (29@ = index)
    0085: 24@ = 0@ // (int)
    005A: 24@ += 29@  // (int)
    0A8D: 28@ = read_memory 24@ size 1 virtual_protect 0

    0085: 23@ = 1@ // (int)
    005A: 23@ += 26@  // (int)
    0A8D: 27@ = read_memory 23@ size 1 virtual_protect 0

    if 003B:   28@ == 27@  // (int)
    then
    26@++
        if 002D:   26@ >= 30@  // (int)
        then
        0485:  return_true
        0062: 24@ -= 30@  // (int)
        24@ += 1
        0AB2: ret 1 24@
        end
    else
        if 26@ > 0
        then
        29@-- //check the same char again and assume it's the begining of the string but only if there was matching parts before (otherwise it would go back all the time and make infinite loop)
        end
    26@ = 0
    end       
end

059A:  return_false
0AB2: ret 1 0

:strlen
// 0AB1: @strlen 1 string 1@ _return: size 3@
for 1@ = 0 to 1024
    0A8D: 2@ = read_memory 0@ size 1 virtual_protect 0
    if not 2@ == 0
    jf break
    0@ += 1
end
0AB2: ret 1 1@

:Timer
2@ = TRUE
IF
2@ == TRUE
THEN
    0@ *= 1000
    0085: 4@ = 0@ // (int)
    0085: 3@ = 1@ // (int)
    0062: 3@ -= 4@  // (int)

    3@ /= 1000
 
    3@ *= -1
END

IF AND
2@ == TRUE
001D:   1@ > 0@  // (int)
THEN
    2@ = FALSE
END
0AB2: ret 2 3@ 2@

this code works just fine the only problem i faced he doesn't execute /towcars after the period is done
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,103
Solutions
5
Reaction score
882
Location
Lithuania
Code below was made to be used in all existing samp versions at the moment
PHP:
{$CLEO .cs}

0000:

REPEAT
IF 8256:   player $PLAYER_CHAR defined
THEN 0A93: end_custom_thread
END
WAIT 1500
UNTIL 0256:   player $PLAYER_CHAR defined 

0AC8: 28@ = allocate_memory_size 1024
0AD3: 28@ = string_format "autotow"
0AC7: 27@ = var 27@ pointer
0AC7: 26@ = var 26@ pointer
0AB1: @registerClientCommand 3 _CommandName 28@ _TogglingVar 27@ _ParamsPtrToVar 26@
27@ = 0 // default disabled
26@ = 0 // null ptr

0AA8: call_function_method 0x6A0050 0xC1B340 num_params 1 pop 0 'CRED098' 30@
0AA5: call 0x718600 2 pop 2 30@ "Respawning cars in: ~1~ sec"

32@ = 0 // keep timer active

while true
wait 0

if 0256:   player $PLAYER_CHAR defined
then
    /////////////////// Command Check
    if 27@ <> 0 // if comand " autotow " was sent
    then
        27@ = 0 // disable indication of the cmd
        if 25@ == false
        then
            25@ = true  
            30@ = true // enable draw text
            32@ = 0 // start count only when text is detected
            0AD1: "~Y~Auto towcars ~N~~G~ON" 1337
        else
            25@ = false
            30@ = false // disable draw text
            32@ = 0 // reset timer
            0AD1: "~Y~Auto towcars ~N~~G~OFF" 1337
        end
    end
    ///////////////////      
end

if 25@ == true // code enabled
then
    if 30@ == true
    then  
        03F0: enable_text_draw 1
        0342: set_text_draw_centered 1
        03E0: draw_text_behind_textures 0
        0349: set_text_draw_font 1
        0340: set_text_draw_RGBA 255 255 255 255
        033F: set_text_draw_letter_size width 0.255 height 0.955
        081C: draw_text_outline 1 RGBA 10 10 10 255
        0AB1: @Timer 2 Seconds 180 TimingVariable 32@ _Return: TimeLeft 29@ SetTimeCountEndStatus 30@
        045A: draw_text_1number 320.0 390.0 GXT 'CRED098' numbers 29@  // Respawning cars in: ~1~ sec
    end
    
    if and
    30@ == false
    29@ < 1 // time left less than 1 sec
    then
        0AC8: 22@ = allocate_memory_size 1024
        0AD3: 22@ = format "/towcars"
        0AB1: @process_chat_input 1 InputText 22@
        wait 1000 // anti spam
        32@ = 0 // reset timer
        30@ = true // enable draw text and activate timer
    end 
end


end

:get_samp_version_id
// 0AB1: @get_samp_version_id 0 _returned: ID 0@  
30@ = 0
IF 0AA2: 31@ = "samp.dll" // IF and SET
THEN
    31@ += 0x128
    0A8D: 29@ = read_memory 31@ size 4 virtual_protect 1
    IF 29@ == 0x5542F47A
    THEN // 0.3.7 R1
        30@ = 1
    END
    
    IF 29@ == 0x59C30C94
    THEN // 0.3.7 R2
        30@ = 2
    END
    
    IF 29@ == 0x5A6A3130
    THEN // 0.3.DL
        30@ = 3
    END
    31@ -= 8 // reading samp.dll + 0x120
    0A8D: 29@ = read_memory 31@ size 4 virtual_protect 1
    IF 29@ == 0x5C0B4243
    THEN // 0.3.7 R3 
        30@ = 4
    END  
    
    IF 29@ == 0x5DD606CD
    THEN // 0.3.7 R4
        30@ = 5
    END
    IF 29@ == 0x6094ACAB
    THEN // 0.3.7 R4 - v2
        30@ = 6
    END 
    IF 29@ == 0x6372C39E
    THEN // 0.3.7 R5
        30@ = 7
    END 
END
0AB2: ret 1 30@

:process_chat_input
/*
    0AC8: 0@ = allocate_memory_size 1024
    0AD3: 0@ = format "text or /command"
    0AB1: @process_chat_input 1 InputText 0@
*/
IF 0AA2: 31@ = "samp.dll"
THEN
    0AB1: @get_samp_version_id 0 _returned: ID 17@ 
    IF 17@ > 0
    THEN
        IF 17@ == 1 // 0.3.7 R1
        THEN 
            0A8E: 30@ = 31@ + 0x21A0E8            // SAMP_CHAT_INPUT_INFO_OFFSET
            0A8D: 29@ = readMem 30@ sz 4 vp 0     // pChatInput;
            0A8E: 28@ = 29@ + 0x8                // pChatInput->pEditBox;
            0A8D: 27@ = readMem 28@ sz 4 vp 0     // pEditBox;
          
            0A8E: 26@ = 31@ + 0x80F60 // CDXUTEditBox::SetText
            0A8E: 25@ = 31@ + 0x65D30 // PROCESS_INPUT
        END
        IF 17@ == 2 // 0.3.7 R2
        THEN
            0A8E: 30@ = 31@ + 0x21A0F0            // SAMP_CHAT_INPUT_INFO_OFFSET
            0A8D: 29@ = readMem 30@ sz 4 vp 0     // pChatInput;
            0A8E: 28@ = 29@ + 0x8                // pChatInput->pEditBox;
            0A8D: 27@ = readMem 28@ sz 4 vp 0     // pEditBox;
          
            0A8E: 26@ = 31@ + 0x81000 // CDXUTEditBox::SetText
            0A8E: 25@ = 31@ + 0x65E00 // PROCESS_INPUT
        END
        
        IF 17@ == 3 // 0.3.DL
        THEN
            0A8E: 30@ = 31@ + 0x2ACA14            // SAMP_CHAT_INPUT_INFO_OFFSET
            0A8D: 29@ = readMem 30@ sz 4 vp 0     // pChatInput;
            0A8E: 28@ = 29@ + 0x8                // pChatInput->pEditBox;
            0A8D: 27@ = readMem 28@ sz 4 vp 0     // pEditBox;
          
            0A8E: 26@ = 31@ + 0x85000 // CDXUTEditBox::SetText
            0A8E: 25@ = 31@ + 0x69410 // PROCESS_INPUT
        END
        
        IF 17@ == 4 // 0.3.7 R3 
        THEN
            0A8E: 30@ = 31@ + 0x26E8CC            // SAMP_CHAT_INPUT_INFO_OFFSET
            0A8D: 29@ = readMem 30@ sz 4 vp 0     // pChatInput;
            0A8E: 28@ = 29@ + 0x8                // pChatInput->pEditBox;
            0A8D: 27@ = readMem 28@ sz 4 vp 0     // pEditBox;
          
            0A8E: 26@ = 31@ + 0x84E70 // CDXUTEditBox::SetText
            0A8E: 25@ = 31@ + 0x69260 // PROCESS_INPUT
        END
        
        IF 17@ == 5 // 0.3.7 R4
        THEN
            0A8E: 30@ = 31@ + 0x26E9FC            // SAMP_CHAT_INPUT_INFO_OFFSET
            0A8D: 29@ = readMem 30@ sz 4 vp 0     // pChatInput;
            0A8E: 28@ = 29@ + 0x8                // pChatInput->pEditBox;
            0A8D: 27@ = readMem 28@ sz 4 vp 0     // pEditBox;
          
            0A8E: 26@ = 31@ + 0x855B0 // CDXUTEditBox::SetText
            0A8E: 25@ = 31@ + 0x69990 // PROCESS_INPUT
        END
        
        IF 17@ == 6 // 0.3.7 R4 - v2
        THEN
            0A8E: 30@ = 31@ + 0x26E9FC            // SAMP_CHAT_INPUT_INFO_OFFSET
            0A8D: 29@ = readMem 30@ sz 4 vp 0     // pChatInput;
            0A8E: 28@ = 29@ + 0x8                // pChatInput->pEditBox;
            0A8D: 27@ = readMem 28@ sz 4 vp 0     // pEditBox;
          
            0A8E: 26@ = 31@ + 0x855E0 // CDXUTEditBox::SetText
            0A8E: 25@ = 31@ + 0x699D0 // PROCESS_INPUT
        END

        IF 17@ == 7 // 0.3.7 R5
        THEN
            0A8E: 30@ = 31@ + 0x26EB84            // SAMP_CHAT_INPUT_INFO_OFFSET
            0A8D: 29@ = readMem 30@ sz 4 vp 0     // pChatInput;
            0A8E: 28@ = 29@ + 0x8                // pChatInput->pEditBox;
            0A8D: 27@ = readMem 28@ sz 4 vp 0     // pEditBox;
          
            0A8E: 26@ = 31@ + 0x85580 // CDXUTEditBox::SetText
            0A8E: 25@ = 31@ + 0x699D0 // PROCESS_INPUT
        END
    
        0AA8: call_function_method 26@ struct 27@ num_params 2 pop 0 _bSelected 0 _pszText 0@ _retVal 6@
        0AA8: call_function_method 25@ struct 29@ num_params 0 pop 0 _retVal 7@
    END
END
0AB2: 0

:registerClientCommand
{
    Credits:
        Parazitas - UGBASE
        kawa_operand - BlastHack
        ajom - UGBASE
    
    Usage:
    0AC8: 31@ = allocate_memory_size 1024
    0AD3: 31@ = string_format "vr"
    0AC7: 30@ = var 30@ pointer
    0AC7: 29@ = var 29@ pointer
    0AB1: @registerClientCommand 3 _CommandName 31@ _TogglingVar 30@ _ParamsPtrToVar 29@
    30@ = 0 // default disabled
    29@ = 0 // null ptr
 
    Note:
        The Reference Pointers passed at _TogglingVar and _ParamPtrToVar are required to be treated as ReadOnly. Which means that the value of those two Reference Pointers should not be manually overwritten/changed.

    I am having a problem with opcode 0AB1, it permanently writes on the main thread's local variables. Maybe its because I directly writes on the passed variable's memory pointer. An example case:
        Passing _ParamPtrToVar = 31@ , _TogglingVar = 30@
            Opcode 0AB1 31@ == Main Thread's 31@
            Opcode 0AB1 30@ == Main Thread's 30@

    Thats why I decided to use global variables since they aren't that exposed on scripts.
}
CONST
    //    WARNING:
    //        Do not use Local Variables
    //        Do not recycle/use the three variables on any operation inside the script because these variables will always be used by this function and doesn't override outside the function. I promise you that even if you replace this with a local variable, It will cause overwriting mistakes that will mess the operation
    // You can Replace any of these variables into any UNIQUE GLOBAL VARIABLES
    VAR1 = $2AFD
    VAR2 = $2BEC
    VAR3 = $2CDE
    VAR4 = $2DCB
    VAR5 = $2EBF
    VAR6 = $2FAA
END
IF 0AA2: VAR4 = "samp.dll"
THEN
        // ~~~~~~~~~~~~~ Create a New Callback Structure
        {
            51                      // push     ecx
            56                      // push     esi
            8B 74 24 0C             // mov     esi, [esp+0Ch]
            89 34 25 11 11 11 11    // mov     [11111111], esi // later: [11111111] becomes 1@
            83 35 11 11 11 11 01    // xor     [11111111], 01 // later: [11111111] becomes 2@
            5E                      // pop     esi
            59                      // pop     ecx
            C3 // retn
        }
            // Avoid using local variables by saving the values inside a global variables
    008A: VAR1 = 0@
    008A: VAR2 = 2@
    008A: VAR3 = 1@
            //
    0AC8: VAR5 = allocate_memory_size 23 // undeleteable memory region
    0084: VAR6 = VAR5
    0A8C: write_memory VAR6 size 4 value 0x748B5651 virtual_protect 1
    VAR6 += 4
    0A8C: write_memory VAR6 size 4 value 0x34890C24 virtual_protect 1
    VAR6 += 4
    0A8C: write_memory VAR6 size 1 value 0x25 virtual_protect 1
    VAR6++
    // 0A8C: write_memory VAR2 size 4 value 0 virtual_protect 0 // null string // NOT WORKING due to this function's varibles overriding
    0A8C: write_memory VAR6 size 4 value VAR2 virtual_protect 1
    VAR6 += 4
    0A8C: write_memory VAR6 size 2 value 0x3583 virtual_protect 1
    VAR6 += 2
    // 0A8C: write_memory VAR3 size 4 value 0 virtual_protect 0 // Zeroing TogglingVar // NOT WORKING due to this function's varibles overriding
    0A8C: write_memory VAR6 size 4 value VAR3 virtual_protect 1
    VAR6 += 4
    0A8C: write_memory VAR6 size 4 value 0xC3595E01 virtual_protect 1
        // ~~~~~~~~~~~~~ now callback struct VAR5 is ready
    0AB1: @get_samp_version_id 0 _returned: ID 17@ 
    IF 17@ > 0
    THEN
        IF 17@ == 1 // 0.3.7 R1
        THEN 
            0A8E: VAR6 = VAR4 + 0x21A0E8 // SAMP_CHAT_INPUT_INFO_OFFSET
            0A8D: VAR6 = read_memory VAR6 size 4 virtual_protect 1
            VAR4 += 0x65AD0 // SAMP_REGISTER_CLIENT_CMD_OFFSET
        END
        IF 17@ == 2 // 0.3.7 R2
        THEN
            0A8E: VAR6 = VAR4 + 0x21A0F0 // SAMP_CHAT_INPUT_INFO_OFFSET
            0A8D: VAR6 = read_memory VAR6 size 4 virtual_protect 1
            VAR4 += 0x65BA0 // SAMP_REGISTER_CLIENT_CMD_OFFSET
        END
        
        IF 17@ == 3 // 0.3.DL
        THEN
            0A8E: VAR6 = VAR4 + 0x2ACA14 // SAMP_CHAT_INPUT_INFO_OFFSET
            0A8D: VAR6 = read_memory VAR6 size 4 virtual_protect 1
            VAR4 += 0x691B0 // SAMP_REGISTER_CLIENT_CMD_OFFSET
        END
        
        IF 17@ == 4 // 0.3.7 R3 
        THEN
            0A8E: VAR6 = VAR4 + 0x26E8CC // SAMP_CHAT_INPUT_INFO_OFFSET
            0A8D: VAR6 = read_memory VAR6 size 4 virtual_protect 1
            VAR4 += 0x69000 // SAMP_REGISTER_CLIENT_CMD_OFFSET
        END
        
        IF 17@ == 5 // 0.3.7 R4
        THEN
            0A8E: VAR6 = VAR4 + 0x26E9FC // SAMP_CHAT_INPUT_INFO_OFFSET
            0A8D: VAR6 = read_memory VAR6 size 4 virtual_protect 1
            VAR4 += 0x69730 // SAMP_REGISTER_CLIENT_CMD_OFFSET
        END
        
        IF 17@ == 6 // 0.3.7 R4 - v2
        THEN
            0A8E: VAR6 = VAR4 + 0x26E9FC // SAMP_CHAT_INPUT_INFO_OFFSET
            0A8D: VAR6 = read_memory VAR6 size 4 virtual_protect 1
            VAR4 += 0x69770 // SAMP_REGISTER_CLIENT_CMD_OFFSET
        END

        IF 17@ == 7 // 0.3.7 R5
        THEN
            0A8E: VAR6 = VAR4 + 0x26EB84 // SAMP_CHAT_INPUT_INFO_OFFSET
            0A8D: VAR6 = read_memory VAR6 size 4 virtual_protect 1
            VAR4 += 0x69770 // SAMP_REGISTER_CLIENT_CMD_OFFSET
        END
    
        0AA6: call_method VAR4 struct VAR6 num_params 2 pop 0 VAR5 VAR1
    END
END
0AB2: ret 0

:IfTextContains
//0AB1: @IfTextContains 2 String1 0@ String2 1@
0AB1: @strlen 1 string 0@ _length 31@
0AB1: @strlen 1 string 1@ _length 30@

//initial length check (the phrase can't be longer than the main text)
if 001D:   30@ > 31@  // (int)
then
059A:  return_false
0AB2: ret 1 0
end

31@ -= 1
26@ = 0 // counter of the same chars in a row
for 29@ = 0 to 31@ // for each char of the main text  (29@ = index)
    0085: 24@ = 0@ // (int)
    005A: 24@ += 29@  // (int)
    0A8D: 28@ = read_memory 24@ size 1 virtual_protect 0

    0085: 23@ = 1@ // (int)
    005A: 23@ += 26@  // (int)
    0A8D: 27@ = read_memory 23@ size 1 virtual_protect 0

    if 003B:   28@ == 27@  // (int)
    then
    26@++
        if 002D:   26@ >= 30@  // (int)
        then
        0485:  return_true
        0062: 24@ -= 30@  // (int)
        24@ += 1
        0AB2: ret 1 24@
        end
    else
        if 26@ > 0
        then
        29@-- //check the same char again and assume it's the begining of the string but only if there was matching parts before (otherwise it would go back all the time and make infinite loop)
        end
    26@ = 0
    end       
end

059A:  return_false
0AB2: ret 1 0

:strlen
// 0AB1: @strlen 1 string 1@ _return: size 3@
for 1@ = 0 to 1024
    0A8D: 2@ = read_memory 0@ size 1 virtual_protect 0
    if not 2@ == 0
    jf break
    0@ += 1
end
0AB2: ret 1 1@

:Timer
2@ = TRUE
IF
2@ == TRUE
THEN
    0@ *= 1000
    0085: 4@ = 0@ // (int)
    0085: 3@ = 1@ // (int)
    0062: 3@ -= 4@  // (int)

    3@ /= 1000
  
    3@ *= -1
END

IF AND
2@ == TRUE
001D:   1@ > 0@  // (int)
THEN
    2@ = FALSE
END
0AB2: ret 2 3@ 2@
 

Attachments

  • TowCars.cs
    33.8 KB · Views: 2
Status
Not open for further replies.
Top