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

Общая тема для вопросов по разработке скриптов на языке программирования Lua, в частности под MoonLoader.
  • Задавая вопрос, убедитесь, что его нет в списке частых вопросов и что на него ещё не отвечали (воспользуйтесь поиском).
  • Поищите ответ в теме посвященной разработке Lua скриптов в MoonLoader
  • Отвечая, убедитесь, что ваш ответ корректен.
  • Старайтесь как можно точнее выразить мысль, а если проблема связана с кодом, то обязательно прикрепите его к сообщению, используя блок [code=lua]здесь мог бы быть ваш код[/code].
  • Если вопрос связан с MoonLoader-ом первым делом желательно поискать решение на wiki.

Частые вопросы

Как научиться писать скрипты? С чего начать?
Информация - Гайд - Всё о Lua скриптинге для MoonLoader(https://blast.hk/threads/22707/)
Как вывести текст на русском? Вместо русского текста у меня какие-то каракули.
Изменить кодировку файла скрипта на Windows-1251. В Atom: комбинация клавиш Ctrl+Shift+U, в Notepad++: меню Кодировки -> Кодировки -> Кириллица -> Windows-1251.
Как получить транспорт, в котором сидит игрок?
Lua:
local veh = storeCarCharIsInNoSave(PLAYER_PED)
Как получить свой id или id другого игрока?
Lua:
local _, id = sampGetPlayerIdByCharHandle(PLAYER_PED) -- получить свой ид
local _, id = sampGetPlayerIdByCharHandle(ped) -- получить ид другого игрока. ped - это хендл персонажа
Как проверить, что строка содержит какой-то текст?
Lua:
if string.find(str, 'текст', 1, true) then
-- строка str содержит "текст"
end
Как эмулировать нажатие игровой клавиши?
Lua:
local game_keys = require 'game.keys' -- где-нибудь в начале скрипта вне функции main

setGameKeyState(game_keys.player.FIREWEAPON, -1) -- будет сэмулировано нажатие клавиши атаки
Все иды клавиш находятся в файле moonloader/lib/game/keys.lua.
Подробнее о функции setGameKeyState здесь: lua - setgamekeystate | BlastHack — DEV_WIKI(https://www.blast.hk/wiki/lua:setgamekeystate)
Как получить id другого игрока, в которого целюсь я?
Lua:
local valid, ped = getCharPlayerIsTargeting(PLAYER_HANDLE) -- получить хендл персонажа, в которого целится игрок
if valid and doesCharExist(ped) then -- если цель есть и персонаж существует
  local result, id = sampGetPlayerIdByCharHandle(ped) -- получить samp-ид игрока по хендлу персонажа
  if result then -- проверить, прошло ли получение ида успешно
    -- здесь любые действия с полученным идом игрока
  end
end
Как зарегистрировать команду чата SAMP?
Lua:
-- До бесконечного цикла/задержки
sampRegisterChatCommand("mycommand", function (param)
     -- param будет содержать весь текст введенный после команды, чтобы разделить его на аргументы используйте string.match()
    sampAddChatMessage("MyCMD", -1)
end)
Крашит игру при вызове sampSendChat. Как это исправить?
Это происходит из-за бага в SAMPFUNCS, когда производится попытка отправки пакета определенными функциями изнутри события исходящих RPC и пакетов. Исправления для этого бага нет, но есть способ не провоцировать его. Вызов sampSendChat изнутри обработчика исходящих RPC/пакетов нужно обернуть в скриптовый поток с нулевой задержкой:
Lua:
function onSendRpc(id)
  -- крашит:
  -- sampSendChat('Send RPC: ' .. id)

  -- норм:
  lua_thread.create(function()
    wait(0)
    sampSendChat('Send RPC: ' .. id)
  end)
end
 
Последнее редактирование:

7 СМЕРТНЫХ ГРЕХОВ

пісюнковий злочинець
527
165
В чем может быть ошибка ?
Бывает моментами выдает ошибку на строку - raknetBitStreamIgnoreBits(bs, 8)
in function 'raknetBitStreamIgnoreBits'
...es\projects\crmp\moonloader\POHYI FLOODER by 7sg (7).lua:408: in function <...es\projects\crmp\moonloader\POHYI FLOODER by 7sg (7).lua:406>
[22:27:18.275333] (error) POHUY FLOODER: Script died due to an error. (id:6)


LUA:
local bytes = { 2, 0, 0, 0, 0, 0, 16, 0, 0, 0, 79, 110, 68, 105, 97, 108, 111, 103, 82, 101, 115, 112, 111, 110, 115, 101, 8, 0, 0, 0, 100, 0, 0, 0, 0, 100 }
function onReceivePacket(id, bs)
    lua_thread.create(function()
        if id == 215 and skip[0] then
            raknetBitStreamIgnoreBits(bs, 8)
            if raknetBitStreamReadInt16(bs) == 2 then
                raknetBitStreamReadInt32(bs)
                local e = {}
                for i = 1, raknetBitStreamReadInt8(bs) do
                    local l = raknetBitStreamReadInt32(bs)
                    table.insert(e, raknetBitStreamReadString(bs, l))
                end
                if table.getn(e) > 0 then
                    local text = e[1]
                    if skip_tape_1[0] then
                        if text:find("") then
                            sendDialogResponse(1,0,'by 7sg')
                            return false
                        end
                    end
                    if skip_tape_2[0] then
                        if text:find("") then
                            local bs = raknetNewBitStream()
                            raknetBitStreamWriteInt8(bs, 215)
                            for i = 1, #bytes do
                                raknetBitStreamWriteInt8(bs, bytes[i])
                            end
                            raknetBitStreamWriteInt32(bs, 1)
                            raknetBitStreamWriteInt8(bs, 100)
                            raknetBitStreamWriteInt32(bs, 0)
                            raknetBitStreamWriteInt8(bs, 115)
                            raknetBitStreamWriteInt32(bs, 8)
                            raknetSendBitStreamEx(bs, 1, 7, 1)
                            raknetDeleteBitStream(bs)
                        end
                    end
                end
            end
        end
    end)
end
 

Oki_Bern

Участник
287
7
Как ускорить анимацию, которая воспроизводится через taskPlayAnime не визуально
 
Последнее редактирование:

dmitry.karle

Известный
364
101
В чем может быть ошибка ?
Бывает моментами выдает ошибку на строку - raknetBitStreamIgnoreBits(bs, 8)
in function 'raknetBitStreamIgnoreBits'
...es\projects\crmp\moonloader\POHYI FLOODER by 7sg (7).lua:408: in function <...es\projects\crmp\moonloader\POHYI FLOODER by 7sg (7).lua:406>
[22:27:18.275333] (error) POHUY FLOODER: Script died due to an error. (id:6)


LUA:
local bytes = { 2, 0, 0, 0, 0, 0, 16, 0, 0, 0, 79, 110, 68, 105, 97, 108, 111, 103, 82, 101, 115, 112, 111, 110, 115, 101, 8, 0, 0, 0, 100, 0, 0, 0, 0, 100 }
function onReceivePacket(id, bs)
    lua_thread.create(function()
        if id == 215 and skip[0] then
            raknetBitStreamIgnoreBits(bs, 8)
            if raknetBitStreamReadInt16(bs) == 2 then
                raknetBitStreamReadInt32(bs)
                local e = {}
                for i = 1, raknetBitStreamReadInt8(bs) do
                    local l = raknetBitStreamReadInt32(bs)
                    table.insert(e, raknetBitStreamReadString(bs, l))
                end
                if table.getn(e) > 0 then
                    local text = e[1]
                    if skip_tape_1[0] then
                        if text:find("") then
                            sendDialogResponse(1,0,'by 7sg')
                            return false
                        end
                    end
                    if skip_tape_2[0] then
                        if text:find("") then
                            local bs = raknetNewBitStream()
                            raknetBitStreamWriteInt8(bs, 215)
                            for i = 1, #bytes do
                                raknetBitStreamWriteInt8(bs, bytes[i])
                            end
                            raknetBitStreamWriteInt32(bs, 1)
                            raknetBitStreamWriteInt8(bs, 100)
                            raknetBitStreamWriteInt32(bs, 0)
                            raknetBitStreamWriteInt8(bs, 115)
                            raknetBitStreamWriteInt32(bs, 8)
                            raknetSendBitStreamEx(bs, 1, 7, 1)
                            raknetDeleteBitStream(bs)
                        end
                    end
                end
            end
        end
    end)
end
Lua:
local bytes = { 2, 0, 0, 0, 0, 0, 16, 0, 0, 0, 79, 110, 68, 105, 97, 108, 111, 103, 82, 101, 115, 112, 111, 110, 115, 101, 8, 0, 0, 0, 100, 0, 0, 0, 0, 100 }

function onReceivePacket(id, bs)
    lua_thread.create(function()
        if id == 215 and skip[0] then
            local originalPos = raknetBitStreamGetReadOffset(bs)
            
            raknetBitStreamIgnoreBits(bs, 8)
            local packetType = raknetBitStreamReadInt16(bs)
            
            if packetType == 2 then
                raknetBitStreamReadInt32(bs)
                
                local e = {}
                local count = raknetBitStreamReadInt8(bs)
                
                if count > 0 and count < 100 then
                    for i = 1, count do
                        local l = raknetBitStreamReadInt32(bs)
                        if l > 0 and l < 4096 then
                            table.insert(e, raknetBitStreamReadString(bs, l))
                        else
                            raknetBitStreamSetReadOffset(bs, originalPos)
                            return false
                        end
                    end
                    
                    if #e > 0 then
                        local text = e[1]
                        
                        if skip_tape_1[0] and text:find("") then
                            sendDialogResponse(1, 0, 'by 7sg')
                            return false
                        end
                        
                        if skip_tape_2[0] and text:find("") then
                            local responseBs = raknetNewBitStream()
                            
                            raknetBitStreamWriteInt8(responseBs, 215)
                            
                            for _, byte in ipairs(bytes) do
                                raknetBitStreamWriteInt8(responseBs, byte)
                            end
                            
                            raknetBitStreamWriteInt32(responseBs, 1)
                            raknetBitStreamWriteInt8(responseBs, 100)
                            raknetBitStreamWriteInt32(responseBs, 0)
                            raknetBitStreamWriteInt8(responseBs, 115)
                            raknetBitStreamWriteInt32(responseBs, 8)
                            
                            raknetSendBitStreamEx(responseBs, 1, 7, 1)
                            raknetDeleteBitStream(responseBs)
                        end
                    end
                end
            else
                raknetBitStreamSetReadOffset(bs, originalPos)
            end
        end
    end)
end
 

7 СМЕРТНЫХ ГРЕХОВ

пісюнковий злочинець
527
165
Lua:
local bytes = { 2, 0, 0, 0, 0, 0, 16, 0, 0, 0, 79, 110, 68, 105, 97, 108, 111, 103, 82, 101, 115, 112, 111, 110, 115, 101, 8, 0, 0, 0, 100, 0, 0, 0, 0, 100 }

function onReceivePacket(id, bs)
    lua_thread.create(function()
        if id == 215 and skip[0] then
            local originalPos = raknetBitStreamGetReadOffset(bs)
           
            raknetBitStreamIgnoreBits(bs, 8)
            local packetType = raknetBitStreamReadInt16(bs)
           
            if packetType == 2 then
                raknetBitStreamReadInt32(bs)
               
                local e = {}
                local count = raknetBitStreamReadInt8(bs)
               
                if count > 0 and count < 100 then
                    for i = 1, count do
                        local l = raknetBitStreamReadInt32(bs)
                        if l > 0 and l < 4096 then
                            table.insert(e, raknetBitStreamReadString(bs, l))
                        else
                            raknetBitStreamSetReadOffset(bs, originalPos)
                            return false
                        end
                    end
                   
                    if #e > 0 then
                        local text = e[1]
                       
                        if skip_tape_1[0] and text:find("") then
                            sendDialogResponse(1, 0, 'by 7sg')
                            return false
                        end
                       
                        if skip_tape_2[0] and text:find("") then
                            local responseBs = raknetNewBitStream()
                           
                            raknetBitStreamWriteInt8(responseBs, 215)
                           
                            for _, byte in ipairs(bytes) do
                                raknetBitStreamWriteInt8(responseBs, byte)
                            end
                           
                            raknetBitStreamWriteInt32(responseBs, 1)
                            raknetBitStreamWriteInt8(responseBs, 100)
                            raknetBitStreamWriteInt32(responseBs, 0)
                            raknetBitStreamWriteInt8(responseBs, 115)
                            raknetBitStreamWriteInt32(responseBs, 8)
                           
                            raknetSendBitStreamEx(responseBs, 1, 7, 1)
                            raknetDeleteBitStream(responseBs)
                        end
                    end
                end
            else
                raknetBitStreamSetReadOffset(bs, originalPos)
            end
        end
    end)
end
А в чем проблема была в старой ?
 

BRA22ERS

Новичок
5
0
Подскажите в чем может быть проблема, хочу сделать, чтобы скрипт не флудил для этого сделал "флаги". То есть при появлении сообщения о покупке isBuy становился false, а isSell true и наоборот. Но все равно флудит.

lua:
require('moonloader')
local sampev = require('samp.events')

local prods = false
local isBuy = true
local isSell = false

local locations = {

    -- /buyprods LS
    {x = 2716.2505, y = -2404.0786, z = 13.6413, command = "/buyprods", radius = 18},
    {x = 2411.0034, y = -1972.9319, z = 1001.0859, command = "/buyprods", radius = 12},
 

    -- /sellprods 24/7 №5
    {x = 2401.0298, y = -1980.0492, z = 13.7215, command = "/sellprods", radius = 15},
    {x = -2157.0566, y = -247.0761, z = 36.5156, command = "/sellprods", radius = 1.5},
    {x = -2157.6450, y = -247.0761, z = 36.5156, command = "/sellprods", radius = 1.5},
    {x = -2158.1047, y = -247.0761, z = 36.5156, command = "/sellprods", radius = 1.5}
}

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampAddChatMessage('{696969}[AutoBuySell] {ffffff}загружен. Активация | деактивация - {32CD32}/bsprods', -1)
    sampRegisterChatCommand('bsprods', function()
      prods = not prods
      sampAddChatMessage(prods and '{696969}[AutoBuySell]: {32CD32}Активирован' or '{696969}[AutoBuySell]: {B22222}Деактивирован', -1)
    end)

    while true do wait(0)
    if prods then
        local player = playerPed 
        if doesCharExist(player) then
            local playerX, playerY, playerZ = getCharCoordinates(player)

            for _, loc in ipairs(locations) do
                local distance = getDistanceBetweenCoords3d(playerX, playerY, playerZ, loc.x, loc.y, loc.z)
                
                if distance < loc.radius then
                    if isBuy then
                            sampSendChat(loc.command)
                            wait(1000)
                    end
                    if isSell then
                            sampSendChat(loc.command)
                            wait(1000)
                        end
                    end
                end
            end
        end
    end
  end

  function sampev.onServerMessage(color, text)
    if text:find("Продуктов в фургоне:") then
        isBuy = false
        isSell = true
    end
   if text:find("Империя: Ваш грузовик пуст, отправляйтесь на базу продуктов!") then
        isBuy = true
        isSell = false
    end
end
 

Dmitriy Makarov

25.05.2021
Проверенный
2,514
1,140
мб кто-то знает, как через mimgui вывести круговое меню?
@chapo
Попробуй вот это
 

dmitry.karle

Известный
364
101
мб кто-то знает, как через mimgui вывести круговое меню?
@chapo
 

copypaste_scripter

Известный
1,418
288
есть скрипт мини бота, который бежит по точкам и жмет альт
пользую анти афк от АИРа на лаунчере арз
можно как то сделать, чтобы скрипт в свернутом режиме работал и в другом игре где я играю не нажимался альт?
 

mango mango

Новичок
8
1
помогите, в чем проблема. автоответ репорта не реагирует на саму жалобу и не отвечает

Lua:
local sampev = require 'lib.samp.events'

local otvet = {
    [1] = 'Уточните свой запрос!',
    [2] = 'РП процесс!',
    [3] = 'Приятной игры на OnlineRP!',
    [4] = 'Ваш вопрос вы можете задать в /ask',
    [5] = 'Не телепортируем!',
    [6] = 'Про админку можете узнать в /faq - 16',
    [7] = 'Не спавним просто так!',
    [8] = 'Ждите.',
    [9] = 'Причина всегда указывается',
    [10] = 'Вы со временем сами выйдете',
    [11] = 'Подробнее про фракцици написано в /faq - 9',
    [12] = 'Скины не даем.',
    [13] = 'Обратитесь в тех.раздел на форуме!',
    [14] = 'Если машин нет - они заняты. Ожидайте',
    [15] = 'Промокоды ищите на YouTube',
    [16] = 'Посмотреть оставшееся время заключения - /time',
    [17] = 'Команда /supports больше не существует. Введите /admins'
}
local reports = {
    [1] = '[Пп][оа]могите$',
    [2] = '.*[Уу]пал%s[УуВв]%s[воде|воду].*',
    [3] = '.*[Сс][Пп][оа]сиб[оа].*',
    [4] = '.*[Зз][оа]чем.*',
    [5] = '[Тт][Пп].*',
    [6] = '.*[Пп]очин.*',
    [7] = '.*[Пп]омгите.*',
    [8] = '.*[Аа]дминку.*',
    [10] = '[spawn|спавн]$',
    [12] = '[Сс]пасите.*',
    [13] = '.*[за что|почему].*посадили.*',
    [14] = '[Пп]ривет.*',
    [15] = '[Кк]огда.*',
    [16] = '[Кк]ак.*',
    [17] = '.*[Бб]лагодар.*',
    [18] = '.*[Вв]ыпусти.*',
    [19] = 'не.*могу%s[двигатся|ходить].*',
    [20] = '.*[смену|смените]%sник.*',
    [21] = '[Гг]де.*',
    [22] = '.*[Уу]тонул.*',
    [23] = '.*[Сс]пс.*',
    [24] = '.*[Сс]обес.*',
    [25] = '[Зз]астрял',
    [26] = '.*[Дд]айте.*скин.*',
    [27] = '[Бб]аг$',
    [28] = '%d+$',
    [29] = '[Пп]очему.*',
    [30] = '[Сс]павн [кар|машин].*',
    [31] = '[Пр]омокод.*',
    [32] = '[сколько|cкок]%s[сидеть|призон|дмг].*',
    [33] = '/supports.*',
}
function sampev.omServerMessage(color, text)
    if active then
        if text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[1]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[1]) then
            sampAddChatMessage(text..' Reports: 1', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[1])
            sampSendChat('/pm '..igrok_nick..' '..otvet[1])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[2]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[2]) then
            sampAddChatMessage(text..' Reports: 2', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[2])
            sampSendChat('/pm '..igrok_nick..' '..otvet[2])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[3]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[3]) then
            sampAddChatMessage(text..' Reports: 3', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[3])
            sampSendChat('/pm '..igrok_nick..' '..otvet[3])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[4]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[4]) then
            sampAddChatMessage(text..' Reports: 4', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[4])
            sampSendChat('/pm '..igrok_nick..' '..otvet[4])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[5]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[5]) then
            sampAddChatMessage(text..' Reports: 5', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[5])
            sampSendChat('/pm '..igrok_nick..' '..otvet[5])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[6]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[6]) then
            sampAddChatMessage(text..' Reports: 6', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[6])
            sampSendChat('/pm '..igrok_nick..' '..otvet[2])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[7]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[7]) then
            sampAddChatMessage(text..' Reports: 7', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[7])
            sampSendChat('/pm '..igrok_nick..' '..otvet[1])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[8]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[8]) then
            sampAddChatMessage(text..' Reports: 8', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[8])
            sampSendChat('/pm '..igrok_nick..' '..otvet[6])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[10]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[10]) then
            sampAddChatMessage(text..' Reports: 10', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[10])
            sampSendChat('/pm '..igrok_nick..' '..otvet[7])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[12]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[12]) then
            sampAddChatMessage(text..' Reports: 12', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[12])
            sampSendChat('/pm '..igrok_nick..' '..otvet[1])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[13]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[13]) then
            sampAddChatMessage(text..' Reports: 13', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[13])
            sampSendChat('/pm '..igrok_nick..' '..otvet[9])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[14]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[14]) then
            sampAddChatMessage(text..' Reports: 14', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[14])
            sampSendChat('/pm '..igrok_nick..' '..otvet[3])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[15]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[15]) then
            sampAddChatMessage(text..' Reports: 15', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[15])
            sampSendChat('/pm '..igrok_nick..' '..otvet[8])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[16]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[16]) then
            sampAddChatMessage(text..' Reports: 16', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[16])
            sampSendChat('/pm '..igrok_nick..' '..otvet[4])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[17]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[17]) then
            sampAddChatMessage(text..' Reports: 17', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[17])
            sampSendChat('/pm '..igrok_nick..' '..otvet[3])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[18]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[18]) then
            sampAddChatMessage(text..' Reports: 18', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[18])
            sampSendChat('/pm '..igrok_nick..' '..otvet[10])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[19]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[19]) then
            sampAddChatMessage(text..' Reports: 19', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[19])
            lua_thread.create(function ()
                sampSendChat('/pm '..igrok_nick..' '..otvet[3])
                wait(1000)
                sampSendChat('/unfreeze '..igrok_nick)
            end)
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[20]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[20]) then
            sampAddChatMessage(text..' Reports: 20', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[20])
            sampSendChat('/pm '..igrok_nick..' '..otvet[8])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[21]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[21]) then
            sampAddChatMessage(text..' Reports: 21', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[21])
            sampSendChat('/pm '..igrok_nick..' '..otvet[4])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[22]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[22]) then
            sampAddChatMessage(text..' Reports: 22', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[22])
            sampSendChat('/pm '..igrok_nick..' '..otvet[2])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[23]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[23]) then
            sampAddChatMessage(text..' Reports: 23', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[23])
            sampSendChat('/pm '..igrok_nick..' '..otvet[3])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[24]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[24]) then
            sampAddChatMessage(text..' Reports: 24', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[24])
            sampSendChat('/pm '..igrok_nick..' '..otvet[11])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[25]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[25]) then
            sampAddChatMessage(text..' Reports: 25', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[25])
            sampSendChat('/pm '..igrok_nick..' '..otvet[1])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[26]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[26]) then
            sampAddChatMessage(text..' Reports: 26', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[26])
            sampSendChat('/pm '..igrok_nick..' '..otvet[12])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[27]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[27]) then
            sampAddChatMessage(text..' Reports: 27', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[27])
            sampSendChat('/pm '..igrok_nick..' '..otvet[13])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[28]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[28]) then
            sampAddChatMessage(text..' Reports: 28', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[28])
            sampSendChat('/pm '..igrok_nick..' '..otvet[1])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[29]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[29]) then
            sampAddChatMessage(text..' Reports: 29', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[29])
            sampSendChat('/pm '..igrok_nick..' '..otvet[4])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[30]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[30]) then
            sampAddChatMessage(text..' Reports: 30', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[30])
            sampSendChat('/pm '..igrok_nick..' '..otvet[14])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[31]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[31]) then
            sampAddChatMessage(text..' Reports: 31', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[31])
            sampSendChat('/pm '..igrok_nick..' '..otvet[15])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[32]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[32]) then
            sampAddChatMessage(text..' Reports: 32', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[32])
            sampSendChat('/pm '..igrok_nick..' '..otvet[16])
        elseif text:find('%[Жалоба%] (.*)%[%d+%]:%s'..reports[33]) and not text:find('%[Жалоба%] Оск/Реклама (.*)%[%d+%]:%s'..reports[33]) then
            sampAddChatMessage(text..' Reports: 33', -1)
            igrok_nick = text:match('%[Жалоба%] (.*)%[%d+%]:%s'..reports[33])
            sampSendChat('/pm '..igrok_nick..' '..otvet[17])   
        end
    end
end
local active = false

function main()

    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
        sampRegisterChatCommand("vkll", function ()
            active = not active
            if active then
                sampAddChatMessage("Автоответчик успешно активирован", -1)
            else
                sampAddChatMessage("Автоответчик деактивирован", -1)
            end
        end)
        while true do
            wait(0)
    end
end
 

Oleg1337228

Участник
377
18
кто разбирается можете пожалуйста также добавить этому скрипту чтобы не только комманда была установить айди автомобиля но и поменять само значение высоты в самой игре, а не в файле буду очень благодарен.

либо дайте альтернативу если есть что то лучше, спасибо
 

Вложения

  • Подгон модели машины .lua
    845 байт · Просмотры: 2

dmitry.karle

Известный
364
101
кто разбирается можете пожалуйста также добавить этому скрипту чтобы не только комманда была установить айди автомобиля но и поменять само значение высоты в самой игре, а не в файле буду очень благодарен.

либо дайте альтернативу если есть что то лучше, спасибо
типа так? Не тестил

Lua:
script_author('FunnyRofl')

local Car_Model = 16896

local Height = 0.7

function SetCarHeight(vehicle, height)
    local x, y, z = getCarCoordinates(vehicle)
    setCarCoordinates(vehicle, x, y, z + height)
end

require('lib.samp.events').onSendVehicleSync = function(data)
    if isCharInAnyCar(PLAYER_PED) then
        local vehicle = storeCarCharIsInNoSave(PLAYER_PED)
        if (getCarModel(vehicle) == Car_Model) then
            SetCarHeight(vehicle, Height)
            local offsetX, offsetY, offsetZ = getOffsetFromCarInWorldCoords(vehicle, 0, 0, Height)
            data.position = {offsetX, offsetY, offsetZ}
        end
    end
end

sampRegisterChatCommand("car.id", function()
    if isCharInAnyCar(PLAYER_PED) then
        local a = getCarModel(storeCarCharIsInNoSave(PLAYER_PED))
        sampAddChatMessage("Текущий ID автомобиля: "..tostring(a), -1)
    else
        sampAddChatMessage("Вы не в автомобиле", -1)
    end
end)

sampRegisterChatCommand("car.height", function(x)
    local newHeight = tonumber(x)
    if newHeight then
        Height = newHeight
        sampAddChatMessage("Высота установлена на: "..tostring(Height), -1)
        if isCharInAnyCar(PLAYER_PED) then
            local vehicle = storeCarCharIsInNoSave(PLAYER_PED)
            if (getCarModel(vehicle) == Car_Model) then
                SetCarHeight(vehicle, Height)
            end
        end
    else
        sampAddChatMessage("Использование: /car.height [значение]", -1)
        sampAddChatMessage("Текущая высота: "..tostring(Height), -1)
    end
end)
 

Орк

Известный
339
304
Как в monetloader закрыть диалог? sampCloseCurrentDialogWithButton(0) такой функции в monetloader не существует
sampSendDialogResponse(sampGetCurrentDialogId(), 1,0,-1) sampSendDialogResponse(sampGetCurrentDialogId(), 0,0,-1) тоже не закрывает