Вопросы по 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
 
Последнее редактирование:

штейн

Известный
Проверенный
1,001
687
Lua:
                                     if id == '9' then
                                     players = 0
                                     for id = 0, sampGetMaxPlayerId(false) do
                                     if sampIsPlayerConnected(id) then
                                         color = sampGetPlayerColor(id)
                                         if color == colcnn then
                                             sampSendChat("/masked "..id)
                                         break
                                     else
                                         if color ~= colcnn then
                                             sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                                          break
                                       end
                                    end
                                 end
                             end
                         end
почему даже если color == colcnn то он выполняет else?
 

trefa

Известный
Всефорумный модератор
2,097
1,231
Lua:
                                     if id == '9' then
                                     players = 0
                                     for id = 0, sampGetMaxPlayerId(false) do
                                     if sampIsPlayerConnected(id) then
                                         color = sampGetPlayerColor(id)
                                         if color == colcnn then
                                             sampSendChat("/masked "..id)
                                         break
                                     else
                                         if color ~= colcnn then
                                             sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                                          break
                                       end
                                    end
                                 end
                             end
                         end
почему даже если color == colcnn то он выполняет else?
С end накосячил
 

штейн

Известный
Проверенный
1,001
687
Lua:
             if id == '1' then
                players = 0
                for id = 0, sampGetMaxPlayerId(false) do
                if sampIsPlayerConnected(id) then
                    color = sampGetPlayerColor(id)
                    if color == collspd then
                    sampSendChat("/masked "..id)
                 break
              end
         end
    end
end

как тут сделать чтоб id в sampSendChat рандомный вводило, но не простой рандом, а только людей у которых будет color == collspd
 
  • Нравится
Реакции: CatKnight

imring

Ride the Lightning
Всефорумный модератор
2,355
2,517
Lua:
             if id == '1' then
                players = 0
                for id = 0, sampGetMaxPlayerId(false) do
                if sampIsPlayerConnected(id) then
                    color = sampGetPlayerColor(id)
                    if color == collspd then
                    sampSendChat("/masked "..id)
                 break
              end
         end
    end
end

как тут сделать чтоб id в sampSendChat рандомный вводило, но не простой рандом, а только людей у которых будет color == collspd
Lua:
math.randomseed(os.time())
local id = math.random(0, sampGetMaxPlayerId(false))
while sampGetPlayerColor(id) ~= collspd do wait(0) id = math.random(0, sampGetMaxPlayerId(false)) end
-- code
 
  • Нравится
Реакции: штейн

штейн

Известный
Проверенный
1,001
687
Lua:
                                     if id == '9' then
                                     players = 0
                                     for id = 0, sampGetMaxPlayerId(false) do
                                     if sampIsPlayerConnected(id) then
                                         color = sampGetPlayerColor(id)
                                         if color == colcnn then
                                             sampSendChat("/masked "..id)
                                         break
                                     else
                                         if color ~= colcnn then
                                             sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                                          break
                                       end
                                    end
                                 end
                             end
                         end
почему даже если color == colcnn то он выполняет else?

может таки поможет кто, энды пытался переставить но чет не оч
 

for (;;)

Участник
71
31
может таки поможет кто, энды пытался переставить но чет не оч
Lua:
if id == "9" then
    players = 0
    for id = 0, sampGetMaxPlayerId(false) do
        if sampIsPlayerConnected(id) then
            color = sampGetPlayerColor(id)
            if color == colcnn then
                sampSendChat("/masked "..id)
                players = players + 1
                break
            end
        end
    end
    if players == 0 then
        sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
    end
end
 
  • Нравится
Реакции: штейн

BND / PLP

Новичок
84
4
Lua:
if li == 1 then sampShowDialog(1000, ("huina"), huina, "{ffffff}Далее", "{ffffff}Закрыть", 2) end
напиши полностью, а то не робит когда второй раз юзаю sampHasDialogRespond

Lua:
function main()
  if not isSampfuncsLoaded() or not isSampLoaded() then return end
  while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("dialog", dialog)
    while true do
        wait(0)
        local result, button, list, input = sampHasDialogRespond(1233)
        if result == true then
            if button == 1 then
                if list == 0 then
                    sampShowDialog(1544, "caption1", "1\n2\n3\0", "close", "", 2)
                    local result, button, list, input = sampHasDialogRespond(1544)
                    if result == true then
                        if buttion == 1 then
                            if list == 0 then
                                sampAddChatMessage("bla bla bla 1", -1)
                            end
                            if list == 1 then
                                sampAddChatMessage("bla bla bla 2", -1)
                            end
                            if list == 2 then
                                sampAddChatMessage("bla bla bla 3", -1)
                            end
                        end
                    end
                end
                if list == 1 then
                    sampShowDialog(1355, "caption2", "1234567890", "Закрыть", "", 0)
                end
            end
        end
    end
end

function dialog()
    sampShowDialog(1233, "caption", "1\n2\0", "close", "", 2)
end
вот чекайте почему в чат не идут эти сообщения когда я в диалоге их выбираю
 
Последнее редактирование модератором:
1,417
1,029
напиши полностью, а то не робит когда второй раз юзаю sampHasDialogRespond

Lua:
function main()
  if not isSampfuncsLoaded() or not isSampLoaded() then return end
  while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("dialog", dialog)
    while true do
        wait(0)
        local result, button, list, input = sampHasDialogRespond(1233)
        if result == true then
            if button == 1 then
                if list == 0 then
                    sampShowDialog(1544, "caption1", "1\n2\n3\0", "close", "", 2)
                    local result, button, list, input = sampHasDialogRespond(1544)
                    if result == true then
                        if buttion == 1 then
                            if list == 0 then
                                sampAddChatMessage("bla bla bla 1", -1)
                            end
                            if list == 1 then
                                sampAddChatMessage("bla bla bla 2", -1)
                            end
                            if list == 2 then
                                sampAddChatMessage("bla bla bla 3", -1)
                            end
                        end
                    end
                end
                if list == 1 then
                    sampShowDialog(1355, "caption2", "1234567890", "Закрыть", "", 0)
                end
            end
        end
    end
end

function dialog()
    sampShowDialog(1233, "caption", "1\n2\0", "close", "", 2)
end
вот чекайте почему в чат не идут эти сообщения когда я в диалоге их выбираю
все sampHasDialogRespond должны быть в беск.цикле, юзай лучше готовую функцию от фипа, есть в сниппетах.
 

штейн

Известный
Проверенный
1,001
687
что я мог сделать, что при запуске гта вылезает ошибка

upload_2018-4-23_22-30-21.png


Lua:
    function scm(param)
        collspd = -1442814209
        colfbi = -1436129537
        colarmy = -1426807712
        colmz = -1426102682
        colcn = -1429419008
        colym = -1432813568
        colprvo = -1426063361
        colcnn = -1426076570
        coltm = -1442827418
        colsfpd = -1442840448
        colrm = -1439485133
        colgrv = -1442788352
        colbal = -1432813364
        colvag = -1426076621
        colazt = -1442775041
        colrif = -1439458919
        colar = -1436142848
        colstr = -1429418855
        colbik = -1432787354
        collvpd = -1442827418
        colpriz = -1439485184
        colvvs = -1442788199
        colvmf = -1439458970
        local id = string.match(param, '(%d+)')
        if id ~= nil then
             if id == "1" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= collspd do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             end
             if id == "2" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colfbi do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             end
             if id == "3" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colarmy do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "4" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colmz do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "5" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colcn do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "6" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colym do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "7" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colprvo do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "8" then
                              sampAddChatMessage("[ {800000}HitMan {ffffff}]: Маскировка невозможна. Причина: 8 ID фракции - {800000}Hitman Agency.", -1)
                     end
             if id == "9" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colcnn do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "10" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= coltm do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "11" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colsfpd do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "12" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colrm do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "13" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colgrv do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "14" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colbal do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "15" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colvag do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "16" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colazt do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "17" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colrif do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "18" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colar do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "19" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colstr do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "20" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colbik do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "21" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= collvpd do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "22" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colpriz do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "23" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colvvs do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "24" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colvmf do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
                 else
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Скины фракций - [ {800000}/scm {ffffff}].", -1)
                     sampAddChatMessage("[ {800000}1 {ffffff}] - LSPD; [ {800000}2 {ffffff}] - FBI; [ {800000}3 {ffffff}] - NGSA; [ {800000}4 {ffffff}] - МинЗдрав ..", -1)
                     sampAddChatMessage(".. [ {800000}5 {ffffff}] - Cosa Nostra; [ {800000}6 {ffffff}] - Yakuza; [ {800000}7 {ffffff}] - Правительство ..", -1)
                     sampAddChatMessage(".. [ {800000}8 {ffffff}] - None; [ {800000}9 {ffffff}] - CNN; [ {800000}10 {ffffff}] - Triada  ..", -1)
                     sampAddChatMessage(".. [ {800000}11 {ffffff}] - SFPD; [ {800000}12 {ffffff}] - Russia; [ {800000}13 {ffffff}] - Grove ..", -1)
                     sampAddChatMessage(".. [ {800000}14 {ffffff}] - Ballas; [ {800000}15 {ffffff}] - Vagos; [ {800000}16 {ffffff}] - Aztecas ..", -1)
                     sampAddChatMessage(".. [ {800000}17 {ffffff}] - Rifa; [ {800000}18 {ffffff}] - Arabian; [ {800000}19 {ffffff}] - Street Racers ..")
                     sampAddChatMessage(".. [ {800000}20 {ffffff}] - Bikers; [ {800000}21 {ffffff}] - LVPD ..", -1)
                     sampAddChatMessage(".. [ {800000}22 {ffffff}]- Призывник; [ {800000}23 {ffffff}] - ВВС; [ {800000}24 {ffffff}] - ВМФ.", -1)
                 end
 

itsLegend

Фонд борьбы за жуков 🐞
Администратор
2,696
1,460
что я мог сделать, что при запуске гта вылезает ошибка

Посмотреть вложение 13437

Lua:
    function scm(param)
        collspd = -1442814209
        colfbi = -1436129537
        colarmy = -1426807712
        colmz = -1426102682
        colcn = -1429419008
        colym = -1432813568
        colprvo = -1426063361
        colcnn = -1426076570
        coltm = -1442827418
        colsfpd = -1442840448
        colrm = -1439485133
        colgrv = -1442788352
        colbal = -1432813364
        colvag = -1426076621
        colazt = -1442775041
        colrif = -1439458919
        colar = -1436142848
        colstr = -1429418855
        colbik = -1432787354
        collvpd = -1442827418
        colpriz = -1439485184
        colvvs = -1442788199
        colvmf = -1439458970
        local id = string.match(param, '(%d+)')
        if id ~= nil then
             if id == "1" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= collspd do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             end
             if id == "2" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colfbi do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             end
             if id == "3" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colarmy do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "4" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colmz do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "5" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colcn do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "6" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colym do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "7" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colprvo do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "8" then
                              sampAddChatMessage("[ {800000}HitMan {ffffff}]: Маскировка невозможна. Причина: 8 ID фракции - {800000}Hitman Agency.", -1)
                     end
             if id == "9" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colcnn do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "10" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= coltm do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "11" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colsfpd do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "12" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colrm do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "13" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colgrv do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "14" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colbal do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "15" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colvag do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "16" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colazt do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "17" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colrif do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "18" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colar do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "19" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colstr do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "20" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colbik do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "21" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= collvpd do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "22" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colpriz do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "23" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colvvs do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
             if id == "24" then
                 players = 0
                 for id = 0, sampGetMaxPlayerId(false) do
                     if sampIsPlayerConnected(id) then
                         color = sampGetPlayerColor(id)
                                     math.randomseed(os.time())
                                         local id = math.random(0, sampGetMaxPlayerId(false))
                                         while sampGetPlayerColor(id) ~= colvmf do
                                         id = math.random(0, sampGetMaxPlayerId(false)) end
                             sampSendChat("/masked "..id)
                             players = players + 1
                             break
                         end
                     end
                 if players == 0 then
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Ни одного из членов данной органицзации нет в игре.", -1)
                 end
                 else
                     sampAddChatMessage("[ {800000}HitMan {ffffff}]: Скины фракций - [ {800000}/scm {ffffff}].", -1)
                     sampAddChatMessage("[ {800000}1 {ffffff}] - LSPD; [ {800000}2 {ffffff}] - FBI; [ {800000}3 {ffffff}] - NGSA; [ {800000}4 {ffffff}] - МинЗдрав ..", -1)
                     sampAddChatMessage(".. [ {800000}5 {ffffff}] - Cosa Nostra; [ {800000}6 {ffffff}] - Yakuza; [ {800000}7 {ffffff}] - Правительство ..", -1)
                     sampAddChatMessage(".. [ {800000}8 {ffffff}] - None; [ {800000}9 {ffffff}] - CNN; [ {800000}10 {ffffff}] - Triada  ..", -1)
                     sampAddChatMessage(".. [ {800000}11 {ffffff}] - SFPD; [ {800000}12 {ffffff}] - Russia; [ {800000}13 {ffffff}] - Grove ..", -1)
                     sampAddChatMessage(".. [ {800000}14 {ffffff}] - Ballas; [ {800000}15 {ffffff}] - Vagos; [ {800000}16 {ffffff}] - Aztecas ..", -1)
                     sampAddChatMessage(".. [ {800000}17 {ffffff}] - Rifa; [ {800000}18 {ffffff}] - Arabian; [ {800000}19 {ffffff}] - Street Racers ..")
                     sampAddChatMessage(".. [ {800000}20 {ffffff}] - Bikers; [ {800000}21 {ffffff}] - LVPD ..", -1)
                     sampAddChatMessage(".. [ {800000}22 {ffffff}]- Призывник; [ {800000}23 {ffffff}] - ВВС; [ {800000}24 {ffffff}] - ВМФ.", -1)
                 end
Будем отсылать исходный код, как вымогатели текст по частям из чего-то большего?
bez.png