CLEO Help Taxi

CLEO related

Jik ke

Active member
Joined
Jun 2, 2021
Messages
43
Reaction score
2
Location
America
Hi guys, I need help. This cleo is having an error, please help me how to fix it, this cleo is working: when there is a chat line "(% d) can mot chiec taxi tai", you will immediately receive the number in "(% d)" and Execute it. does the command "/ataxi %d" but why is it not working? This Cleo aims to agree a taxi call faster.
SAMP 0.3DL
Pic chatlog:
Code:
{$CLEO .cs}

0000:
                                        
wait 8500

while true
wait 0

if 0256:   player $PLAYER_CHAR defined
then
    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@  // lay chuoi tro chuyen
    0AC8: 4@ = allocate_memory_size 1024
    0AB1: @DeleteColorCodeFromText 4 text 0@ FirstCharacter 123 SecondCharacter 125  memory_to_store_characters_as_text 4@ // xoa ma mau khoi van ban
    0AC8: 5@ = allocate_memory_size 1024
    0AD3: 5@ = format "can mot chiec taxi tai"
    if 0AB1: @IfTextContains 2 String1 4@ String2 5@ _returned: Text 6@ // Neu van ban chua
    then
        0AC8: 7@ = allocate_memory_size 1024
        0AD3: 7@ = format "() can mot chiec taxi tai"
        if 0AB1: @IfTextContains 2 String1 6@ String2 7@ _returned: Text 8@  // neu van ban chua
        then
            if 0AD4: $NOT_USED = scan_string 8@ format "(%d) can mot chiec taxi tai" 9@
            then
    // Create Command
            0AC8: 6@ = allocate_memory_size 1024
                0AD3: 6@ = format "/ataxi %d" 9@
             0AB1: @PROCESS_CHAT_INPUT 1 InputText 6@ 
    
            end
        end
    end
end                                                                   



:getChatString
{
    0AC8: 0@ = allocate_memory_size 260
    0AC8: 1@ = allocate_memory_size 260
    0AB1: @getChatString 1 ChatID 99 _Returned: Text 0@ PrefixText 1@ Color 2@ PrefixColor 3@
    0.3.DL
}
IF 0AA2: 31@ = "samp.dll"
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
    0AA3: 31@
END
0AB2: ret 4 30@ 29@ 27@ 24@

:DeleteColorCodeFromText
{
    0AB1: @DeleteColorCodeFromText 4 text 0@ FirstCharacter 91 SecondCharacter 93  memory_to_store_characters_as_text 1@
    In: 0@ = text , FirstCharacter , SecondCharacter
    Out: 1@ = pointer to memory where characters will be stored as text
}
5@ = FALSE // inbracket
0AB1: @strlen 1 string 0@ _length 31@
    for 30@ = 0 to 31@
        0085: 29@ = 0@ // copy pointer
        005A: 29@ += 30@  // add offset make loop
        0A8D: 28@ = read_memory 29@ size 1 virtual_protect 1 // 28@ is the ascii number representing character
        if
        003B:   28@ == 1@  // (int)
        then
            5@ = TRUE // inbracket
        end

        if
        5@ == FALSE // inbracket
        THEN
            0A8C: write_memory 3@ size 1 value 28@ virtual_protect 1
            3@ += 1 // move to next address
        END

        if
        003B:   28@ == 2@  // (int)
        then
            5@ = FALSE // inbracket
        end
    end
0A8C: write_memory 3@ size 1 value 0 virtual_protect 1 // null-termination
0AB2: ret 0

:IfTextContains
//0AB1: @IfTextContains 2 String1 0@ String2 1@ _Returned: Text 2@
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@
:get_samp_version_id
// 0AB1: @get_samp_version_id 0 _returned: id 0@
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
        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
END
0AB2: ret 1 30@
:PROCESS_CHAT_INPUT
{
    0.3.DL
    Ex.:
    0AB1: @PROCESS_CHAT_INPUT 1 InputText 0@
}
IF 0AA2: 20@ = "samp.dll"
THEN
    0A8E: 21@ = 20@ + 0x2ACA14            // SAMP_CHAT_INPUT_INFO_OFFSET
    0A8D: 22@ = readMem 21@ sz 4 vp 0     // pChatInput;
    0A8E: 26@ = 22@ + 0x8                // pChatInput->pEditBox;
    0A8D: 27@ = readMem 26@ sz 4 vp 0     // pEditBox;
  
    0A8E: 24@ = 20@ + 0x85000 // CDXUTEditBox::SetText
 
    0AA8: call_function_method 24@ struct 27@ num_params 2 pop 0 _bSelected 0 _pszText 0@ _retVal 6@
  
    0A8E: 25@ = 20@ + 0x69410 // PROCESS_INPUT
    0AA8: call_function_method 25@ struct 22@ num_params 0 pop 0 _retVal 7@
END
0AB2: 0
Code:
 

Attachments

  • sa-mp-115.png
    sa-mp-115.png
    1 MB · Views: 46
Top