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
{$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}
0xA5, вот ссылка на сайт, откуда брал: тык.какой id у правого альта, несколько сайтов с ID облазил, там только левый есть
165какой id у правого альта, несколько сайтов с ID облазил, там только левый есть
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.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"
: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?
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
{$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()
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()
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()
Он же вроде попросил без сампфункса, но тут всё равно используются функции сф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()
Какую? Выход их команды?Он же вроде попросил без сампфункса, но тут всё равно используются функции сф
))) Все опкоды из SF, Ну разве что кроме allocate memory и 0000:Какую? Выход их команды?
Да я чёрт знает что из SF, что нет )))) Все опкоды из SF, Ну разве что кроме allocate memory и 0000:
Как отправить сообщение?
0BC9: samp send_dialog_response dialog 0@ button 1@ listitem 2@ input 3@
Parameters: UINT16 wDialogID, UINT8 bResponse, INT16 wListItem, UINT8 bTextLength, char[] Text
Я вчера пробовал так делать, то ли я тупой, то ли этот оркод работает, когда диалог открыт0BC9: samp send_dialog_response dialog 0@ button 1@ listitem 2@ input 3@
SendDialogResponse - 62