CLEO Help Reading And Replying Messages Without Sampfuncs

CLEO related

tydeushd

Member
Joined
Sep 23, 2022
Messages
13
Reaction score
1
Hello, i have an issue. I am trying to make a script that will read the game's chat and all kinds of chats (including server chat, player chat) without using Sampfuncs, and if it sees the sentence "there is a fish" in the chat, it will automatically send the "/startfish" command once. I need to do it without using sampfuncs and my samp version is 0.3dl. Could you help? I'm getting crash like this:

Code:
{$CLEO .cs}
0000:  NOP

REPEAT
wait 0 /// wait 10sec until samp is redy
Until 0AFA:

const
SAMP_CHAT_INFO_OFFSET_03DL = 0x2ACA10
FUNC_ADDTOCHATWND_03DL = 0x67650
FUNC_SAY_03DL = 0x5860
FUNC_SEND_CMD_03DL = 0x69340
end

0AD3: 0@ = format "/startfish"


WHILE TRUE
    WAIT 0
    
if
0B61: samp is_local_player_spawned
then
    0AC8: 0@ allocate_memory_size 260
    0AC8: 1@ allocate_memory_size 260
    0B75: samp get_chat_string 99 text_to 0@ prefix_to 1@ color_to 2@ prefix_color_to 3@
    If
    0C29: $NOT_USED = stristr string1 0@ string2 "there is a fish"
    Then 
    0AB1: @SAY 1 text 0@
    end
 
END

:SAY
//0AB1: @SAY 1 $text
IF 0AA2: 1@ = "samp.dll"
THEN
    1@ += FUNC_SAY_03DL
    0AA5: call 1@ num_param 1 pop 0 0@
END
0AB2: 0
 

Ice555

Active member
Joined
Mar 11, 2021
Messages
49
Solutions
3
Reaction score
7
Location
Lithuania
Hello, i have an issue. I am trying to make a script that will read the game's chat and all kinds of chats (including server chat, player chat) without using Sampfuncs, and if it sees the sentence "there is a fish" in the chat, it will automatically send the "/startfish" command once. I need to do it without using sampfuncs and my samp version is 0.3dl. Could you help? I'm getting crash like this:

Code:
{$CLEO .cs}
0000:  NOP

REPEAT
wait 0 /// wait 10sec until samp is redy
Until 0AFA:

const
SAMP_CHAT_INFO_OFFSET_03DL = 0x2ACA10
FUNC_ADDTOCHATWND_03DL = 0x67650
FUNC_SAY_03DL = 0x5860
FUNC_SEND_CMD_03DL = 0x69340
end

0AD3: 0@ = format "/startfish"


WHILE TRUE
    WAIT 0
   
if
0B61: samp is_local_player_spawned
then
    0AC8: 0@ allocate_memory_size 260
    0AC8: 1@ allocate_memory_size 260
    0B75: samp get_chat_string 99 text_to 0@ prefix_to 1@ color_to 2@ prefix_color_to 3@
    If
    0C29: $NOT_USED = stristr string1 0@ string2 "there is a fish"
    Then
    0AB1: @SAY 1 text 0@
    end
 
END

:SAY
//0AB1: @SAY 1 $text
IF 0AA2: 1@ = "samp.dll"
THEN
    1@ += FUNC_SAY_03DL
    0AA5: call 1@ num_param 1 pop 0 0@
END
0AB2: 0
and dont use sf opcodes, like 0B75, 0B61
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
Hello, i have an issue. I am trying to make a script that will read the game's chat and all kinds of chats (including server chat, player chat) without using Sampfuncs, and if it sees the sentence "there is a fish" in the chat, it will automatically send the "/startfish" command once. I need to do it without using sampfuncs and my samp version is 0.3dl. Could you help? I'm getting crash like this:

Code:
{$CLEO .cs}
0000:  NOP

REPEAT
wait 0 /// wait 10sec until samp is redy
Until 0AFA:

const
SAMP_CHAT_INFO_OFFSET_03DL = 0x2ACA10
FUNC_ADDTOCHATWND_03DL = 0x67650
FUNC_SAY_03DL = 0x5860
FUNC_SEND_CMD_03DL = 0x69340
end

0AD3: 0@ = format "/startfish"


WHILE TRUE
    WAIT 0
   
if
0B61: samp is_local_player_spawned
then
    0AC8: 0@ allocate_memory_size 260
    0AC8: 1@ allocate_memory_size 260
    0B75: samp get_chat_string 99 text_to 0@ prefix_to 1@ color_to 2@ prefix_color_to 3@
    If
    0C29: $NOT_USED = stristr string1 0@ string2 "there is a fish"
    Then
    0AB1: @SAY 1 text 0@
    end
 
END

:SAY
//0AB1: @SAY 1 $text
IF 0AA2: 1@ = "samp.dll"
THEN
    1@ += FUNC_SAY_03DL
    0AA5: call 1@ num_param 1 pop 0 0@
END
0AB2: 0
Opcode
0C29
Requires SAMPFUNC
 

tydeushd

Member
Joined
Sep 23, 2022
Messages
13
Reaction score
1
I combined my code with what you said, but shouldn't it send an "Important message" when it sees "ant" in the chat? It's not working right now, I don't have much information. I couldn't understand where I made a mistake

@Parazitas @Ice555
Code:
{$CLEO .cs}
0000:  NOP

REPEAT
wait 10000 /// wait 10sec until samp is redy

const
SAMP_CHAT_INFO_OFFSET_03DL = 0x2ACA10
FUNC_ADDTOCHATWND_03DL = 0x67650
FUNC_SAY_03DL = 0x5860
FUNC_SEND_CMD_03DL = 0x69340
end

WHILE TRUE
    WAIT 0

{
    ----------------------
           PREPARATION
    ----------------------
}

0AC8: 0@ = allocate_memory_size 100
0AC8: 1@ = allocate_memory_size 100

0AD3: 0@ = format "Important message"
0AD3: 1@ = format "ant"

{
    ----------------------
           USAGE
    ----------------------
}

if 0AB1: call_scm_func @IfTextContains 2 mainTextPointer 0@ pieceToFindPointer 1@ _returnedPointer 2@
then
0AB1: @SAY 1 text 0@
wait 2000
end

0A93: end_custom_thread

:IfTextContains
/*
    0AC8: 1@ = allocate_memory_size 1024
    0AD3: 1@ = format "my string to compare"
    IF 0AB1: @IfTextContains 2 String1 0@ String2 1@ _Returned: Text 2@
*/
0AA7: call_function 0x718690 num_params 1 pop 1 string 0@ _Returned: length 31@ // Gta Strlen
0AA7: call_function 0x718690 num_params 1 pop 1 string 1@ _Returned: length 30@ // Gta Strlen

//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@ = readMem 24@ sz 1 vp 0

    0085: 23@ = 1@ // (int)
    005A: 23@ += 26@  // (int)
    0A8D: 27@ = readMem 23@ sz 1 vp 0
    IF AND
    28@ >= 65 // From A
    28@ >= 90 // Till Z
    THEN 28@ += 32 // convert to lowercase
    END
    IF AND
    27@ >= 65 // From A
    27@ >= 90 // Till Z
    THEN 27@ += 32 // convert to lowercase
    END
    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

:SAY
//0AB1: @SAY 1 $text
IF 0AA2: 1@ = "samp.dll"
THEN
    1@ += FUNC_SAY_03DL
    0AA5: call 1@ num_param 1 pop 0 0@
END
 

Ice555

Active member
Joined
Mar 11, 2021
Messages
49
Solutions
3
Reaction score
7
Location
Lithuania
I combined my code with what you said, but shouldn't it send an "Important message" when it sees "ant" in the chat? It's not working right now, I don't have much information. I couldn't understand where I made a mistake

@Parazitas @Ice555
Code:
{$CLEO .cs}
0000:  NOP

REPEAT
wait 10000 /// wait 10sec until samp is redy

const
SAMP_CHAT_INFO_OFFSET_03DL = 0x2ACA10
FUNC_ADDTOCHATWND_03DL = 0x67650
FUNC_SAY_03DL = 0x5860
FUNC_SEND_CMD_03DL = 0x69340
end

WHILE TRUE
    WAIT 0

{
    ----------------------
           PREPARATION
    ----------------------
}

0AC8: 0@ = allocate_memory_size 100
0AC8: 1@ = allocate_memory_size 100

0AD3: 0@ = format "Important message"
0AD3: 1@ = format "ant"

{
    ----------------------
           USAGE
    ----------------------
}

if 0AB1: call_scm_func @IfTextContains 2 mainTextPointer 0@ pieceToFindPointer 1@ _returnedPointer 2@
then
0AB1: @SAY 1 text 0@
wait 2000
end

0A93: end_custom_thread

:IfTextContains
/*
    0AC8: 1@ = allocate_memory_size 1024
    0AD3: 1@ = format "my string to compare"
    IF 0AB1: @IfTextContains 2 String1 0@ String2 1@ _Returned: Text 2@
*/
0AA7: call_function 0x718690 num_params 1 pop 1 string 0@ _Returned: length 31@ // Gta Strlen
0AA7: call_function 0x718690 num_params 1 pop 1 string 1@ _Returned: length 30@ // Gta Strlen

//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@ = readMem 24@ sz 1 vp 0

    0085: 23@ = 1@ // (int)
    005A: 23@ += 26@  // (int)
    0A8D: 27@ = readMem 23@ sz 1 vp 0
    IF AND
    28@ >= 65 // From A
    28@ >= 90 // Till Z
    THEN 28@ += 32 // convert to lowercase
    END
    IF AND
    27@ >= 65 // From A
    27@ >= 90 // Till Z
    THEN 27@ += 32 // convert to lowercase
    END
    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

:SAY
//0AB1: @SAY 1 $text
IF 0AA2: 1@ = "samp.dll"
THEN
    1@ += FUNC_SAY_03DL
    0AA5: call 1@ num_param 1 pop 0 0@
END
while true needs end.

if 0AB1: call_scm_func @IfTextContains 2 mainTextPointer 0@ pieceToFindPointer 1@ _returnedPointer 2@
then
0AB1: @SAY 1 text 0@
wait 2000
end
end
 

tydeushd

Member
Joined
Sep 23, 2022
Messages
13
Reaction score
1
oh and main text pointer has to be chat message, which u can get from this. https://ugbase.eu/threads/cleo-some-multi-samp-snippets.17193/post-110748
well, i made this but i dont know that if we can two @'s in one phrase


Code:
{$CLEO .cs}
0000:  NOP

REPEAT
wait 10000 /// wait 10sec until samp is redy

const
SAMP_CHAT_INFO_OFFSET_03DL = 0x2ACA10
FUNC_ADDTOCHATWND_03DL = 0x67650
FUNC_SAY_03DL = 0x5860
FUNC_SEND_CMD_03DL = 0x69340
end

WHILE TRUE
    WAIT 0

{
    ----------------------
           PREPARATION
    ----------------------
}

0AC8: 0@ = allocate_memory_size 100
0AC8: 1@ = allocate_memory_size 100

0AD3: 0@ = format "Important message"
0AD3: 1@ = format "ant"

{
    ----------------------
           USAGE
    ----------------------
}

if 0AB1: call_scm_func @IfTextContains @getChatString mainTextPointer 0@ pieceToFindPointer 1@ _returnedPointer 2@
then
0AB1: @SAY 1 text 0@
wait 2000
end
end

0A93: end_custom_thread

:IfTextContains
/*
    0AC8: 1@ = allocate_memory_size 1024
    0AD3: 1@ = format "my string to compare"
    IF 0AB1: @IfTextContains 2 String1 0@ String2 1@ _Returned: Text 2@
*/
0AA7: call_function 0x718690 num_params 1 pop 1 string 0@ _Returned: length 31@ // Gta Strlen
0AA7: call_function 0x718690 num_params 1 pop 1 string 1@ _Returned: length 30@ // Gta Strlen

//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@ = readMem 24@ sz 1 vp 0

    0085: 23@ = 1@ // (int)
    005A: 23@ += 26@  // (int)
    0A8D: 27@ = readMem 23@ sz 1 vp 0
    IF AND
    28@ >= 65 // From A
    28@ >= 90 // Till Z
    THEN 28@ += 32 // convert to lowercase
    END
    IF AND
    27@ >= 65 // From A
    27@ >= 90 // Till Z
    THEN 27@ += 32 // convert to lowercase
    END
    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

:SAY
//0AB1: @SAY 1 $text
IF 0AA2: 1@ = "samp.dll"
THEN
    1@ += FUNC_SAY_03DL
    0AA5: call 1@ num_param 1 pop 0 0@
END

:getChatString
{
    0AC8: 0@ = allocate_memory_size 1024
    0AC8: 1@ = allocate_memory_size 1024
    0AB1: @getChatString 1 ChatID 99 _Returned: Text 0@ PrefixText 1@ Color 2@ PrefixColor 3@
}
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
            31@ += 0x21A0E4 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
        IF 17@ == 2 // 0.3.7 R2
        THEN
            31@ += 0x21A0EC // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
        
        IF 17@ == 3 // 0.3.DL
        THEN
            31@ += 0x2ACA10 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
        
        IF 17@ == 4 // 0.3.7 R3
        THEN
            31@ += 0x26E8C8 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
        
        IF 17@ == 5 // 0.3.7 R4
        THEN
            31@ += 0x26E9F8 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
        
        IF 17@ == 6 // 0.3.7 R4 - v2
        THEN
            31@ += 0x26E9F8 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
        
        IF 17@ == 7 // 0.3.7 R5
        THEN
            31@ += 0x26EB80 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
        0AA3: 31@
    END
END
0AB2: ret 4 30@ 29@ 27@ 24@

:get_samp_version_id
30@ = 0
if 0AA2: 31@ = load_library "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 R1
    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 1
    30@ = 4
    end   
end
0AB2: ret 1 30@

// Usage: 0AB1: call_scm_func @get_samp_version_name 0 _returned_name 0@
//
// There's no need to allocate memory, it is allocated inside function. If the function is called
// repetitively then you can free memory before making another call (using: 0AC9: free_allocated_memory 0@)
:get_samp_version_name
0AB1: call_scm_func @get_samp_version_id 0 _returned_id 30@
0AC8: 31@ = allocate_memory_size 30
if 30@ == 0
then
0AD3: 31@ = format "Not recognized"
end

if 30@ == 1
then
0AD3: 31@ = format "0.3.7 R1"
end

if 30@ == 2
then
0AD3: 31@ = format "0.3.7 R2"
end

if 30@ == 3
then
0AD3: 31@ = format "0.3.DL R1"
end

if 30@ == 4
then
0AD3: 31@ = format "0.3.7 R3 1"
end
0AB2: ret 1 31@
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
well, i made this but i dont know that if we can two @'s in one phrase


Code:
{$CLEO .cs}
0000:  NOP

REPEAT
wait 10000 /// wait 10sec until samp is redy

const
SAMP_CHAT_INFO_OFFSET_03DL = 0x2ACA10
FUNC_ADDTOCHATWND_03DL = 0x67650
FUNC_SAY_03DL = 0x5860
FUNC_SEND_CMD_03DL = 0x69340
end

WHILE TRUE
    WAIT 0

{
    ----------------------
           PREPARATION
    ----------------------
}

0AC8: 0@ = allocate_memory_size 100
0AC8: 1@ = allocate_memory_size 100

0AD3: 0@ = format "Important message"
0AD3: 1@ = format "ant"

{
    ----------------------
           USAGE
    ----------------------
}

if 0AB1: call_scm_func @IfTextContains @getChatString mainTextPointer 0@ pieceToFindPointer 1@ _returnedPointer 2@
then
0AB1: @SAY 1 text 0@
wait 2000
end
end

0A93: end_custom_thread

:IfTextContains
/*
    0AC8: 1@ = allocate_memory_size 1024
    0AD3: 1@ = format "my string to compare"
    IF 0AB1: @IfTextContains 2 String1 0@ String2 1@ _Returned: Text 2@
*/
0AA7: call_function 0x718690 num_params 1 pop 1 string 0@ _Returned: length 31@ // Gta Strlen
0AA7: call_function 0x718690 num_params 1 pop 1 string 1@ _Returned: length 30@ // Gta Strlen

//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@ = readMem 24@ sz 1 vp 0

    0085: 23@ = 1@ // (int)
    005A: 23@ += 26@  // (int)
    0A8D: 27@ = readMem 23@ sz 1 vp 0
    IF AND
    28@ >= 65 // From A
    28@ >= 90 // Till Z
    THEN 28@ += 32 // convert to lowercase
    END
    IF AND
    27@ >= 65 // From A
    27@ >= 90 // Till Z
    THEN 27@ += 32 // convert to lowercase
    END
    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

:SAY
//0AB1: @SAY 1 $text
IF 0AA2: 1@ = "samp.dll"
THEN
    1@ += FUNC_SAY_03DL
    0AA5: call 1@ num_param 1 pop 0 0@
END

:getChatString
{
    0AC8: 0@ = allocate_memory_size 1024
    0AC8: 1@ = allocate_memory_size 1024
    0AB1: @getChatString 1 ChatID 99 _Returned: Text 0@ PrefixText 1@ Color 2@ PrefixColor 3@
}
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
            31@ += 0x21A0E4 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
        IF 17@ == 2 // 0.3.7 R2
        THEN
            31@ += 0x21A0EC // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
     
        IF 17@ == 3 // 0.3.DL
        THEN
            31@ += 0x2ACA10 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
     
        IF 17@ == 4 // 0.3.7 R3
        THEN
            31@ += 0x26E8C8 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
     
        IF 17@ == 5 // 0.3.7 R4
        THEN
            31@ += 0x26E9F8 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
     
        IF 17@ == 6 // 0.3.7 R4 - v2
        THEN
            31@ += 0x26E9F8 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
     
        IF 17@ == 7 // 0.3.7 R5
        THEN
            31@ += 0x26EB80 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
        0AA3: 31@
    END
END
0AB2: ret 4 30@ 29@ 27@ 24@

:get_samp_version_id
30@ = 0
if 0AA2: 31@ = load_library "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 R1
    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 1
    30@ = 4
    end
end
0AB2: ret 1 30@

// Usage: 0AB1: call_scm_func @get_samp_version_name 0 _returned_name 0@
//
// There's no need to allocate memory, it is allocated inside function. If the function is called
// repetitively then you can free memory before making another call (using: 0AC9: free_allocated_memory 0@)
:get_samp_version_name
0AB1: call_scm_func @get_samp_version_id 0 _returned_id 30@
0AC8: 31@ = allocate_memory_size 30
if 30@ == 0
then
0AD3: 31@ = format "Not recognized"
end

if 30@ == 1
then
0AD3: 31@ = format "0.3.7 R1"
end

if 30@ == 2
then
0AD3: 31@ = format "0.3.7 R2"
end

if 30@ == 3
then
0AD3: 31@ = format "0.3.DL R1"
end

if 30@ == 4
then
0AD3: 31@ = format "0.3.7 R3 1"
end
0AB2: ret 1 31@

Any SAMP
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

WHILE TRUE
WAIT 0

IF 0256:   player $PLAYER_CHAR defined
THEN
    0AC8: 0@ = allocate_memory_size 144
    0AC8: 1@ = allocate_memory_size 144
    0AB1: @getChatString 1 ChatID 99 _Returned: Text 0@ PrefixText 1@ Color 2@ PrefixColor 3@
  
    0AC8: 4@ = allocate_memory_size 144
    0AD3: 4@ = format "there is a fish"
    IF 0AB1: @IfTextContains 2 String1 0@ String2 4@ _returned: Text 5@
    THEN
        0AC8: 6@ = allocate_memory_size 144
        0AD3: 6@ = format "/startfish"
        0AB1: @process_chat_input 1 InputText 6@
        0AC9: free_allocated_memory 6@
        WAIT 1500
    END 
  
    0AC9: free_allocated_memory 0@
    0AC9: free_allocated_memory 1@
    0AC9: free_allocated_memory 4@
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@

:getChatString
{
    0AC8: 0@ = allocate_memory_size 144
    0AC8: 1@ = allocate_memory_size 144
    0AB1: @getChatString 1 ChatID 99 _Returned: Text 0@ PrefixText 1@ Color 2@ PrefixColor 3@
    0AC9: free_allocated_memory 0@
    0AC9: free_allocated_memory 1@
}
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
            31@ += 0x21A0E4 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
        IF 17@ == 2 // 0.3.7 R2
        THEN
            31@ += 0x21A0EC // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
      
        IF 17@ == 3 // 0.3.DL
        THEN
            31@ += 0x2ACA10 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
      
        IF 17@ == 4 // 0.3.7 R3
        THEN
            31@ += 0x26E8C8 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
      
        IF 17@ == 5 // 0.3.7 R4
        THEN
            31@ += 0x26E9F8 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
      
        IF 17@ == 6 // 0.3.7 R4 - v2
        THEN
            31@ += 0x26E9F8 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
      
        IF 17@ == 7 // 0.3.7 R5
        THEN
            31@ += 0x26EB80 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
        0AA3: 31@
    END
END
0AB2: ret 4 30@ 29@ 27@ 24@

:process_chat_input
/*
    0AC8: 1@ = allocate_memory_size 144
    0AD3: 1@ = format "text or /command"
    0AB1: @process_chat_input 1 InputText 1@
    0AC9: free_allocated_memory 1@
*/
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

:IfTextContains
{
    0AC8: 3@ = allocate_memory_size 1024
    0AD3: 3@ = format "Ar"
    if 0AB1: @IfTextContains 2 String1 2@ String2 3@ _returned: Text 4@
}
0AB1: @strlenA 1 string 0@ _length 31@
0AB1: @strlenA 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

:StrlenA
// 0AB1: @StrlenA 1 String 0@ _Returned: Length 1@
0A8D: 26@ = readmem 0x8580DC sz 4 vp 0 // 0x8580DC - KERNEL32.lstrlenA
0AA7: strlen_addr 26@ num_params 1 pop 0 string 0@ _returned_length 25@
0AB2: ret 1 25@
 

tydeushd

Member
Joined
Sep 23, 2022
Messages
13
Reaction score
1
Can we also add activation with the f3 key? It should be open at startup, but I can pause and continue with the f3 key.
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
Can we also add activation with the f3 key? It should be open at startup, but I can pause and continue with the f3 key.
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

WHILE TRUE
WAIT 0

IF 0256:   player $PLAYER_CHAR defined
THEN
    IF 0AB0: 114 // PRESSED F3
    THEN
        REPEAT
        WAIT 0
        UNTIL 8AB0: 114 // NOT PRESSED F3
        IF 31@ == FALSE
        THEN
            31@ = TRUE
            0AD1: "~Y~Auto fishing ~G~ON" 1337
        ELSE
            31@ = FALSE
            0AD1: "~Y~Auto fishing ~R~OFF" 1337
        END
    END
    IF 31@ == TRUE
    THEN
        0AC8: 0@ = allocate_memory_size 144
        0AC8: 1@ = allocate_memory_size 144
        0AB1: @getChatString 1 ChatID 99 _Returned: Text 0@ PrefixText 1@ Color 2@ PrefixColor 3@
      
        0AC8: 4@ = allocate_memory_size 144
        0AD3: 4@ = format "there is a fish"
        IF 0AB1: @IfTextContains 2 String1 0@ String2 4@ _returned: Text 5@
        THEN
            0AC8: 6@ = allocate_memory_size 144
            0AD3: 6@ = format "/startfish"
            0AB1: @process_chat_input 1 InputText 6@
            0AC9: free_allocated_memory 6@
            WAIT 1500
        END 
      
        0AC9: free_allocated_memory 0@
        0AC9: free_allocated_memory 1@
        0AC9: free_allocated_memory 4@
    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@

:getChatString
{
    0AC8: 0@ = allocate_memory_size 144
    0AC8: 1@ = allocate_memory_size 144
    0AB1: @getChatString 1 ChatID 99 _Returned: Text 0@ PrefixText 1@ Color 2@ PrefixColor 3@
    0AC9: free_allocated_memory 0@
    0AC9: free_allocated_memory 1@
}
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
            31@ += 0x21A0E4 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
        IF 17@ == 2 // 0.3.7 R2
        THEN
            31@ += 0x21A0EC // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
      
        IF 17@ == 3 // 0.3.DL
        THEN
            31@ += 0x2ACA10 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
      
        IF 17@ == 4 // 0.3.7 R3
        THEN
            31@ += 0x26E8C8 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
      
        IF 17@ == 5 // 0.3.7 R4
        THEN
            31@ += 0x26E9F8 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
      
        IF 17@ == 6 // 0.3.7 R4 - v2
        THEN
            31@ += 0x26E9F8 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
      
        IF 17@ == 7 // 0.3.7 R5
        THEN
            31@ += 0x26EB80 // SAMP_CHAT_INFO_OFFSET
            0A8D: 31@ readMem 31@ sz 4 vp 0
            31@ += 0x132
            0@ *= 0xFC
            005A: 31@ += 0@
            0A8E: 30@ = 31@ + 0x20 // CHAT_TEXT_OFFSET
            0A8E: 29@ = 31@ + 0x4 // CHAT_PREFIX_TEXT_OFFSET
            0A8E: 28@ = 31@ + 0xF4 // CHAT_COLOR_OFFSET
            0A8D: 27@ readMem 28@ sz 4 vp 0 // HEX Color
            0A8E: 26@ = 31@ + 0xF8 // CHAT_PREFIX_COLOR_OFFSET
            0A8D: 25@ readMem 26@ sz 1 vp 0
            IF NOT 25@ > 0
            THEN 24@ = 0
            ELSE 0A8D: 24@ readMem 26@ sz 4 vp 0
            END
        END
        0AA3: 31@
    END
END
0AB2: ret 4 30@ 29@ 27@ 24@

:process_chat_input
/*
    0AC8: 1@ = allocate_memory_size 144
    0AD3: 1@ = format "text or /command"
    0AB1: @process_chat_input 1 InputText 1@
    0AC9: free_allocated_memory 1@
*/
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

:IfTextContains
{
    0AC8: 3@ = allocate_memory_size 1024
    0AD3: 3@ = format "Ar"
    if 0AB1: @IfTextContains 2 String1 2@ String2 3@ _returned: Text 4@
}
0AB1: @strlenA 1 string 0@ _length 31@
0AB1: @strlenA 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

:StrlenA
// 0AB1: @StrlenA 1 String 0@ _Returned: Length 1@
0A8D: 26@ = readmem 0x8580DC sz 4 vp 0 // 0x8580DC - KERNEL32.lstrlenA
0AA7: strlen_addr 26@ num_params 1 pop 0 string 0@ _returned_length 25@
0AB2: ret 1 25@
 
Top