Вопросы по CLEO-скриптингу

D3.Pheonix

🎹
Модератор
2,814
1,593
Чего метки так хейтят вообще? Никак не пойму. Лично мне на них куда удобнее 🤔
Потому что ты не познал конструкции, и не писал больших скриптов. Да и в чужом коде намного проще разобраться, если есть есть исходник с нормальным кодом и табуляцией, и не придётся туда сюда рыскать, куда же происходит jump. В какой то степени даже будешь немного лучше соображать что происходит, например в js или lua скрипте. Можно еще в добавок писать на классах, но это уже вкусовщина, т.к. будет смесь из опкодов и классов.
 
  • Нравится
Реакции: New_J3rs3y1337

F.SKY

Участник
36
9
CLEO:
:1
wait 0
80DF:   actor $PLAYER_ACTOR driving
jf @1
0AB5: store_actor $PLAYER_ACTOR closest_vehicle_to 0@ closest_ped_to $NO_USE
not 0@ == -1
jf @1
00AA: store_car 0@ position_to 2@ 3@ 4@
00A0: store_actor $PLAYER_ACTOR position_to 5@ 6@ 7@
050A: 8@ = distance_between_XYZ 2@ 3@ 4@ and_XYZ 5@ 6@ 7@             
8@ < 4.0                                                               
jf @1
0AF8: samp add_message_to_chat "Игрок находится рядом с т/с" color 0xFFFFFFFF
jump @1

Типо вот этого?
Не работает. Из-за 6 строчки если убрать "not" поменять знак и число, то спамит при входе в игру, а если оставить то вообще ничего не происходит.
 

New_J3rs3y1337

Активный
148
99
Странно. В чат действительно должно было спамить, мой косяк, но не при входе в игру. Да и с шестой строкой проблем возникнуть не должно было. Я скомпилировал этот же скрипт у себя, всё работает. Возможно дело в твоём компиляторе и версии сани билдера 🤔
Попробуй мой билд закинуть, там открыт исходник. На всякий случай ещё сюда приложу:
1658393212955.png

Если будет работать, будем думать как правильно реализовать однократную отправку сообщений в чат, т.к там тоже есть нюансы которые по-хорошему нужно учитывать.
 

Вложения

  • test21.cs
    137 байт · Просмотры: 7
Последнее редактирование:

murakami

Известный
131
13
Код:
{$CLEO}
0000:
repeat
wait 0
until Samp.Available()
0B34: samp register_client_command "space" to_label @space
1@ = 0

while true
wait 0
    if
    1@ == 1
    then
    0B56: set_game_key 14 state 255
    1@ = 0
    end
end

:space
1@ = 1
Samp.CmdRet()

This is the code to press the shift key when typing /space chat. Strangely, if I manually type /space it works, but when I type /space using the keybinder, cleo doesn't recognize it. The key binder is normal. Does anyone know what causes this? Why doesn't register_client_command catch the command when used as keybind?
 
  • Эм
Реакции: Bili Djin

Mason_Taylor

Новичок
10
1
CLEO:
{$CLEO}
{$INCLUDE SF}
0000:
IF AND
8B8C:  not    samp is_cursor_active
00DF:  actor $PLAYER_ACTOR driving
THEN

if
047A: actor $PLAYER_ACTOR driving_bike
then
03C0: 1@ = actor $PLAYER_ACTOR car
02E3: 2@ = car 1@ speed
if
0031: 2@ >= 13.0
then
00D6: if or
0AB0:   key_pressed 70
0AB0:   key_pressed 13
then
0001: wait 450 ms
if 
80DF: not  actor $PLAYER_ACTOR driving
then
if
0039:  25@ == 1
then
0AF9: samp say_msg "/oldanim 1"
else
0AF9: samp say_msg "/anim 1"
end
0001: wait 200 ms
0C72: set_virtual_key 13 down 1
0001: wait 50 ms
0C72: set_virtual_key 13 down 0
end
end
end
end

if
00DF: actor $PLAYER_ACTOR driving_car
then
03C0: 1@ = actor $PLAYER_ACTOR car
02E3: 2@ = car 1@ speed
if
0031: 2@ >= 15.0
then
00D6: if or
0AB0:   key_pressed 70
0AB0:   key_pressed 13
then
0001: wait 200 ms
if 
not Actor.Driving($PLAYER_ACTOR)
then
if
0039:  25@ == 1
then
0AF9: samp say_msg "/oldanim 1"
else
0AF9: samp say_msg "/anim 1"
end
0001: wait 200 ms
0C72: set_virtual_key 13 down 1
0001: wait 50 ms
0C72: set_virtual_key 13 down 0
end
end
end
end

END
почему крашит? подскажите пожалуйста
wait 0 не написал
после include sf
 

artie

Участник
70
20
какой id у правого альта, несколько сайтов с ID облазил, там только левый есть
 
  • Эм
Реакции: qdIbp

!Sam#0235

Активный
119
40
Hi, I'm trying to create requests with the discord API, the main snippet I want to "rewrite" is this (.LUA)
Lua:
local encoding = require 'encoding' -- подключаем для корректной отправки русских букв
encoding.default = 'CP1251'
u8 = encoding.UTF8
local sampev = require 'lib.samp.events' -- подключаем для хука отправки ответа на диалог
local effil = require 'effil' -- для ассинхронных запросов

local url = 'URL'
local data = {
   ['content'] = '', -- текст (меняется через команду, так что можно оставить пустым)
   ['username'] = 'Sended from .lua script!', -- ник отправителя
   ['avatar_url'] = 'https://c.tenor.com/Z9mXH7-MlcsAAAAS/sexy-black-man-thirst-trap.gif', -- ссылка на аватарку (можно убрать, будет дефолтная)
   ['tts'] = false, -- tts - text to speech - читалка сообщений (true/false)
   -- так же можно сделать еще много чего, подробнее тут: https://discord.com/developers/docs/resources/webhook
}

function main()
   while not isSampAvailable() do wait(0) end
   sampRegisterChatCommand('ds.msg', function(arg)
      data['username'] = sampGetPlayerNickname(select(2, sampGetPlayerIdByCharHandle(PLAYER_PED))) -- ник отправителя = ник в игре
      data['content'] = arg -- делаем что бы текст сообщения был равен тексту который мы ввели после команды
      -- отправляем запрос
      asyncHttpRequest('POST', url, {headers = {['content-type'] = 'application/json'}, data = u8(encodeJson(data))},
      function(response)
         print('[WebHook] [OK] отправлено!')
      end,
      function(err)
         print('[WebHook] [ERROR] error: '..err)
      end)
   end)
   wait(-1)
end

-- функция для отправки ассинхронных сообщений
function asyncHttpRequest(method, url, args, resolve, reject)
   local request_thread = effil.thread(function (method, url, args)
      local requests = require 'requests'
      local result, response = pcall(requests.request, method, url, args)
      if result then
         response.json, response.xml = nil, nil
         return true, response
      else
         return false, response
      end
   end)(method, url, args)
   -- Если запрос без функций обработки ответа и ошибок.
   if not resolve then resolve = function() end end
   if not reject then reject = function() end end
   -- Проверка выполнения потока
   lua_thread.create(function()
      local runner = request_thread
      while true do
         local status, err = runner:status()
         if not err then
            if status == 'completed' then
               local result, response = runner:get()
               if result then
                  resolve(response)
               else
                  reject(response)
               end
               return
            elseif status == 'canceled' then
               return reject(status)
            end
         else
            return reject(err)
         end
         wait(0)
      end
   end)
end
I tried to follow the example of this thread, but it doesn't work, what's wrong?
CLEO:
{$CLEO}
0000: NOP

repeat
    wait 0
until 0AFA:

// host
alloc 0@ 30
0AD3: 0@ = format "discord.com"

// path
alloc 1@ 200
0AD3: 1@ = format "api/webhooks/1015806219421757530/a21OfargEvfX7D2B5irPX0Bf_sAqqQGBV8lrpbciUUB6TFE16_TSwLq0pVA3MD-COfF_"

// data
alloc 2@ 1000
//0AD3: 2@ = format "content=testing message"
0AD3: 2@ = format "content=testing message&username=custom_username"

// response buffer
alloc 3@ 1500

while true
    wait 0
    if
    0ADC: "X"
    then
        0AB1: call_scm_func @HTTP_POST 5 host 0@ file_path 1@ response_buffer 3@ data 2@ is_https true _ret_is_success 31@
        if
        31@ == true
        then
            chatmsg "Respuesta = %s" 0xFFFFFF 3@
        else
            chatmsg "Fail" -1
        end
    end
end


{$INCLUDE includes/http_requests.txt}
http_requests.txt
 

halfastrc

Участник
33
4
How to get a specific word in the chat and after send a command? For example, when the word "Salario" appear in chat, send this 0AF9: samp say_msg "/caixinha"
 

Bili Djin

Активный
137
67

какой id у правого альта, несколько сайтов с ID облазил, там только левый есть
165

How to get a specific word in the chat and after send a command? For example, when the word "Salario" appear in chat, send this 0AF9: samp say_msg "/caixinha"
This is done via HOOK. I made a short code example that I didn't check. I hope you understand and the code will work! If you have any questions about how and what works, please contact us.

CLEO:
:main
wait 0
0BE3: raknet setup_incoming_rpc_hook @Hook_STR
4@ == 1
jf @main
4@ = 0
8C29:   not 24@ = stristr string1 23@ string2 "Salario"
jf @code
jump @main

:code
say "/caixinha"
jump @main


:Hook_STR
wait 0
0BE5: raknet 6@ = get_hook_param PARAM_PACKETID
if
6@ == RPC_ScrClientMessage
then
    0BE5: raknet 5@ = get_hook_param PARAM_BITSTREAM
    0BE7: raknet 7@ = bit_stream_read 5@ type BS_TYPE_INT
    0BE7: raknet 8@ = bit_stream_read 5@ type BS_TYPE_INT
    alloc 23@ 512
    4@ = 1
    0BE8: raknet bit_stream 5@ read_array 23@ size 8@
    0C0F: array 23@ element 8@ = 0x00
end
0BE0: raknet hook_ret true
 
Последнее редактирование:
  • Нравится
Реакции: halfastrc

halfastrc

Участник
33
4


165


This is done via HOOK. I made a short code example that I didn't check. I hope you understand and the code will work! If you have any questions about how and what works, please contact us.

CLEO:
:main
wait 0
0BE3: raknet setup_incoming_rpc_hook @Hook_STR
4@ == 1
jf @main
4@ = 0
8C29:   not 24@ = stristr string1 23@ string2 "Salario"
jf @code
jump @main

:code
say "/caixinha"
jump @main


:Hook_STR
wait 0
0BE5: raknet 6@ = get_hook_param PARAM_PACKETID
if
6@ == RPC_ScrClientMessage
then
    0BE5: raknet 5@ = get_hook_param PARAM_BITSTREAM
    0BE7: raknet 7@ = bit_stream_read 5@ type BS_TYPE_INT
    0BE7: raknet 8@ = bit_stream_read 5@ type BS_TYPE_INT
    alloc 23@ 512
    4@ = 1
    0BE8: raknet bit_stream 5@ read_array 23@ size 8@
    0C0F: array 23@ element 8@ = 0x00
end
0BE0: raknet hook_ret true
There's any way to do this, but without Sampfuncs?

Something like this

CLEO:
{$CLEO .cs}

0000: NOP

REPEAT
    WAIT 0
UNTIL 0AFA:

WHILE TRUE
    WAIT 0
    IF 0C29: $NOT_USED = stristr string1 0@ string2 "Salario"
    THEN
        0AF9: samp say_msg "/caixinha"
        WAIT 5000
    END
END
    
SAMP.CmdRet()
 
Последнее редактирование:

Bili Djin

Активный
137
67
There's any way to do this, but without Sampfuncs?

Something like this

CLEO:
{$CLEO .cs}

0000: NOP

REPEAT
    WAIT 0
UNTIL 0AFA:

WHILE TRUE
    WAIT 0
    IF 0C29: $NOT_USED = stristr string1 0@ string2 "Salario"
    THEN
        0AF9: samp say_msg "/caixinha"
        WAIT 5000
    END
END
   
SAMP.CmdRet()

I made the script check the last line (99) in the WHILE loop. That is, this means that in the case of a flood or sending 2 messages with zero delay, the script may not see a certain word.
CLEO:
0000: NOP

REPEAT
    WAIT 0
UNTIL 0AFA:

alloc 0@ 228

WHILE TRUE
    WAIT 0
    0B75: samp get_chat_string 99 text_to 0@ prefix_to 0 color_to 0 prefix_color_to 0
    IF 0C29: $NOT_USED = stristr string1 0@ string2 "Salario"
    THEN
        0AF9: samp say_msg "/caixinha"
        WAIT 5000
    END
END
   
SAMP.CmdRet()
 
  • Нравится
Реакции: halfastrc

RedBoxWhite

Известный
337
27
I made the script check the last line (99) in the WHILE loop. That is, this means that in the case of a flood or sending 2 messages with zero delay, the script may not see a certain word.
CLEO:
0000: NOP

REPEAT
    WAIT 0
UNTIL 0AFA:

alloc 0@ 228

WHILE TRUE
    WAIT 0
    0B75: samp get_chat_string 99 text_to 0@ prefix_to 0 color_to 0 prefix_color_to 0
    IF 0C29: $NOT_USED = stristr string1 0@ string2 "Salario"
    THEN
        0AF9: samp say_msg "/caixinha"
        WAIT 5000
    END
END
  
SAMP.CmdRet()
Он же вроде попросил без сампфункса, но тут всё равно используются функции сф