CLEO Help Send command if chat message appear.

CLEO related

mmia

Member
Joined
Apr 30, 2019
Messages
17
Reaction score
0
What I do wrong? I want command to trigger if chat message appear. On lua.

Code:
function onAddChatMessage(text)
    if (text == '*Bodyguard Name Surname wants to protect you for $200, type /accept bodyguard to accept.') then
        sendCommand('/accept bodyguard')
    end
    return false
end
 

mmia

Member
Joined
Apr 30, 2019
Messages
17
Reaction score
0
So I made like this and it still doesn't send message on "key words" in samp chat.
Code:
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    while true do
        wait(100)
        if string.find(text, "test this") ~= 0 then
            sendCommand('/saythis')
        end
        return false
    end
end
 
Last edited:

mmia

Member
Joined
Apr 30, 2019
Messages
17
Reaction score
0
this way still doesn't work, no clue.
Code:
function onAddChatMessage(text)
    if string.find(text, "test this") ~= 0 then
        sampSendChat(string.format("/thiscommand"))
    end
    return false
end
 

mmia

Member
Joined
Apr 30, 2019
Messages
17
Reaction score
0
ah right, I should make in two functions? This way in log file it says -Loaded successfully.
if I use string.find then it shows error.
Code:
require"lib.moonloader"
require"lib.sampfuncs"

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
end

function onAddChatMessage(text)
    if (text == 'when I say this') then
        sendCommand('/sendthis')
    end
    return false
end
 

mmia

Member
Joined
Apr 30, 2019
Messages
17
Reaction score
0
This is how it looks in cleo, but need on .lua
Code:
{$CLEO .cs}
0000: NOP

:Init
wait 100
if
    SAMP.Available
jf @Init
0AC8: 0@ = allocate_memory_size 250
0AC8: 1@ = allocate_memory_size 250
jump @WaitForCap

:WaitForCap
wait 0
for 30@ = 98 to 99
    0B75: samp get_chat_string 30@ text_to 0@ prefix_to 1@ color_to 2@ prefix_color_to 3@
    0C26: strupr in 0@ out 1@
    if
        0C18: 2@ = strstr string1 1@ string2 "when I say this"
    then
        0AF9: samp say_msg "/sendthis"
        wait 60000
        Break
    end
end
jump @WaitForCap
 
Top