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

Questel

Участник
151
13
кодик:
local toggle = false
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end --Проверка на загрузку сампа и SF
    while not isSampAvailable() do wait(0) end --Ждём пока функция isSampAvailable вернёт true и добавляем задержку wait(0) что бы игра не зависла
    while true do
    wait(0)
      if wasKeyPressed(0x6B) then
        toggle = not toggle
       end
    end
    if not sampIsCursorActive() then
      if toggle then
        printStringNow("Flood Space Activated", 100)
        wait(10)
        setVirtualKeyDown(0x20, true)
        wait(10)
        setVirtualKeyDown(0x20, false)
      end
   end
end
Спасибо)))
 

Questel

Участник
151
13
кодик:
local toggle = false
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end --Проверка на загрузку сампа и SF
    while not isSampAvailable() do wait(0) end --Ждём пока функция isSampAvailable вернёт true и добавляем задержку wait(0) что бы игра не зависла
    while true do
    wait(0)
      if wasKeyPressed(0x6B) then
        toggle = not toggle
       end
    end
    if not sampIsCursorActive() then
      if toggle then
        printStringNow("Flood Space Activated", 100)
        wait(10)
        setVirtualKeyDown(0x20, true)
        wait(10)
        setVirtualKeyDown(0x20, false)
      end
   end
end
А понимаю, функцию проверки загрузки сделал, а все равно не работает, лол
 

Questel

Участник
151
13
[10:16:57.509015] (system) Session started.
[10:16:57.517024] (debug) Module handle: 6C050000

MoonLoader v.026.5-beta loaded.
Developers: FYP, hnnssy, EvgeN 1137

Copyright (c) 2016, BlastHack Team
https://www.blast.hk/moonloader/

[10:16:57.517024] (info) Working directory: D:\Games\GTA\moonloader
[10:16:57.518024] (debug) FP Control: 0009001F
[10:16:57.518024] (debug) Game: GTA SA 1.0.0.0 US
[10:16:57.518024] (system) Installing pre-game hooks...
[10:16:57.545020] (system) Hooks installed.
[10:17:03.595520] (debug) Initializing opcode handler table
[10:17:03.596521] (debug) package.path = D:\Games\GTA\moonloader\lib\?.lua;D:\Games\GTA\moonloader\lib\?\init.lua;D:\Games\GTA\moonloader\?.lua;D:\Games\GTA\moonloader\?\init.lua;.\?.lua;D:\Games\GTA\moonloader\lib\?.luac;D:\Games\GTA\moonloader\lib\?\init.luac;D:\Games\GTA\moonloader\?.luac;D:\Games\GTA\moonloader\?\init.luac;.\?.luac
[10:17:03.597522] (debug) package.cpath = D:\Games\GTA\moonloader\lib\?.dll;
[10:17:03.642503] (system) Loading script 'D:\Games\GTA\moonloader\alt enter.lua'...
[10:17:03.643504] (debug) New script: 12D5B85C
[10:17:03.658517] (system) alt enter.lua: Loaded successfully.
[10:17:03.658517] (system) Loading script 'D:\Games\GTA\moonloader\ARZ HelperLite1.0.lua'...
[10:17:03.658517] (debug) New script: 12D5B6D4
[10:17:03.803475] (system) ARZ HelperLite1.0.lua: Loaded successfully.
[10:17:03.804473] (system) Loading script 'D:\Games\GTA\moonloader\AutoReboot.lua'...
[10:17:03.804473] (debug) New script: 12D5A5FC
[10:17:03.812475] (system) ML-AutoReboot: Loaded successfully.
[10:17:03.813475] (system) Loading script 'D:\Games\GTA\moonloader\Central Cleaner(FINAL).lua'...
[10:17:03.813475] (debug) New script: 12D5AF2C
[10:17:03.892461] (system) Central Cleaner(FINAL): Loaded successfully.
[10:17:03.892461] (system) Loading script 'D:\Games\GTA\moonloader\check-moonloader-updates.lua'...
[10:17:03.892461] (debug) New script: 12D5B54C
[10:17:03.907456] (system) Check MoonLoader Updates: Loaded successfully.
[10:17:03.908456] (system) Loading script 'D:\Games\GTA\moonloader\hphud.lua'...
[10:17:03.908456] (debug) New script: 12D5C004
[10:17:03.916458] (system) hphud.lua: Loaded successfully.
[10:17:03.917459] (system) Loading script 'D:\Games\GTA\moonloader\imgui_notf.lua'...
[10:17:03.917459] (debug) New script: 12D5A90C
[10:17:03.960453] (system) imgui_notf.lua: Loaded successfully.
[10:17:03.960453] (system) Loading script 'D:\Games\GTA\moonloader\keylogger.lua'...
[10:17:03.960453] (debug) New script: 12D5B0B4
[10:17:03.978454] (system) keylogger.lua: Loaded successfully.
[10:17:03.978454] (system) Loading script 'D:\Games\GTA\moonloader\logo.lua'...
[10:17:03.978454] (debug) New script: 12D5C18C
[10:17:04.024442] (system) New Logo by Ambient Mods and VovaS Sripts : Loaded successfully.
[10:17:04.024442] (system) Loading script 'D:\Games\GTA\moonloader\money_separator.lua'...
[10:17:04.024442] (debug) New script: 12D5ADA4
[10:17:04.062451] (system) money_separator.lua: Loaded successfully.
[10:17:04.063429] (system) Loading script 'D:\Games\GTA\moonloader\reload_all.lua'...
[10:17:04.064431] (debug) New script: 12D5AA94
[10:17:04.072441] (system) ML-ReloadAll: Loaded successfully.
[10:17:04.072441] (system) Loading script 'D:\Games\GTA\moonloader\sbiv.lua'...
[10:17:04.073442] (debug) New script: 12D5B9E4
[10:17:04.080426] (system) sbiv.lua: Loaded successfully.
[10:17:04.080426] (system) Loading script 'D:\Games\GTA\moonloader\Server_Time_by_Kalashnikov.lua'...
[10:17:04.081428] (debug) New script: 12D5BB6C
[10:17:04.121419] (system) Server_Time_by_Kalashnikov.lua: Loaded successfully.
[10:17:04.121419] (system) Loading script 'D:\Games\GTA\moonloader\SF Integration.lua'...
[10:17:04.122438] (debug) New script: 12D5AC1C
[10:17:04.139430] (system) SF Integration: Loaded successfully.
[10:17:04.139430] (system) Loading script 'D:\Games\GTA\moonloader\space.lua'...
[10:17:04.140416] (debug) New script: 12D5BCF4
[10:17:04.141416] (error) space.lua: D:\Games\GTA\moonloader\space.lua:17: 'end' expected (to close 'function' at line 2) near '<eof>'
[10:17:04.142415] (error) space.lua: Script died due to an error. (12D5BCF4)
[10:17:11.770900] (system) Installing post-load hooks...
[10:17:11.771901] (system) Hooks installed.
[10:22:20.132098] (system) alt enter.lua: Script terminated. (12D5B85C)
[10:22:20.134098] (system) ARZ HelperLite1.0.lua: Script terminated. (12D5B6D4)
[10:22:20.140097] (system) ML-AutoReboot: Script terminated. (12D5A5FC)
[10:22:20.143097] (system) Central Cleaner(FINAL): Script terminated. (12D5AF2C)
[10:22:20.151095] (system) Check MoonLoader Updates: Script terminated. (12D5B54C)
[10:22:20.153095] (system) hphud.lua: Script terminated. (12D5C004)
[10:22:20.156094] (system) imgui_notf.lua: Script terminated. (12D5A90C)
[10:22:20.160094] (system) keylogger.lua: Script terminated. (12D5B0B4)
[10:22:20.162097] (system) New Logo by Ambient Mods and VovaS Sripts : Script terminated. (12D5C18C)
[10:22:20.165092] (system) money_separator.lua: Script terminated. (12D5ADA4)
[10:22:20.169091] (system) ML-ReloadAll: Script terminated. (12D5AA94)
[10:22:20.170091] (system) sbiv.lua: Script terminated. (12D5B9E4)
[10:22:20.171091] (system) Server_Time_by_Kalashnikov.lua: Script terminated. (12D5BB6C)
[10:22:20.174091] (system) SF Integration: Script terminated. (12D5AC1C)
[10:22:20.177090] (system) Loading script 'D:\Games\GTA\moonloader\alt enter.lua'...
[10:22:20.177090] (debug) New script: 1BDC277C
[10:22:20.183089] (system) alt enter.lua: Loaded successfully.
[10:22:20.183089] (system) Loading script 'D:\Games\GTA\moonloader\ARZ HelperLite1.0.lua'...
[10:22:20.183089] (debug) New script: 1BDC3B64
[10:22:20.262096] (system) ARZ HelperLite1.0.lua: Loaded successfully.
[10:22:20.262096] (system) Loading script 'D:\Games\GTA\moonloader\AutoReboot.lua'...
[10:22:20.262096] (debug) New script: 1BDC215C
[10:22:20.269074] (system) ML-AutoReboot: Loaded successfully.
[10:22:20.269074] (system) Loading script 'D:\Games\GTA\moonloader\Central Cleaner(FINAL).lua'...
[10:22:20.269074] (debug) New script: 1BDC3CEC
[10:22:20.326064] (system) Central Cleaner(FINAL): Loaded successfully.
[10:22:20.326064] (system) Loading script 'D:\Games\GTA\moonloader\check-moonloader-updates.lua'...
[10:22:20.327064] (debug) New script: 1BDC3234
[10:22:20.338063] (system) Check MoonLoader Updates: Loaded successfully.
[10:22:20.338063] (system) Loading script 'D:\Games\GTA\moonloader\hphud.lua'...
[10:22:20.338063] (debug) New script: 1BDC33BC
[10:22:20.344062] (system) hphud.lua: Loaded successfully.
[10:22:20.344062] (system) Loading script 'D:\Games\GTA\moonloader\imgui_notf.lua'...
[10:22:20.345061] (debug) New script: 1BDC3E74
[10:22:20.377056] (system) imgui_notf.lua: Loaded successfully.
[10:22:20.377056] (system) Loading script 'D:\Games\GTA\moonloader\keylogger.lua'...
[10:22:20.377056] (debug) New script: 1BDC246C
[10:22:20.390054] (system) keylogger.lua: Loaded successfully.
[10:22:20.390054] (system) Loading script 'D:\Games\GTA\moonloader\logo.lua'...
[10:22:20.390054] (debug) New script: 1BDC3544
[10:22:20.421048] (system) New Logo by Ambient Mods and VovaS Sripts : Loaded successfully.
[10:22:20.421048] (system) Loading script 'D:\Games\GTA\moonloader\money_separator.lua'...
[10:22:20.421048] (debug) New script: 1BDC22E4
[10:22:20.451043] (system) money_separator.lua: Loaded successfully.
[10:22:20.451043] (system) Loading script 'D:\Games\GTA\moonloader\reload_all.lua'...
[10:22:20.451043] (debug) New script: 1BDC2904
[10:22:20.458043] (system) ML-ReloadAll: Loaded successfully.
[10:22:20.458043] (system) Loading script 'D:\Games\GTA\moonloader\sbiv.lua'...
[10:22:20.459043] (debug) New script: 1BDC36CC
[10:22:20.465046] (system) sbiv.lua: Loaded successfully.
[10:22:20.465046] (system) Loading script 'D:\Games\GTA\moonloader\Server_Time_by_Kalashnikov.lua'...
[10:22:20.465046] (debug) New script: 1BDC3854
[10:22:20.496043] (system) Server_Time_by_Kalashnikov.lua: Loaded successfully.
[10:22:20.497045] (system) Loading script 'D:\Games\GTA\moonloader\SF Integration.lua'...
[10:22:20.497045] (debug) New script: 1BDC2D9C
[10:22:20.511033] (system) SF Integration: Loaded successfully.
[10:22:20.511033] (system) Loading script 'D:\Games\GTA\moonloader\space.lua'...
[10:22:20.512033] (debug) New script: 1BDC2F24
[10:22:20.520035] (system) space.lua: Loaded successfully.
[10:24:00.991876] (script) ML-AutoReboot: Reloading "space.lua"...
[10:24:07.451900] (system) space.lua: Script terminated. (1BDC2F24)
[10:24:07.452900] (system) Loading script 'D:\Games\GTA\moonloader\space.lua'...
[10:24:07.453899] (debug) New script: 111F1FFC
[10:24:07.459898] (system) space.lua: Loaded successfully.
[10:24:10.142685] (system) alt enter.lua: Script terminated. (1BDC277C)
[10:24:10.143684] (system) ARZ HelperLite1.0.lua: Script terminated. (1BDC3B64)
[10:24:10.150683] (system) ML-AutoReboot: Script terminated. (1BDC215C)
[10:24:10.152683] (system) Central Cleaner(FINAL): Script terminated. (1BDC3CEC)
[10:24:10.157681] (system) Check MoonLoader Updates: Script terminated. (1BDC3234)
[10:24:10.158681] (system) hphud.lua: Script terminated. (1BDC33BC)
[10:24:10.162681] (system) imgui_notf.lua: Script terminated. (1BDC3E74)
[10:24:10.166680] (system) keylogger.lua: Script terminated. (1BDC246C)
[10:24:10.168693] (system) New Logo by Ambient Mods and VovaS Sripts : Script terminated. (1BDC3544)
[10:24:10.171696] (system) money_separator.lua: Script terminated. (1BDC22E4)
[10:24:10.174679] (system) ML-ReloadAll: Script terminated. (1BDC2904)
[10:24:10.175679] (system) sbiv.lua: Script terminated. (1BDC36CC)
[10:24:10.177678] (system) Server_Time_by_Kalashnikov.lua: Script terminated. (1BDC3854)
[10:24:10.180678] (system) SF Integration: Script terminated. (1BDC2D9C)
[10:24:10.182678] (system) space.lua: Script terminated. (111F1FFC)
[10:24:10.184677] (system) Loading script 'D:\Games\GTA\moonloader\alt enter.lua'...
[10:24:10.184677] (debug) New script: 111F1FFC
[10:24:10.190681] (system) alt enter.lua: Loaded successfully.
[10:24:10.190681] (system) Loading script 'D:\Games\GTA\moonloader\ARZ HelperLite1.0.lua'...
[10:24:10.190681] (debug) New script: 111F13BC
[10:24:10.268663] (system) ARZ HelperLite1.0.lua: Loaded successfully.
[10:24:10.268663] (system) Loading script 'D:\Games\GTA\moonloader\AutoReboot.lua'...
[10:24:10.268663] (debug) New script: 111F19DC
[10:24:10.275661] (system) ML-AutoReboot: Loaded successfully.
[10:24:10.275661] (system) Loading script 'D:\Games\GTA\moonloader\Central Cleaner(FINAL).lua'...
[10:24:10.275661] (debug) New script: 111F1544
[10:24:10.332652] (system) Central Cleaner(FINAL): Loaded successfully.
[10:24:10.332652] (system) Loading script 'D:\Games\GTA\moonloader\check-moonloader-updates.lua'...
[10:24:10.332652] (debug) New script: 111F1B64
[10:24:10.343650] (system) Check MoonLoader Updates: Loaded successfully.
[10:24:10.344649] (system) Loading script 'D:\Games\GTA\moonloader\hphud.lua'...
[10:24:10.344649] (debug) New script: 111F1854
[10:24:10.350649] (system) hphud.lua: Loaded successfully.
[10:24:10.350649] (system) Loading script 'D:\Games\GTA\moonloader\imgui_notf.lua'...
[10:24:10.351648] (debug) New script: 111F1CEC
[10:24:10.383643] (system) imgui_notf.lua: Loaded successfully.
[10:24:10.383643] (system) Loading script 'D:\Games\GTA\moonloader\keylogger.lua'...
[10:24:10.383643] (debug) New script: 111F2184
[10:24:10.395640] (system) keylogger.lua: Loaded successfully.
[10:24:10.396641] (system) Loading script 'D:\Games\GTA\moonloader\logo.lua'...
[10:24:10.396641] (debug) New script: 111F16CC
[10:24:10.426635] (system) New Logo by Ambient Mods and VovaS Sripts : Loaded successfully.
[10:24:10.426635] (system) Loading script 'D:\Games\GTA\moonloader\money_separator.lua'...
[10:24:10.427635] (debug) New script: 12D5A474
[10:24:10.455630] (system) money_separator.lua: Loaded successfully.
[10:24:10.456631] (system) Loading script 'D:\Games\GTA\moonloader\reload_all.lua'...
[10:24:10.456631] (debug) New script: 12D5AF2C
[10:24:10.462629] (system) ML-ReloadAll: Loaded successfully.
[10:24:10.462629] (system) Loading script 'D:\Games\GTA\moonloader\sbiv.lua'...
[10:24:10.462629] (debug) New script: 12D5A90C
[10:24:10.468628] (system) sbiv.lua: Loaded successfully.
[10:24:10.468628] (system) Loading script 'D:\Games\GTA\moonloader\Server_Time_by_Kalashnikov.lua'...
[10:24:10.468628] (debug) New script: 12D5BE7C
[10:24:10.501165] (system) Server_Time_by_Kalashnikov.lua: Loaded successfully.
[10:24:10.502165] (system) Loading script 'D:\Games\GTA\moonloader\SF Integration.lua'...
[10:24:10.502165] (debug) New script: 12D5AA94
[10:24:10.516148] (system) SF Integration: Loaded successfully.
[10:24:10.516148] (system) Loading script 'D:\Games\GTA\moonloader\space.lua'...
[10:24:10.516148] (debug) New script: 12D5AC1C
[10:24:10.522153] (system) space.lua: Loaded successfully.
 

LelHack

Известный
452
125
[10:16:57.509015] (system) Session started.
[10:16:57.517024] (debug) Module handle: 6C050000

MoonLoader v.026.5-beta loaded.
Developers: FYP, hnnssy, EvgeN 1137

Copyright (c) 2016, BlastHack Team

[10:16:57.517024] (info) Working directory: D:\Games\GTA\moonloader
[10:16:57.518024] (debug) FP Control: 0009001F
[10:16:57.518024] (debug) Game: GTA SA 1.0.0.0 US
[10:16:57.518024] (system) Installing pre-game hooks...
[10:16:57.545020] (system) Hooks installed.
[10:17:03.595520] (debug) Initializing opcode handler table
[10:17:03.596521] (debug) package.path = D:\Games\GTA\moonloader\lib\?.lua;D:\Games\GTA\moonloader\lib\?\init.lua;D:\Games\GTA\moonloader\?.lua;D:\Games\GTA\moonloader\?\init.lua;.\?.lua;D:\Games\GTA\moonloader\lib\?.luac;D:\Games\GTA\moonloader\lib\?\init.luac;D:\Games\GTA\moonloader\?.luac;D:\Games\GTA\moonloader\?\init.luac;.\?.luac
[10:17:03.597522] (debug) package.cpath = D:\Games\GTA\moonloader\lib\?.dll;
[10:17:03.642503] (system) Loading script 'D:\Games\GTA\moonloader\alt enter.lua'...
[10:17:03.643504] (debug) New script: 12D5B85C
[10:17:03.658517] (system) alt enter.lua: Loaded successfully.
[10:17:03.658517] (system) Loading script 'D:\Games\GTA\moonloader\ARZ HelperLite1.0.lua'...
[10:17:03.658517] (debug) New script: 12D5B6D4
[10:17:03.803475] (system) ARZ HelperLite1.0.lua: Loaded successfully.
[10:17:03.804473] (system) Loading script 'D:\Games\GTA\moonloader\AutoReboot.lua'...
[10:17:03.804473] (debug) New script: 12D5A5FC
[10:17:03.812475] (system) ML-AutoReboot: Loaded successfully.
[10:17:03.813475] (system) Loading script 'D:\Games\GTA\moonloader\Central Cleaner(FINAL).lua'...
[10:17:03.813475] (debug) New script: 12D5AF2C
[10:17:03.892461] (system) Central Cleaner(FINAL): Loaded successfully.
[10:17:03.892461] (system) Loading script 'D:\Games\GTA\moonloader\check-moonloader-updates.lua'...
[10:17:03.892461] (debug) New script: 12D5B54C
[10:17:03.907456] (system) Check MoonLoader Updates: Loaded successfully.
[10:17:03.908456] (system) Loading script 'D:\Games\GTA\moonloader\hphud.lua'...
[10:17:03.908456] (debug) New script: 12D5C004
[10:17:03.916458] (system) hphud.lua: Loaded successfully.
[10:17:03.917459] (system) Loading script 'D:\Games\GTA\moonloader\imgui_notf.lua'...
[10:17:03.917459] (debug) New script: 12D5A90C
[10:17:03.960453] (system) imgui_notf.lua: Loaded successfully.
[10:17:03.960453] (system) Loading script 'D:\Games\GTA\moonloader\keylogger.lua'...
[10:17:03.960453] (debug) New script: 12D5B0B4
[10:17:03.978454] (system) keylogger.lua: Loaded successfully.
[10:17:03.978454] (system) Loading script 'D:\Games\GTA\moonloader\logo.lua'...
[10:17:03.978454] (debug) New script: 12D5C18C
[10:17:04.024442] (system) New Logo by Ambient Mods and VovaS Sripts : Loaded successfully.
[10:17:04.024442] (system) Loading script 'D:\Games\GTA\moonloader\money_separator.lua'...
[10:17:04.024442] (debug) New script: 12D5ADA4
[10:17:04.062451] (system) money_separator.lua: Loaded successfully.
[10:17:04.063429] (system) Loading script 'D:\Games\GTA\moonloader\reload_all.lua'...
[10:17:04.064431] (debug) New script: 12D5AA94
[10:17:04.072441] (system) ML-ReloadAll: Loaded successfully.
[10:17:04.072441] (system) Loading script 'D:\Games\GTA\moonloader\sbiv.lua'...
[10:17:04.073442] (debug) New script: 12D5B9E4
[10:17:04.080426] (system) sbiv.lua: Loaded successfully.
[10:17:04.080426] (system) Loading script 'D:\Games\GTA\moonloader\Server_Time_by_Kalashnikov.lua'...
[10:17:04.081428] (debug) New script: 12D5BB6C
[10:17:04.121419] (system) Server_Time_by_Kalashnikov.lua: Loaded successfully.
[10:17:04.121419] (system) Loading script 'D:\Games\GTA\moonloader\SF Integration.lua'...
[10:17:04.122438] (debug) New script: 12D5AC1C
[10:17:04.139430] (system) SF Integration: Loaded successfully.
[10:17:04.139430] (system) Loading script 'D:\Games\GTA\moonloader\space.lua'...
[10:17:04.140416] (debug) New script: 12D5BCF4
[10:17:04.141416] (error) space.lua: D:\Games\GTA\moonloader\space.lua:17: 'end' expected (to close 'function' at line 2) near '<eof>'
[10:17:04.142415] (error) space.lua: Script died due to an error. (12D5BCF4)
[10:17:11.770900] (system) Installing post-load hooks...
[10:17:11.771901] (system) Hooks installed.
[10:22:20.132098] (system) alt enter.lua: Script terminated. (12D5B85C)
[10:22:20.134098] (system) ARZ HelperLite1.0.lua: Script terminated. (12D5B6D4)
[10:22:20.140097] (system) ML-AutoReboot: Script terminated. (12D5A5FC)
[10:22:20.143097] (system) Central Cleaner(FINAL): Script terminated. (12D5AF2C)
[10:22:20.151095] (system) Check MoonLoader Updates: Script terminated. (12D5B54C)
[10:22:20.153095] (system) hphud.lua: Script terminated. (12D5C004)
[10:22:20.156094] (system) imgui_notf.lua: Script terminated. (12D5A90C)
[10:22:20.160094] (system) keylogger.lua: Script terminated. (12D5B0B4)
[10:22:20.162097] (system) New Logo by Ambient Mods and VovaS Sripts : Script terminated. (12D5C18C)
[10:22:20.165092] (system) money_separator.lua: Script terminated. (12D5ADA4)
[10:22:20.169091] (system) ML-ReloadAll: Script terminated. (12D5AA94)
[10:22:20.170091] (system) sbiv.lua: Script terminated. (12D5B9E4)
[10:22:20.171091] (system) Server_Time_by_Kalashnikov.lua: Script terminated. (12D5BB6C)
[10:22:20.174091] (system) SF Integration: Script terminated. (12D5AC1C)
[10:22:20.177090] (system) Loading script 'D:\Games\GTA\moonloader\alt enter.lua'...
[10:22:20.177090] (debug) New script: 1BDC277C
[10:22:20.183089] (system) alt enter.lua: Loaded successfully.
[10:22:20.183089] (system) Loading script 'D:\Games\GTA\moonloader\ARZ HelperLite1.0.lua'...
[10:22:20.183089] (debug) New script: 1BDC3B64
[10:22:20.262096] (system) ARZ HelperLite1.0.lua: Loaded successfully.
[10:22:20.262096] (system) Loading script 'D:\Games\GTA\moonloader\AutoReboot.lua'...
[10:22:20.262096] (debug) New script: 1BDC215C
[10:22:20.269074] (system) ML-AutoReboot: Loaded successfully.
[10:22:20.269074] (system) Loading script 'D:\Games\GTA\moonloader\Central Cleaner(FINAL).lua'...
[10:22:20.269074] (debug) New script: 1BDC3CEC
[10:22:20.326064] (system) Central Cleaner(FINAL): Loaded successfully.
[10:22:20.326064] (system) Loading script 'D:\Games\GTA\moonloader\check-moonloader-updates.lua'...
[10:22:20.327064] (debug) New script: 1BDC3234
[10:22:20.338063] (system) Check MoonLoader Updates: Loaded successfully.
[10:22:20.338063] (system) Loading script 'D:\Games\GTA\moonloader\hphud.lua'...
[10:22:20.338063] (debug) New script: 1BDC33BC
[10:22:20.344062] (system) hphud.lua: Loaded successfully.
[10:22:20.344062] (system) Loading script 'D:\Games\GTA\moonloader\imgui_notf.lua'...
[10:22:20.345061] (debug) New script: 1BDC3E74
[10:22:20.377056] (system) imgui_notf.lua: Loaded successfully.
[10:22:20.377056] (system) Loading script 'D:\Games\GTA\moonloader\keylogger.lua'...
[10:22:20.377056] (debug) New script: 1BDC246C
[10:22:20.390054] (system) keylogger.lua: Loaded successfully.
[10:22:20.390054] (system) Loading script 'D:\Games\GTA\moonloader\logo.lua'...
[10:22:20.390054] (debug) New script: 1BDC3544
[10:22:20.421048] (system) New Logo by Ambient Mods and VovaS Sripts : Loaded successfully.
[10:22:20.421048] (system) Loading script 'D:\Games\GTA\moonloader\money_separator.lua'...
[10:22:20.421048] (debug) New script: 1BDC22E4
[10:22:20.451043] (system) money_separator.lua: Loaded successfully.
[10:22:20.451043] (system) Loading script 'D:\Games\GTA\moonloader\reload_all.lua'...
[10:22:20.451043] (debug) New script: 1BDC2904
[10:22:20.458043] (system) ML-ReloadAll: Loaded successfully.
[10:22:20.458043] (system) Loading script 'D:\Games\GTA\moonloader\sbiv.lua'...
[10:22:20.459043] (debug) New script: 1BDC36CC
[10:22:20.465046] (system) sbiv.lua: Loaded successfully.
[10:22:20.465046] (system) Loading script 'D:\Games\GTA\moonloader\Server_Time_by_Kalashnikov.lua'...
[10:22:20.465046] (debug) New script: 1BDC3854
[10:22:20.496043] (system) Server_Time_by_Kalashnikov.lua: Loaded successfully.
[10:22:20.497045] (system) Loading script 'D:\Games\GTA\moonloader\SF Integration.lua'...
[10:22:20.497045] (debug) New script: 1BDC2D9C
[10:22:20.511033] (system) SF Integration: Loaded successfully.
[10:22:20.511033] (system) Loading script 'D:\Games\GTA\moonloader\space.lua'...
[10:22:20.512033] (debug) New script: 1BDC2F24
[10:22:20.520035] (system) space.lua: Loaded successfully.
[10:24:00.991876] (script) ML-AutoReboot: Reloading "space.lua"...
[10:24:07.451900] (system) space.lua: Script terminated. (1BDC2F24)
[10:24:07.452900] (system) Loading script 'D:\Games\GTA\moonloader\space.lua'...
[10:24:07.453899] (debug) New script: 111F1FFC
[10:24:07.459898] (system) space.lua: Loaded successfully.
[10:24:10.142685] (system) alt enter.lua: Script terminated. (1BDC277C)
[10:24:10.143684] (system) ARZ HelperLite1.0.lua: Script terminated. (1BDC3B64)
[10:24:10.150683] (system) ML-AutoReboot: Script terminated. (1BDC215C)
[10:24:10.152683] (system) Central Cleaner(FINAL): Script terminated. (1BDC3CEC)
[10:24:10.157681] (system) Check MoonLoader Updates: Script terminated. (1BDC3234)
[10:24:10.158681] (system) hphud.lua: Script terminated. (1BDC33BC)
[10:24:10.162681] (system) imgui_notf.lua: Script terminated. (1BDC3E74)
[10:24:10.166680] (system) keylogger.lua: Script terminated. (1BDC246C)
[10:24:10.168693] (system) New Logo by Ambient Mods and VovaS Sripts : Script terminated. (1BDC3544)
[10:24:10.171696] (system) money_separator.lua: Script terminated. (1BDC22E4)
[10:24:10.174679] (system) ML-ReloadAll: Script terminated. (1BDC2904)
[10:24:10.175679] (system) sbiv.lua: Script terminated. (1BDC36CC)
[10:24:10.177678] (system) Server_Time_by_Kalashnikov.lua: Script terminated. (1BDC3854)
[10:24:10.180678] (system) SF Integration: Script terminated. (1BDC2D9C)
[10:24:10.182678] (system) space.lua: Script terminated. (111F1FFC)
[10:24:10.184677] (system) Loading script 'D:\Games\GTA\moonloader\alt enter.lua'...
[10:24:10.184677] (debug) New script: 111F1FFC
[10:24:10.190681] (system) alt enter.lua: Loaded successfully.
[10:24:10.190681] (system) Loading script 'D:\Games\GTA\moonloader\ARZ HelperLite1.0.lua'...
[10:24:10.190681] (debug) New script: 111F13BC
[10:24:10.268663] (system) ARZ HelperLite1.0.lua: Loaded successfully.
[10:24:10.268663] (system) Loading script 'D:\Games\GTA\moonloader\AutoReboot.lua'...
[10:24:10.268663] (debug) New script: 111F19DC
[10:24:10.275661] (system) ML-AutoReboot: Loaded successfully.
[10:24:10.275661] (system) Loading script 'D:\Games\GTA\moonloader\Central Cleaner(FINAL).lua'...
[10:24:10.275661] (debug) New script: 111F1544
[10:24:10.332652] (system) Central Cleaner(FINAL): Loaded successfully.
[10:24:10.332652] (system) Loading script 'D:\Games\GTA\moonloader\check-moonloader-updates.lua'...
[10:24:10.332652] (debug) New script: 111F1B64
[10:24:10.343650] (system) Check MoonLoader Updates: Loaded successfully.
[10:24:10.344649] (system) Loading script 'D:\Games\GTA\moonloader\hphud.lua'...
[10:24:10.344649] (debug) New script: 111F1854
[10:24:10.350649] (system) hphud.lua: Loaded successfully.
[10:24:10.350649] (system) Loading script 'D:\Games\GTA\moonloader\imgui_notf.lua'...
[10:24:10.351648] (debug) New script: 111F1CEC
[10:24:10.383643] (system) imgui_notf.lua: Loaded successfully.
[10:24:10.383643] (system) Loading script 'D:\Games\GTA\moonloader\keylogger.lua'...
[10:24:10.383643] (debug) New script: 111F2184
[10:24:10.395640] (system) keylogger.lua: Loaded successfully.
[10:24:10.396641] (system) Loading script 'D:\Games\GTA\moonloader\logo.lua'...
[10:24:10.396641] (debug) New script: 111F16CC
[10:24:10.426635] (system) New Logo by Ambient Mods and VovaS Sripts : Loaded successfully.
[10:24:10.426635] (system) Loading script 'D:\Games\GTA\moonloader\money_separator.lua'...
[10:24:10.427635] (debug) New script: 12D5A474
[10:24:10.455630] (system) money_separator.lua: Loaded successfully.
[10:24:10.456631] (system) Loading script 'D:\Games\GTA\moonloader\reload_all.lua'...
[10:24:10.456631] (debug) New script: 12D5AF2C
[10:24:10.462629] (system) ML-ReloadAll: Loaded successfully.
[10:24:10.462629] (system) Loading script 'D:\Games\GTA\moonloader\sbiv.lua'...
[10:24:10.462629] (debug) New script: 12D5A90C
[10:24:10.468628] (system) sbiv.lua: Loaded successfully.
[10:24:10.468628] (system) Loading script 'D:\Games\GTA\moonloader\Server_Time_by_Kalashnikov.lua'...
[10:24:10.468628] (debug) New script: 12D5BE7C
[10:24:10.501165] (system) Server_Time_by_Kalashnikov.lua: Loaded successfully.
[10:24:10.502165] (system) Loading script 'D:\Games\GTA\moonloader\SF Integration.lua'...
[10:24:10.502165] (debug) New script: 12D5AA94
[10:24:10.516148] (system) SF Integration: Loaded successfully.
[10:24:10.516148] (system) Loading script 'D:\Games\GTA\moonloader\space.lua'...
[10:24:10.516148] (debug) New script: 12D5AC1C
[10:24:10.522153] (system) space.lua: Loaded successfully.
-------------------------------------------------------------------------------------------------------------------
[10:17:04.141416] (error) space.lua: D:\Games\GTA\moonloader\space.lua:17: 'end' expected (to close 'function' at line 2) near '<eof>'
[10:17:04.142415] (error) space.lua: Script died due to an error. (12D5BCF4)

17 строчка не закрыл end

UPD. И кстати заметил у тебя проверка вне беск цикла:


kod:
local toggle = false
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end --Проверка на загрузку сампа и SF
    while not isSampAvailable() do wait(0) end --Ждём пока функция isSampAvailable вернёт true и добавляем задержку wait(0) что бы игра не зависла
    while true do
    wait(0)
    if wasKeyPressed(0x6B) then
        toggle = not toggle
    end
    if not sampIsCursorActive() then
      if toggle then
          printStringNow("Flood Space Activated", 100)
        wait(10)
        setVirtualKeyDown(0x20, true)
        wait(10)
        setVirtualKeyDown(0x20, false)
      end
    end
    end
end
 
  • Нравится
Реакции: Questel

Questel

Участник
151
13
-------------------------------------------------------------------------------------------------------------------
[10:17:04.141416] (error) space.lua: D:\Games\GTA\moonloader\space.lua:17: 'end' expected (to close 'function' at line 2) near '<eof>'
[10:17:04.142415] (error) space.lua: Script died due to an error. (12D5BCF4)

17 строчка не закрыл end

UPD. И кстати заметил у тебя проверка вне беск цикла:


kod:
local toggle = false
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end --Проверка на загрузку сампа и SF
    while not isSampAvailable() do wait(0) end --Ждём пока функция isSampAvailable вернёт true и добавляем задержку wait(0) что бы игра не зависла
    while true do
    wait(0)
    if wasKeyPressed(0x6B) then
        toggle = not toggle
    end
    if not sampIsCursorActive() then
      if toggle then
          printStringNow("Flood Space Activated", 100)
        wait(10)
        setVirtualKeyDown(0x20, true)
        wait(10)
        setVirtualKeyDown(0x20, false)
      end
    end
    end
end
Ебать бро спасибо, я с 8 устра ебался с этим флудером, спасибо огромное
 
  • Ха-ха
Реакции: LelHack

Alkoigel

Участник
116
15
как добавить "такое", чтобы ид игрока не нужно было вводить втд игрока, самому.
Нужно чтобы автоматически брался ид игрока, за которым я слежу

Lua:
require "lib.moonloader" -- подключение библиотеки
local keys = require "vkeys"
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local tag = "[My First Script]:" -- локальная переменная
local label = 0
local main_color = 0x5A90CE
local main_color_text = "{5A90CE}"
local white_color = "{FFFFFF}"
local arr_cheat = {"30 Aimbot", "30 WallHack", "10 Spread", "10 Speedhack", "30 Saim", "30 DMG", "30 SK", "10 Provo na SK", "10 Fly", "20 AirBreak", "15 Flycar"}

local main_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)


-- чекбоксы
    local checked_NakNumber        = imgui.ImInt(1)
--

-- радиокнопки
    local checked_band        = imgui.ImInt(1)

    local checked_jail        = imgui.ImInt(1)
 
--

--комбобоксы
    local combo_select         =imgui.ImInt(0)
--

local sw, sh = getScreenResolution()

function SetStyle()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4

    imgui.GetStyle().WindowPadding = imgui.ImVec2(8, 8)
    imgui.GetStyle().WindowRounding = 0.5
    imgui.GetStyle().FramePadding = imgui.ImVec2(5, 3)
    imgui.GetStyle().ItemSpacing = imgui.ImVec2(4, 4)
    imgui.GetStyle().ItemInnerSpacing = imgui.ImVec2(5, 5)
    imgui.GetStyle().IndentSpacing = 9.0
    imgui.GetStyle().ScrollbarSize = 17.0
    imgui.GetStyle().ScrollbarRounding = 16.0
    imgui.GetStyle().GrabMinSize = 7.0
    imgui.GetStyle().GrabRounding = 15.0
    imgui.GetStyle().ChildWindowRounding = 10.0
    imgui.GetStyle().FrameRounding = 7.0

    colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 0.94)
    colors[clr.ComboBg]                = colors[clr.PopupBg]
    colors[clr.Button]                 = ImVec4(0.26, 0.59, 0.98, 0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.ButtonActive]           = ImVec4(0.06, 0.53, 0.98, 1.00)
    colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.16, 0.29, 0.48, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.CloseButton]            = ImVec4(0.41, 0.41, 0.41, 0.50)-- (0.1, 0.9, 0.1, 1.0)
    colors[clr.CloseButtonHovered]     = ImVec4(0.98, 0.39, 0.36, 1.00)
    colors[clr.CloseButtonActive]      = ImVec4(0.98, 0.39, 0.36, 1.00)
    colors[clr.TextSelectedBg]         = ImVec4(0.26, 0.59, 0.98, 0.35)
    colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.FrameBg]                = ImVec4(0.16, 0.29, 0.48, 0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.26, 0.59, 0.98, 0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.26, 0.59, 0.98, 0.67)
    colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 1.00)
    colors[clr.ScrollbarBg]            = ImVec4(0.02, 0.02, 0.02, 0.53)
    colors[clr.ScrollbarGrab]          = ImVec4(0.31, 0.31, 0.31, 1.00)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.41, 0.41, 0.41, 1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.51, 0.51, 0.51, 1.00)
    colors[clr.CheckMark]              = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.Header]                 = ImVec4(0.26, 0.59, 0.98, 0.31)
    colors[clr.HeaderHovered]          = ImVec4(0.26, 0.59, 0.98, 0.80)
    colors[clr.HeaderActive]           = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.SliderGrab]             = ImVec4(0.24, 0.52, 0.88, 1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.26, 0.59, 0.98, 1.00)
end
SetStyle()

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

    sampRegisterChatCommand("imgui", cmd_imgui)
    sampRegisterChatCommand("check", cmd_check)
    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    nick = sampGetPlayerNickname(rid)

    imgui.Process = false
    --sampAddChatMessage("Скрипт imgui перезагружен", -1)

    while true do
        wait(0)
        if isKeyJustPressed(VK_F3) then
            cmd_imgui()
        end
        if isKeyJustPressed(VK_F4) then
            cmd_check()
        end

        if main_window_state.v == false then
            imgui.Process = false
        end
        -- Блок выполняющийся бесконечно (пока самп активен)

    end
end

function cmd_imgui(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end

function cmd_check(arg)
    sampAddChatMessage(checked_band.v, -1)
end

function imgui.OnDrawFrame()
    imgui.SwitchContext()
    local colors = imgui.GetStyle().Colors;
    local icol = imgui.Col
    local ImVec4 = imgui.ImVec4

    imgui.GetStyle().WindowPadding = imgui.ImVec2(10, 10)
    imgui.GetStyle().WindowRounding = 10.0
    imgui.GetStyle().FramePadding = imgui.ImVec2(5, 4)
    imgui.GetStyle().ItemSpacing = imgui.ImVec2(4, 4)
    imgui.GetStyle().ItemInnerSpacing = imgui.ImVec2(5, 5)
    imgui.GetStyle().IndentSpacing = 9.0
    imgui.GetStyle().ScrollbarSize = 17.0
    imgui.GetStyle().ScrollbarRounding = 20.0
    imgui.GetStyle().GrabMinSize = 7.0
    imgui.GetStyle().GrabRounding = 20.0
    imgui.GetStyle().ChildWindowRounding = 6.0
    imgui.GetStyle().FrameRounding = 20.0

    colors[icol.Text]                   = ImVec4(0.11, 0.11, 0.11, 1.00);
    colors[icol.TextDisabled]           = ImVec4(0.60, 0.60, 0.60, 1.00);
    colors[icol.WindowBg]               = ImVec4(0.90, 0.90, 0.90, 1.00);
    colors[icol.ChildWindowBg]          = ImVec4(0.13, 0.13, 0.13, 1.00);
    colors[icol.PopupBg]                = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.Border]                 = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.BorderShadow]           = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.FrameBg]                = ImVec4(0.26, 0.46, 0.82, 0.59);
    colors[icol.FrameBgHovered]         = ImVec4(0.26, 0.46, 0.82, 0.88);
    colors[icol.FrameBgActive]          = ImVec4(0.28, 0.53, 1.00, 1.00);
    colors[icol.TitleBg]                = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.TitleBgActive]          = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.TitleBgCollapsed]       = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.MenuBarBg]              = ImVec4(0.26, 0.46, 0.82, 0.75);
    colors[icol.ScrollbarBg]            = ImVec4(0.11, 0.11, 0.11, 1.00);
    colors[icol.ScrollbarGrab]          = ImVec4(0.26, 0.46, 0.82, 0.68);
    colors[icol.ScrollbarGrabHovered]   = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.ScrollbarGrabActive]    = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.ComboBg]                = ImVec4(0.26, 0.46, 0.82, 0.79);
    colors[icol.CheckMark]              = ImVec4(0.000, 0.000, 0.000, 1.000)
    colors[icol.SliderGrab]             = ImVec4(0.263, 0.459, 0.824, 1.000)
    colors[icol.SliderGrabActive]       = ImVec4(0.20, 0.20, 0.20, 1.00);
    colors[icol.Button]                 = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.ButtonHovered]          = ImVec4(0.26, 0.46, 0.82, 0.59);
    colors[icol.ButtonActive]           = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.Header]                 = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.HeaderHovered]          = ImVec4(0.26, 0.46, 0.82, 0.74);
    colors[icol.HeaderActive]           = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.Separator]              = ImVec4(0.37, 0.37, 0.37, 1.00);
    colors[icol.SeparatorHovered]       = ImVec4(0.60, 0.60, 0.70, 1.00);
    colors[icol.SeparatorActive]        = ImVec4(0.70, 0.70, 0.90, 1.00);
    colors[icol.ResizeGrip]             = ImVec4(1.00, 1.00, 1.00, 0.30);
    colors[icol.ResizeGripHovered]      = ImVec4(1.00, 1.00, 1.00, 0.60);
    colors[icol.ResizeGripActive]       = ImVec4(1.00, 1.00, 1.00, 0.90);
    colors[icol.CloseButton]            = ImVec4(0.90, 0.90, 0.90, 1.00);
    colors[icol.CloseButtonHovered]     = ImVec4(0.50, 0.50, 0.50, 0.60);
    colors[icol.CloseButtonActive]      = ImVec4(0.35, 0.35, 0.35, 1.00);
    colors[icol.PlotLines]              = ImVec4(1.00, 1.00, 1.00, 1.00);
    colors[icol.PlotLinesHovered]       = ImVec4(0.90, 0.70, 0.00, 1.00);
    colors[icol.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00);
    colors[icol.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00);
    colors[icol.TextSelectedBg]         = ImVec4(0.00, 0.00, 1.00, 0.35);
    colors[icol.ModalWindowDarkening]   = ImVec4(0.20, 0.20, 0.20, 0.35);
    if not main_window_state.v then
        imgui.Process = false
    end
    
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(500, 320), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

        imgui.Begin("Ghetto Helper", main_window_state) -- название окна

        imgui.RadioButton(u8"Грув", checked_band, 2)            -- название круга, переменная,
        imgui.SameLine()
        imgui.RadioButton(u8"Баллас", checked_band, 3)            -- название круга, переменная,
        imgui.SameLine()
        imgui.RadioButton(u8"Вагос", checked_band, 4)            -- название круга, переменная,
        imgui.SameLine()
        imgui.RadioButton(u8"Ацтек", checked_band, 5)            -- название круга, переменная,

        imgui.Separator()

        imgui.RadioButton(u8"Наказание 1/3", checked_NakNumber, 2)            -- название квадрата, переменная.
        imgui.RadioButton(u8"Наказание 2/3", checked_NakNumber, 3)            -- название квадрата, переменная.
        imgui.RadioButton(u8"Наказание 3/3", checked_NakNumber, 4)            -- название квадрата, переменная.

        imgui.Separator()

        imgui.RadioButton(u8"Jail", checked_jail, 2)            -- название квадрата, переменная.
        imgui.RadioButton(u8"Ban", checked_jail, 4)


        imgui.Combo(u8"Причина", combo_select, arr_cheat, #arr_cheat)

        imgui.InputText(u8"id/nickname игрока", text_buffer)


        if imgui.Button(u8"Наказать!") then
            if checked_jail.v == 2 then
                if checked_NakNumber.v == 2 then
                    nakaz = "[1/3]"
                elseif checked_NakNumber.v == 3 then
                    nakaz = "[2/3]"
                elseif checked_NakNumber.v == 4 then
                    nakaz = "[3/3]"
                end
                if checked_band.v == 2 then
                    band = "Вагос"
                elseif checked_band.v == 3 then
                    band = "Баллас"
                elseif checked_band.v == 4 then
                    band = "Вагос"
                elseif checked_band.v == 5 then
                    band = "Ацтек"
                end

                sampSendChat("/jail " .. text_buffer.v .. " " .. arr_cheat[combo_select.v + 1] .. " " .. band .. " " .. nakaz)
            else
                if checked_NakNumber.v == 2 then
                    nakaz = "[1/3]"
                elseif checked_NakNumber.v == 3 then
                    nakaz = "[2/3]"
                elseif checked_NakNumber.v == 4 then
                    nakaz = "[3/3]"
                end
                if checked_band.v == 2 then
                    band = "Вагос"
                elseif checked_band.v == 3 then
                    band = "Баллас"
                elseif checked_band.v == 4 then
                    band = "Вагос"
                elseif checked_band.v == 5 then
                    band = "Ацтек"
                end
                sampSendChat("/ban " .. text_buffer.v .. " " .. arr_cheat[combo_select.v + 1] .. " " .. band .. " " .. nakaz)
            end
        end
    end
    imgui.End()
end


--[[
    radiobutton - круглешки, выбрать 1 пункт
    checkbox - поставить галочку на чекбокс
    combobox - список в котором выбрать пункт

                if imgui.Button("press Me") then
                    sampAddChatMessage(u8:decode(text_buffer.v), -1)
                end

]]
 

Next..

Известный
343
136
как добавить "такое", чтобы ид игрока не нужно было вводить втд игрока, самому.
Нужно чтобы автоматически брался ид игрока, за которым я слежу

Lua:
require "lib.moonloader" -- подключение библиотеки
local keys = require "vkeys"
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local tag = "[My First Script]:" -- локальная переменная
local label = 0
local main_color = 0x5A90CE
local main_color_text = "{5A90CE}"
local white_color = "{FFFFFF}"
local arr_cheat = {"30 Aimbot", "30 WallHack", "10 Spread", "10 Speedhack", "30 Saim", "30 DMG", "30 SK", "10 Provo na SK", "10 Fly", "20 AirBreak", "15 Flycar"}

local main_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)


-- чекбоксы
    local checked_NakNumber        = imgui.ImInt(1)
--

-- радиокнопки
    local checked_band        = imgui.ImInt(1)

    local checked_jail        = imgui.ImInt(1)

--

--комбобоксы
    local combo_select         =imgui.ImInt(0)
--

local sw, sh = getScreenResolution()

function SetStyle()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4

    imgui.GetStyle().WindowPadding = imgui.ImVec2(8, 8)
    imgui.GetStyle().WindowRounding = 0.5
    imgui.GetStyle().FramePadding = imgui.ImVec2(5, 3)
    imgui.GetStyle().ItemSpacing = imgui.ImVec2(4, 4)
    imgui.GetStyle().ItemInnerSpacing = imgui.ImVec2(5, 5)
    imgui.GetStyle().IndentSpacing = 9.0
    imgui.GetStyle().ScrollbarSize = 17.0
    imgui.GetStyle().ScrollbarRounding = 16.0
    imgui.GetStyle().GrabMinSize = 7.0
    imgui.GetStyle().GrabRounding = 15.0
    imgui.GetStyle().ChildWindowRounding = 10.0
    imgui.GetStyle().FrameRounding = 7.0

    colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 0.94)
    colors[clr.ComboBg]                = colors[clr.PopupBg]
    colors[clr.Button]                 = ImVec4(0.26, 0.59, 0.98, 0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.ButtonActive]           = ImVec4(0.06, 0.53, 0.98, 1.00)
    colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.16, 0.29, 0.48, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.CloseButton]            = ImVec4(0.41, 0.41, 0.41, 0.50)-- (0.1, 0.9, 0.1, 1.0)
    colors[clr.CloseButtonHovered]     = ImVec4(0.98, 0.39, 0.36, 1.00)
    colors[clr.CloseButtonActive]      = ImVec4(0.98, 0.39, 0.36, 1.00)
    colors[clr.TextSelectedBg]         = ImVec4(0.26, 0.59, 0.98, 0.35)
    colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.FrameBg]                = ImVec4(0.16, 0.29, 0.48, 0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.26, 0.59, 0.98, 0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.26, 0.59, 0.98, 0.67)
    colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 1.00)
    colors[clr.ScrollbarBg]            = ImVec4(0.02, 0.02, 0.02, 0.53)
    colors[clr.ScrollbarGrab]          = ImVec4(0.31, 0.31, 0.31, 1.00)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.41, 0.41, 0.41, 1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.51, 0.51, 0.51, 1.00)
    colors[clr.CheckMark]              = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.Header]                 = ImVec4(0.26, 0.59, 0.98, 0.31)
    colors[clr.HeaderHovered]          = ImVec4(0.26, 0.59, 0.98, 0.80)
    colors[clr.HeaderActive]           = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.SliderGrab]             = ImVec4(0.24, 0.52, 0.88, 1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.26, 0.59, 0.98, 1.00)
end
SetStyle()

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

    sampRegisterChatCommand("imgui", cmd_imgui)
    sampRegisterChatCommand("check", cmd_check)
    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    nick = sampGetPlayerNickname(rid)

    imgui.Process = false
    --sampAddChatMessage("Скрипт imgui перезагружен", -1)

    while true do
        wait(0)
        if isKeyJustPressed(VK_F3) then
            cmd_imgui()
        end
        if isKeyJustPressed(VK_F4) then
            cmd_check()
        end

        if main_window_state.v == false then
            imgui.Process = false
        end
        -- Блок выполняющийся бесконечно (пока самп активен)

    end
end

function cmd_imgui(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end

function cmd_check(arg)
    sampAddChatMessage(checked_band.v, -1)
end

function imgui.OnDrawFrame()
    imgui.SwitchContext()
    local colors = imgui.GetStyle().Colors;
    local icol = imgui.Col
    local ImVec4 = imgui.ImVec4

    imgui.GetStyle().WindowPadding = imgui.ImVec2(10, 10)
    imgui.GetStyle().WindowRounding = 10.0
    imgui.GetStyle().FramePadding = imgui.ImVec2(5, 4)
    imgui.GetStyle().ItemSpacing = imgui.ImVec2(4, 4)
    imgui.GetStyle().ItemInnerSpacing = imgui.ImVec2(5, 5)
    imgui.GetStyle().IndentSpacing = 9.0
    imgui.GetStyle().ScrollbarSize = 17.0
    imgui.GetStyle().ScrollbarRounding = 20.0
    imgui.GetStyle().GrabMinSize = 7.0
    imgui.GetStyle().GrabRounding = 20.0
    imgui.GetStyle().ChildWindowRounding = 6.0
    imgui.GetStyle().FrameRounding = 20.0

    colors[icol.Text]                   = ImVec4(0.11, 0.11, 0.11, 1.00);
    colors[icol.TextDisabled]           = ImVec4(0.60, 0.60, 0.60, 1.00);
    colors[icol.WindowBg]               = ImVec4(0.90, 0.90, 0.90, 1.00);
    colors[icol.ChildWindowBg]          = ImVec4(0.13, 0.13, 0.13, 1.00);
    colors[icol.PopupBg]                = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.Border]                 = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.BorderShadow]           = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.FrameBg]                = ImVec4(0.26, 0.46, 0.82, 0.59);
    colors[icol.FrameBgHovered]         = ImVec4(0.26, 0.46, 0.82, 0.88);
    colors[icol.FrameBgActive]          = ImVec4(0.28, 0.53, 1.00, 1.00);
    colors[icol.TitleBg]                = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.TitleBgActive]          = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.TitleBgCollapsed]       = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.MenuBarBg]              = ImVec4(0.26, 0.46, 0.82, 0.75);
    colors[icol.ScrollbarBg]            = ImVec4(0.11, 0.11, 0.11, 1.00);
    colors[icol.ScrollbarGrab]          = ImVec4(0.26, 0.46, 0.82, 0.68);
    colors[icol.ScrollbarGrabHovered]   = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.ScrollbarGrabActive]    = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.ComboBg]                = ImVec4(0.26, 0.46, 0.82, 0.79);
    colors[icol.CheckMark]              = ImVec4(0.000, 0.000, 0.000, 1.000)
    colors[icol.SliderGrab]             = ImVec4(0.263, 0.459, 0.824, 1.000)
    colors[icol.SliderGrabActive]       = ImVec4(0.20, 0.20, 0.20, 1.00);
    colors[icol.Button]                 = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.ButtonHovered]          = ImVec4(0.26, 0.46, 0.82, 0.59);
    colors[icol.ButtonActive]           = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.Header]                 = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.HeaderHovered]          = ImVec4(0.26, 0.46, 0.82, 0.74);
    colors[icol.HeaderActive]           = ImVec4(0.26, 0.46, 0.82, 1.00);
    colors[icol.Separator]              = ImVec4(0.37, 0.37, 0.37, 1.00);
    colors[icol.SeparatorHovered]       = ImVec4(0.60, 0.60, 0.70, 1.00);
    colors[icol.SeparatorActive]        = ImVec4(0.70, 0.70, 0.90, 1.00);
    colors[icol.ResizeGrip]             = ImVec4(1.00, 1.00, 1.00, 0.30);
    colors[icol.ResizeGripHovered]      = ImVec4(1.00, 1.00, 1.00, 0.60);
    colors[icol.ResizeGripActive]       = ImVec4(1.00, 1.00, 1.00, 0.90);
    colors[icol.CloseButton]            = ImVec4(0.90, 0.90, 0.90, 1.00);
    colors[icol.CloseButtonHovered]     = ImVec4(0.50, 0.50, 0.50, 0.60);
    colors[icol.CloseButtonActive]      = ImVec4(0.35, 0.35, 0.35, 1.00);
    colors[icol.PlotLines]              = ImVec4(1.00, 1.00, 1.00, 1.00);
    colors[icol.PlotLinesHovered]       = ImVec4(0.90, 0.70, 0.00, 1.00);
    colors[icol.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00);
    colors[icol.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00);
    colors[icol.TextSelectedBg]         = ImVec4(0.00, 0.00, 1.00, 0.35);
    colors[icol.ModalWindowDarkening]   = ImVec4(0.20, 0.20, 0.20, 0.35);
    if not main_window_state.v then
        imgui.Process = false
    end
  
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(500, 320), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

        imgui.Begin("Ghetto Helper", main_window_state) -- название окна

        imgui.RadioButton(u8"Грув", checked_band, 2)            -- название круга, переменная,
        imgui.SameLine()
        imgui.RadioButton(u8"Баллас", checked_band, 3)            -- название круга, переменная,
        imgui.SameLine()
        imgui.RadioButton(u8"Вагос", checked_band, 4)            -- название круга, переменная,
        imgui.SameLine()
        imgui.RadioButton(u8"Ацтек", checked_band, 5)            -- название круга, переменная,

        imgui.Separator()

        imgui.RadioButton(u8"Наказание 1/3", checked_NakNumber, 2)            -- название квадрата, переменная.
        imgui.RadioButton(u8"Наказание 2/3", checked_NakNumber, 3)            -- название квадрата, переменная.
        imgui.RadioButton(u8"Наказание 3/3", checked_NakNumber, 4)            -- название квадрата, переменная.

        imgui.Separator()

        imgui.RadioButton(u8"Jail", checked_jail, 2)            -- название квадрата, переменная.
        imgui.RadioButton(u8"Ban", checked_jail, 4)


        imgui.Combo(u8"Причина", combo_select, arr_cheat, #arr_cheat)

        imgui.InputText(u8"id/nickname игрока", text_buffer)


        if imgui.Button(u8"Наказать!") then
            if checked_jail.v == 2 then
                if checked_NakNumber.v == 2 then
                    nakaz = "[1/3]"
                elseif checked_NakNumber.v == 3 then
                    nakaz = "[2/3]"
                elseif checked_NakNumber.v == 4 then
                    nakaz = "[3/3]"
                end
                if checked_band.v == 2 then
                    band = "Вагос"
                elseif checked_band.v == 3 then
                    band = "Баллас"
                elseif checked_band.v == 4 then
                    band = "Вагос"
                elseif checked_band.v == 5 then
                    band = "Ацтек"
                end

                sampSendChat("/jail " .. text_buffer.v .. " " .. arr_cheat[combo_select.v + 1] .. " " .. band .. " " .. nakaz)
            else
                if checked_NakNumber.v == 2 then
                    nakaz = "[1/3]"
                elseif checked_NakNumber.v == 3 then
                    nakaz = "[2/3]"
                elseif checked_NakNumber.v == 4 then
                    nakaz = "[3/3]"
                end
                if checked_band.v == 2 then
                    band = "Вагос"
                elseif checked_band.v == 3 then
                    band = "Баллас"
                elseif checked_band.v == 4 then
                    band = "Вагос"
                elseif checked_band.v == 5 then
                    band = "Ацтек"
                end
                sampSendChat("/ban " .. text_buffer.v .. " " .. arr_cheat[combo_select.v + 1] .. " " .. band .. " " .. nakaz)
            end
        end
    end
    imgui.End()
end


--[[
    radiobutton - круглешки, выбрать 1 пункт
    checkbox - поставить галочку на чекбокс
    combobox - список в котором выбрать пункт

                if imgui.Button("press Me") then
                    sampAddChatMessage(u8:decode(text_buffer.v), -1)
                end

]]
Код:
local se = require 'lib.samp.events'
function se.onTogglePlayerSpectating(state)
    if state then
        specc = true
    else
        specc = false
    end
end

function se.onSpectatePlayer(id, type)
    if specc then
        if sampGetPlayerNickname(id) ==
    end
end

function se.onSpectateVehicle(id, type)
    if specc then
        sampAddChatMessage(id..type, 'color')
    end
end
 

Alkoigel

Участник
116
15
Код:
local se = require 'lib.samp.events'
function se.onTogglePlayerSpectating(state)
    if state then
        specc = true
    else
        specc = false
    end
end

function se.onSpectatePlayer(id, type)
    if specc then
        if sampGetPlayerNickname(id) ==
    end
end

function se.onSpectateVehicle(id, type)
    if specc then
        sampAddChatMessage(id..type, 'color')
    end
end
то есть я просто заменяю здесь

sampSendChat("/jail " .. text_buffer.v .. " " .. arr_cheat[combo_select.v + 1] .. " " .. band .. " " .. nakaz)
на вот так?
sampSendChat("/jail " .. id .. " " .. arr_cheat[combo_select.v + 1] .. " " .. band .. " " .. nakaz)

?
 

artemka20046

Известный
94
13
Че делать...
 

Вложения

  • 1623322576626.png
    1623322576626.png
    55.3 KB · Просмотры: 41

Next..

Известный
343
136
то есть я просто заменяю здесь

sampSendChat("/jail " .. text_buffer.v .. " " .. arr_cheat[combo_select.v + 1] .. " " .. band .. " " .. nakaz)
на вот так?
sampSendChat("/jail " .. id .. " " .. arr_cheat[combo_select.v + 1] .. " " .. band .. " " .. nakaz)

?
Lua:
local se = require 'lib.samp.events'
local ids = -1

sampSendChat("/jail " .. ids .. " " .. arr_cheat[combo_select.v + 1] .. " " .. band .. " " .. nakaz)

function se.onTogglePlayerSpectating(state)
    if state then
        specc = true
    else
        specc = false
    end
end

function se.onSpectatePlayer(id, type)
    if specc then
        ids = id
    end
end
 

ghostex

Активный
181
31
Вот полная тема, что просто мешало поискать в интернете?