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

Мира

Участник
455
9
шо то не робитcode=lua]
local sampev = require "lib.samp.events"
local keys = require "vkeys"
require "lib.moonloader"

function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
sampAddChatMessage('Группа вк vk.com/pinkmodssamp',-1)
sampRegisterChatCommand('graf', function()
graf = not graf; sampAddChatMessage(graf and 'Бот запущен' or 'Бот умер',-1)
end)
wait(-1)
end

function cmd()
if sampTextdrawIsExists(2184) then
int vkey(38)
bool down(true)
wait(100)
bool down(false)
end

if sampTextdrawIsExists(2185) then
int vkey(40)
bool down(true)
wait(100)
bool down(false)
end

if sampTextdrawIsExists(2186) then
int vkeys(37)
bool down(true)
wait(100)
bool down(false)
end

if sampTextdrawIsExists(2187) then
int vkeys(39)
end
end

[/code].
Лог ошибки отправь, чтобы было легче её найти.
 

darkjer

Активный
134
68
шо то не робитcode=lua]
local sampev = require "lib.samp.events"
local keys = require "vkeys"
require "lib.moonloader"

function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
sampAddChatMessage('Группа вк vk.com/pinkmodssamp',-1)
sampRegisterChatCommand('graf', function()
graf = not graf; sampAddChatMessage(graf and 'Бот запущен' or 'Бот умер',-1)
end)
wait(-1)
end

function cmd()
if sampTextdrawIsExists(2184) then
int vkey(38)
bool down(true)
wait(100)
bool down(false)
end

if sampTextdrawIsExists(2185) then
int vkey(40)
bool down(true)
wait(100)
bool down(false)
end

if sampTextdrawIsExists(2186) then
int vkeys(37)
bool down(true)
wait(100)
bool down(false)
end

if sampTextdrawIsExists(2187) then
int vkeys(39)
end
end

[/code].
int vkeys это номер клавиши, алло.
Пример:
setVirtualKeyDown(0x02, true)
 
Последнее редактирование:
  • Нравится
Реакции: Biuti

solomonioZ

Участник
23
3
Всем Aс-саляму алейкум. Помогите добавить сюда spread,модельные группы,и индивидуальную настроку оружии
Оем:
dow = false
airbreak = false
jumpbmx = false
lastsmooth = -1
lastdist = -1
multiplier = 1
ncr = false
player = -1
input = imgui.ImBuffer(256)

GUI =
{
    windowState = imgui.ImBool(false),
    currentButtonID = 1,
    aimbot =
    {
        Smooth = imgui.ImFloat(5.0),
        Radius = imgui.ImFloat(80.0),
        Safe = imgui.ImFloat(1.0),
        SuperSmooth = imgui.ImFloat(1.0),
        Enable = imgui.ImBool(false),
        IsFire = imgui.ImBool(false),
        VisibleCheck = imgui.ImBool(false),
        DynamicSmooth = imgui.ImBool(false),
        CFilter = imgui.ImBool(false),
        IgnoreRange = imgui.ImBool(false),
        IgnoreStun = imgui.ImBool(false)
    },
    visual =
    {
        DrawFOV = imgui.ImBool(false),
        ESPLine = imgui.ImBool(false),
        ESPBones = imgui.ImBool(false),
        ESPBox = imgui.ImBool(false),
        ESPInfo = imgui.ImBool(false)
    },
    actor =
    {
        NoStun = imgui.ImBool(false),
        InfiniteRun = imgui.ImBool(false),
        NoFall = imgui.ImBool(false),
        NoCamRestore = imgui.ImBool(false),
        GodMode = imgui.ImBool(false),
        AirBreak = imgui.ImBool(false)
    },
    vehicle =
    {
        SpeedHack = imgui.ImBool(false),
        SpeedSmooth = imgui.ImFloat(20.0),
        Drive = imgui.ImBool(false),
        FastExit = imgui.ImBool(false),
        JumpBMX = imgui.ImBool(false),
        BikeFall = imgui.ImBool(false)
    }
}

local config = inicfg.load({
    settings =
    {
        aimbot_smooth = GUI.aimbot.Smooth.v,
        aimbot_radius = GUI.aimbot.Radius.v,
        aimbot_safe = GUI.aimbot.Safe.v,
        aimbot_supersmooth = GUI.aimbot.SuperSmooth.v,
        aimbot_enable = GUI.aimbot.Enable.v,
        aimbot_isfire = GUI.aimbot.IsFire.v,
        aimbot_visiblecheck = GUI.aimbot.VisibleCheck.v,
        aimbot_dynamicsmooth = GUI.aimbot.DynamicSmooth.v,
        aimbot_cfilter = GUI.aimbot.CFilter.v,
        aimbot_ignorerange = GUI.aimbot.IgnoreRange.v,
        aimbot_ignorestun = GUI.aimbot.IgnoreStun.v,
        visual_drawfov = GUI.visual.DrawFOV.v,
        visual_espline = GUI.visual.ESPLine.v,
        visual_espbones = GUI.visual.ESPBones.v,
        visual_espbox = GUI.visual.ESPBox.v,
        visual_espinfo = GUI.visual.ESPInfo.v,
        actor_nostun = GUI.actor.NoStun.v,
        actor_infiniterun = GUI.actor.InfiniteRun.v,
        actor_nofall = GUI.actor.NoFall.v,
        actor_nocamrestore = GUI.actor.NoCamRestore.v,
        actor_godmode = GUI.actor.GodMode.v,
        actor_airbreak = GUI.actor.AirBreak.v,
        vehicle_speedhack = GUI.vehicle.SpeedHack.v,
        vehicle_speedsmooth = GUI.vehicle.SpeedSmooth.v,
        vehicle_drive = GUI.vehicle.Drive.v,
        vehicle_fastexit = GUI.vehicle.FastExit.v,
        vehicle_jumpbmx = GUI.vehicle.JumpBMX.v,
        vehicle_bikefall = GUI.vehicle.BikeFall.v
    }
})

function load_ini()
    local ini_file = inicfg.load(config)
    if ini_file then
        GUI.aimbot.Smooth.v = ini_file.settings.aimbot_smooth
        GUI.aimbot.Radius.v = ini_file.settings.aimbot_radius
        GUI.aimbot.Safe.v = ini_file.settings.aimbot_safe
        GUI.aimbot.SuperSmooth.v = ini_file.settings.aimbot_supersmooth
        GUI.aimbot.Enable.v = ini_file.settings.aimbot_enable
        GUI.aimbot.IsFire.v = ini_file.settings.aimbot_isfire
        GUI.aimbot.VisibleCheck.v = ini_file.settings.aimbot_visiblecheck
        GUI.aimbot.DynamicSmooth.v = ini_file.settings.aimbot_dynamicsmooth
        GUI.aimbot.CFilter.v = ini_file.settings.aimbot_cfilter
        GUI.aimbot.IgnoreRange.v = ini_file.settings.aimbot_ignorerange
        GUI.aimbot.IgnoreStun.v = ini_file.settings.aimbot_ignorestun
        GUI.visual.DrawFOV.v = ini_file.settings.visual_drawfov
        GUI.visual.ESPLine.v = ini_file.settings.visual_espline
        GUI.visual.ESPBones.v = ini_file.settings.visual_espbones
        GUI.visual.ESPBox.v = ini_file.settings.visual_espbox
        GUI.visual.ESPInfo.v = ini_file.settings.visual_espinfo
        GUI.actor.NoStun.v = ini_file.settings.actor_nostun
        GUI.actor.InfiniteRun.v = ini_file.settings.actor_infiniterun
        GUI.actor.NoFall.v = ini_file.settings.actor_nofall
        GUI.actor.NoCamRestore.v = ini_file.settings.actor_nocamrestore
        GUI.actor.GodMode.v = ini_file.settings.actor_godmode
        GUI.actor.AirBreak.v = ini_file.settings.actor_airbreak
        GUI.vehicle.SpeedHack.v = ini_file.settings.vehicle_speedhack
        GUI.vehicle.SpeedSmooth.v = ini_file.settings.vehicle_speedsmooth
        GUI.vehicle.Drive.v = ini_file.settings.vehicle_drive
        GUI.vehicle.FastExit.v = ini_file.settings.vehicle_fastexit
        GUI.vehicle.JumpBMX.v = ini_file.settings.vehicle_jumpbmx
        GUI.vehicle.BikeFall.v = ini_file.settings.vehicle_bikefall
    end
end

function save_ini()
    config.settings.aimbot_smooth = GUI.aimbot.Smooth.v
    config.settings.aimbot_radius = GUI.aimbot.Radius.v
    config.settings.aimbot_safe = GUI.aimbot.Safe.v
    config.settings.aimbot_supersmooth = GUI.aimbot.SuperSmooth.v
    config.settings.aimbot_enable = GUI.aimbot.Enable.v
    config.settings.aimbot_isfire = GUI.aimbot.IsFire.v
    config.settings.aimbot_visiblecheck = GUI.aimbot.VisibleCheck.v
    config.settings.aimbot_dynamicsmooth = GUI.aimbot.DynamicSmooth.v
    config.settings.aimbot_cfilter = GUI.aimbot.CFilter.v
    config.settings.aimbot_ignorerange = GUI.aimbot.IgnoreRange.v
    config.settings.aimbot_ignorestun = GUI.aimbot.IgnoreStun.v
    config.settings.visual_drawfov = GUI.visual.DrawFOV.v
    config.settings.visual_espline = GUI.visual.ESPLine.v
    config.settings.visual_espbones = GUI.visual.ESPBones.v
    config.settings.visual_espbox = GUI.visual.ESPBox.v
    config.settings.visual_espinfo = GUI.visual.ESPInfo.v
    config.settings.actor_nostun = GUI.actor.NoStun.v
    config.settings.actor_infiniterun = GUI.actor.InfiniteRun.v
    config.settings.actor_nofall = GUI.actor.NoFall.v
    config.settings.actor_nocamrestore = GUI.actor.NoCamRestore.v
    config.settings.actor_godmode = GUI.actor.GodMode.v
    config.settings.actor_airbreak = GUI.actor.AirBreak.v
    config.settings.vehicle_speedhack = GUI.vehicle.SpeedHack.v
    config.settings.vehicle_speedsmooth = GUI.vehicle.SpeedSmooth.v
    config.settings.vehicle_drive = GUI.vehicle.Drive.v
    config.settings.vehicle_fastexit = GUI.vehicle.FastExit.v
    config.settings.vehicle_jumpbmx = GUI.vehicle.JumpBMX.v
    config.settings.vehicle_bikefall = GUI.vehicle.BikeFall.v
    inicfg.save(config, script.this.filename..'.ini')
end

function reset_ini()
    GUI =
    {
        windowState = imgui.ImBool(true),
        currentButtonID = 1,
        aimbot =
        {
            Smooth = imgui.ImFloat(5.0),
            Radius = imgui.ImFloat(80.0),
            Safe = imgui.ImFloat(1.0),
            SuperSmooth = imgui.ImFloat(1.0),
            Enable = imgui.ImBool(false),
            IsFire = imgui.ImBool(false),
            VisibleCheck = imgui.ImBool(false),
            DynamicSmooth = imgui.ImBool(false),
            CFilter = imgui.ImBool(false),
            IgnoreRange = imgui.ImBool(false),
            IgnoreStun = imgui.ImBool(false)
        },
        visual =
        {
            DrawFOV = imgui.ImBool(false),
            ESPLine = imgui.ImBool(false),
            ESPBones = imgui.ImBool(false),
            ESPBox = imgui.ImBool(false),
            ESPInfo = imgui.ImBool(false)
        },
        actor =
        {
            NoStun = imgui.ImBool(false),
            InfiniteRun = imgui.ImBool(false),
            NoFall = imgui.ImBool(false),
            NoCamRestore = imgui.ImBool(false),
            GodMode = imgui.ImBool(false),
            AirBreak = imgui.ImBool(false)
        },
        vehicle =
        {
            SpeedHack = imgui.ImBool(false),
            SpeedSmooth = imgui.ImFloat(20.0),
            Drive = imgui.ImBool(false),
            FastExit = imgui.ImBool(false),
            JumpBMX = imgui.ImBool(false),
            BikeFall = imgui.ImBool(false)
        }
    }
    save_ini()
end

function main()
    if not initialized then
        if not isSampAvailable() then return false end
        load_ini()
        guiCustomStyle()
        lua_thread.create(Aimbot)
        lua_thread.create(Visual)
        lua_thread.create(Actor)
        lua_thread.create(Vehicle)
        initialized = true
    end
    if wasKeyPressed(VK_INSERT) then
        GUI.windowState.v = not GUI.windowState.v
    end
    imgui.Process = GUI.windowState.v
    return false
end

function imgui.OnDrawFrame()
    if GUI.windowState.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(319, 300), imgui.Cond.FirstUseEver)
        imgui.Begin('HELLFIRE SOFT', nil, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoMove)
        imgui.SetCursorPos(imgui.ImVec2(5, 25))
        if imgui.Button('Smooth', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 1
        end
        imgui.SetCursorPos(imgui.ImVec2(57, 25))
        if imgui.Button('Visual', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 2
        end
        imgui.SetCursorPos(imgui.ImVec2(109, 25))
        if imgui.Button('Actor', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 3
        end
        imgui.SetCursorPos(imgui.ImVec2(161, 25))
        if imgui.Button('Vehicle', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 4
        end
        imgui.SetCursorPos(imgui.ImVec2(213, 25))
        if imgui.Button('Config', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 5
        end
        imgui.SetCursorPos(imgui.ImVec2(265, 25))
        if imgui.Button('Console', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 6
        end
        if GUI.currentButtonID == 1 then
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('Smooth', GUI.aimbot.Smooth, 1.0, 25.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('Radius', GUI.aimbot.Radius, 1.0, 300.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('SafeZone', GUI.aimbot.Safe, 1.0, 300.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('SuperSmooth', GUI.aimbot.SuperSmooth, 1.0, 25.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.Checkbox('Enable', GUI.aimbot.Enable)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('IsFire', GUI.aimbot.IsFire)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('VisibleCheck', GUI.aimbot.VisibleCheck)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('DynamicSmooth', GUI.aimbot.DynamicSmooth)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('CFilter', GUI.aimbot.CFilter)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('IgnoreRange', GUI.aimbot.IgnoreRange)
            imgui.SetCursorPos(imgui.ImVec2(150, 149))
            imgui.Checkbox('IgnoreStun', GUI.aimbot.IgnoreStun)
        end
        if GUI.currentButtonID == 2 then
            imgui.SetCursorPosX(5)
            imgui.Checkbox('ESP Line', GUI.visual.ESPLine)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('ESP Bones', GUI.visual.ESPBones)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('ESP Box', GUI.visual.ESPBox)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('ESP Info', GUI.visual.ESPInfo)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('Draw FOV', GUI.visual.DrawFOV)
        end
        if GUI.currentButtonID == 3 then
            imgui.SetCursorPosX(5)
            imgui.Checkbox('NoStun', GUI.actor.NoStun)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('NoFall', GUI.actor.NoFall)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('NoCamRestore', GUI.actor.NoCamRestore)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('InfiniteRun', GUI.actor.InfiniteRun)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('GodMode', GUI.actor.GodMode)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('AirBreak', GUI.actor.AirBreak)
        end
        if GUI.currentButtonID == 4 then
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('SpeedSmooth', GUI.vehicle.SpeedSmooth, 1.0, 30.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.Checkbox('SpeedHack', GUI.vehicle.SpeedHack)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('DriveInWater', GUI.vehicle.Drive)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('FastExit', GUI.vehicle.FastExit)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('JumpBMX', GUI.vehicle.JumpBMX)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('BikeFall', GUI.vehicle.BikeFall)
        end
        if GUI.currentButtonID == 5 then
            imgui.SetCursorPosX(5)
            if imgui.Button('Load', imgui.ImVec2(310, 25)) then load_ini() end
            imgui.SetCursorPosX(5)
            if imgui.Button('Save', imgui.ImVec2(310, 25)) then save_ini() end
            imgui.SetCursorPosX(5)
            if imgui.Button('Reset', imgui.ImVec2(310, 25)) then reset_ini() end
        end
        if GUI.currentButtonID == 6 then
            imgui.SetCursorPosX(5)
            imgui.InputText('Input', input)
            imgui.SetCursorPosX(5)
            if imgui.Button('Send') then
                if input.v == 'DEATH' or input.v == 'death' then
                    setCharHealth(PLAYER_PED, 0)
                end
                if input.v == 'RECON' or input.v == 'recon' then
                    local ip, port = sampGetCurrentServerAddress()
                    sampDisconnectWithReason(false)
                    sampConnectToServer(ip, port)
                end
                if input.v == 'RELOAD' or input.v == 'reload' then
                    sampToggleCursor(false)
                    showCursor(false)
                    thisScript():reload()
                end
                input.v = ''
            end
            imgui.Text('All commands:\n\nDEATH\nRECON\nRELOAD')
        end
        imgui.End()
    end
end

function Aimbot()
    if GUI.aimbot.Enable.v and isKeyDown(VK_RBUTTON) then
        if not GUI.aimbot.IsFire.v or (GUI.aimbot.IsFire.v and isKeyDown(VK_LBUTTON)) then
            local playerID = GetNearestPed()
            if playerID ~= -1 then
                local pedID = sampGetPlayerIdByCharHandle(PLAYER_PED)
                if (GUI.aimbot.IgnoreStun.v and not CheckStuned()) then return false end
                if (GUI.aimbot.CFilter.v and sampGetPlayerColor(pedID) == sampGetPlayerColor(playerID)) then return false end
                local _, handle = sampGetCharHandleBySampPlayerId(playerID)
                local myPos = {getActiveCameraCoordinates()}
                local enPos = {GetBodyPartCoordinates(GetNearestBone(handle), handle)}
                if not GUI.aimbot.VisibleCheck.v or (GUI.aimbot.VisibleCheck.v and isLineOfSightClear(myPos[1], myPos[2], myPos[3], enPos[1], enPos[2], enPos[3], true, true, false, true, true)) then
                    local pedWeapon = getCurrentCharWeapon(PLAYER_PED)
                    if (pedWeapon >= 22 and pedWeapon <= 29) or pedWeapon == 32 then
                        coefficent = 0.04253
                    elseif pedWeapon == 30 or pedWeapon == 31 then
                        coefficent = 0.028
                    elseif pedWeapon == 33 then
                        сoefficent = 0.01897
                    end
                    local vector = {myPos[1] - enPos[1], myPos[2] - enPos[2]}
                    local angle = math.acos(vector[1] / math.sqrt((math.pow(vector[1], 2) + math.pow(vector[2], 2))))
                    local view = {fix(representIntAsFloat(readMemory(0xB6F258, 4, false))), fix(representIntAsFloat(readMemory(0xB6F248, 4, false)))}
                    if (vector[1] <= 0.0 and vector[2] >= 0.0) or (vector[1] >= 0.0 and vector[2] >= 0.0) then
                        dif = (angle + coefficent) - view[1]
                    end
                    if (vector[1] >= 0.0 and vector[2] <= 0.0) or (vector[1] <= 0.0 and vector[2] <= 0.0) then
                        dif = (-angle + coefficent) - view[1]
                    end
                    if GUI.aimbot.DynamicSmooth.v then multiplier = 5 else multiplier = 1 end
                    local smooth = dif / ((GUI.aimbot.Smooth.v * multiplier) * GUI.aimbot.SuperSmooth.v)
                    if GUI.aimbot.DynamicSmooth.v then
                        if smooth > 0.0 then
                            if smooth < lastsmooth then
                                smooth = smooth * (lastsmooth / smooth)
                            end
                        else
                            if -smooth < -lastsmooth then
                                smooth = smooth * (-lastsmooth / -smooth)
                            end
                        end
                        lastsmooth = smooth
                    end
                    if smooth > -1.0 and smooth < 0.5 and dif > -2.0 and dif < 2.0 then
                        view[1] = view[1] + smooth
                        setCameraPositionUnfixed(view[2], view[1])
                    end
                end
            end
        end
    end
    return false
end

function Visual()
    if GUI.visual.DrawFOV.v then
        local crosshairPos = {convertGameScreenCoordsToWindowScreenCoords(339.1, 179.1)}
        renderFigure2D(crosshairPos[1], crosshairPos[2], GUI.aimbot.Radius.v >= 70 and 144 or 72, (GUI.aimbot.Radius.v - 1.0), 0xFF00FF00)
        renderFigure2D(crosshairPos[1], crosshairPos[2], GUI.aimbot.Safe.v >= 70 and 144 or 72, (GUI.aimbot.Safe.v - 1.0), 0xFFFF0000)
    end
    for i = 0, sampGetMaxPlayerId(true) do
        if sampIsPlayerConnected(i) then
            local find, handle = sampGetCharHandleBySampPlayerId(i)
            if find then
                 if isCharOnScreen(handle) then
                    local myPos = {GetBodyPartCoordinates(3, PLAYER_PED)}
                    local enPos = {GetBodyPartCoordinates(3, handle)}
                    if (isLineOfSightClear(myPos[1], myPos[2], myPos[3], enPos[1], enPos[2], enPos[3], true, true, false, true, true)) then
                        color = 0xFF00FF00
                    else
                        color = 0xFFFF0000
                    end
                    if GUI.visual.ESPLine.v then
                        local myPosScreen = {convert3DCoordsToScreen(GetBodyPartCoordinates(3, PLAYER_PED))}
                        local enPosScreen = {convert3DCoordsToScreen(GetBodyPartCoordinates(3, handle))}
                        renderDrawLine(myPosScreen[1], myPosScreen[2], enPosScreen[1], enPosScreen[2], 1, color)
                    end
                    if GUI.visual.ESPBones.v then
                        local t = {3, 4, 5, 51, 52, 41, 42, 31, 32, 33, 21, 22, 23, 2}
                        for v = 1, #t do
                            pos1 = {GetBodyPartCoordinates(t[v], handle)}
                            pos2 = {GetBodyPartCoordinates(t[v] + 1, handle)}
                            pos1Screen = {convert3DCoordsToScreen(pos1[1], pos1[2], pos1[3])}
                            pos2Screen = {convert3DCoordsToScreen(pos2[1], pos2[2], pos2[3])}
                            renderDrawLine(pos1Screen[1], pos1Screen[2], pos2Screen[1], pos2Screen[2], 1, color)
                        end
                        for v = 4, 5 do
                            pos2 = {GetBodyPartCoordinates(v * 10 + 1, handle)}
                            pos2Screen = {convert3DCoordsToScreen(pos2[1], pos2[2], pos2[3])}
                            renderDrawLine(pos1Screen[1], pos1Screen[2], pos2Screen[1], pos2Screen[2], 1, color)
                        end
                        local t = {53, 43, 24, 34, 6}
                        for v = 1, #t do
                            pos = {GetBodyPartCoordinates(t[v], handle)}
                            pos1Screen = {convert3DCoordsToScreen(pos[1], pos[2], pos[3])}
                        end
                    end
                    if GUI.visual.ESPBox.v then
                        local headPos = {GetBodyPartCoordinates(8, handle)}
                        local footPos = {GetBodyPartCoordinates(44, handle)}
                        local pointOne =
                        {
                            x = headPos[1] - 0.5,
                            y = headPos[2],
                            z = headPos[3] + 0.35
                        }
                        local pointTwo =
                        {
                            x = headPos[1] + 0.5,
                            y = headPos[2],
                            z = headPos[3] - 0.35
                        }
                        local pointThree =
                        {
                            x = footPos[1] + 0.5,
                            y = footPos[2],
                            z = footPos[3] - 0.35
                        }
                        local pointOneScreen = {convert3DCoordsToScreen(pointOne.x, pointOne.y, pointOne.z)}
                        local pointTwoScreen = {convert3DCoordsToScreen(pointTwo.x, pointTwo.y, pointOne.z)}
                        local pointThreeScreen = {convert3DCoordsToScreen(pointOne.x, pointThree.y, pointThree.z)}
                        local pointFourScreen = {convert3DCoordsToScreen(pointTwo.x, pointThree.y, pointThree.z)}
                        renderDrawLine(pointOneScreen[1], pointOneScreen[2], pointTwoScreen[1], pointTwoScreen[2], 1, color)
                        renderDrawLine(pointThreeScreen[1], pointThreeScreen[2], pointFourScreen[1], pointFourScreen[2], 1, color)
                        renderDrawLine(pointOneScreen[1], pointOneScreen[2], pointThreeScreen[1], pointThreeScreen[2], 1, color)
                        renderDrawLine(pointTwoScreen[1], pointTwoScreen[2], pointFourScreen[1], pointFourScreen[2], 1, color)
                    end
                    if GUI.visual.ESPInfo.v then
                        local enPosGame = {GetBodyPartCoordinates(8, handle)}
                        local point =
                        {
                            x = enPosGame[1] - 0.3,
                            y = enPosGame[2],
                            z = enPosGame[3]
                        }
                        local enPosScr = {convert3DCoordsToScreen(point.x, point.y, point.z)}
                        local distance = math.sqrt((math.pow((enPos[1] - myPos[1]), 2) + math.pow((enPos[2] - myPos[2]), 2) + math.pow((enPos[3] - myPos[3]), 2)))
                        renderFontDrawText(font, string.format('Speed: %.1f\nName: %s\nDistance: %.1f\nSkin: %d\nNPC: %s\nAFK: %s', getCharSpeed(handle), sampGetPlayerNickname(i), distance, getCharModel(handle), tostring(sampIsPlayerNpc(i)), tostring(sampIsPlayerPaused(i))), enPosScr[1], enPosScr[2], color)
                    end
                end
            end
        end
    end
    return false
end

function Actor()
    setCharUsesUpperbodyDamageAnimsOnly(PLAYER_PED, GUI.actor.NoStun.v)
    setPlayerNeverGetsTired(PLAYER_PED, not GUI.actor.InfiniteRun.v)
    if GUI.actor.NoFall.v then
        if isCharPlayingAnim(PLAYER_PED, 'KO_SKID_BACK') or isCharPlayingAnim(PLAYER_PED, 'FALL_COLLAPSE') then
            local charPos = {getCharCoordinates(PLAYER_PED)}
            setCharCoordinates(PLAYER_PED, charPos[1], charPos[2], charPos[3] - 1)
        end
    end
    if GUI.actor.NoCamRestore.v then
        if not ncr then
            memory.write(0x5109AC, 235, 1, true)
            memory.write(0x5109C5, 235, 1, true)
            memory.write(0x5231A6, 235, 1, true)
            memory.write(0x52322D, 235, 1, true)
            memory.write(0x5233BA, 235, 1, true)
            ncr = true
        end
    else
        if ncr then
            memory.write(0x5109AC, 122, 1, true)
            memory.write(0x5109C5, 122, 1, true)
            memory.write(0x5231A6, 117, 1, true)
            memory.write(0x52322D, 117, 1, true)
            memory.write(0x5233BA, 117, 1, true)
            ncr = false
        end
    end
    if GUI.actor.GodMode.v then
        setCharProofs(PLAYER_PED, true, true, true, true, true)
    else
        setCharProofs(PLAYER_PED, false, false, false, false, false)
    end
    if GUI.actor.AirBreak.v then
        if wasKeyPressed(VK_RSHIFT) then
            airbreak = not airbreak
        end
        if airbreak then
            local charCoordinates = {getCharCoordinates(PLAYER_PED)}
            local ViewHeading = getCharHeading(PLAYER_PED)
            Coords = {charCoordinates[1], charCoordinates[2], charCoordinates[3], 0.0, 0.0, ViewHeading}
            local MainHeading = getCharHeading(PLAYER_PED)
            local Camera = {getActiveCameraCoordinates()}
            local Target = {getActiveCameraPointAt()}
            local RotateHeading = getHeadingFromVector2d(Target[1] - Camera[1], Target[2] - Camera[2])
            if isKeyDown(VK_W) then
                Coords[1] = Coords[1] + 0.25 * math.sin(-math.rad(RotateHeading))
                Coords[2] = Coords[2] + 0.25 * math.cos(-math.rad(RotateHeading))
                setCharHeading(PLAYER_PED, RotateHeading)
            elseif isKeyDown(VK_S) then
                Coords[1] = Coords[1] - 0.25 * math.sin(-math.rad(MainHeading))
                Coords[2] = Coords[2] - 0.25 * math.cos(-math.rad(MainHeading))
            end
            if isKeyDown(VK_A) then
                Coords[1] = Coords[1] - 0.25 * math.sin(-math.rad(MainHeading - 90))
                Coords[2] = Coords[2] - 0.25 * math.cos(-math.rad(MainHeading - 90))
            elseif isKeyDown(VK_D) then
                Coords[1] = Coords[1] - 0.25 * math.sin(-math.rad(MainHeading + 90))
                Coords[2] = Coords[2] - 0.25 * math.cos(-math.rad(MainHeading + 90))
            end
            if isKeyDown(VK_SPACE) then Coords[3] = Coords[3] + 0.25 / 1.5 end
            if isKeyDown(VK_LSHIFT) and Coords[3] > -95.0 then Coords[3] = Coords[3] - 0.25 / 1.5 end
            setCharCoordinates(PLAYER_PED, Coords[1], Coords[2], Coords[3] - 1)
        end
    end
    return false
end

function Vehicle()
    if GUI.vehicle.SpeedHack.v then
        if isKeyDown(VK_LMENU) then
            if isCharInAnyCar(PLAYER_PED) then
                local car = storeCarCharIsInNoSave(PLAYER_PED)
                local vector = {getCarSpeedVector(car)}
                local heading = getCarHeading(car)
                local turbo = fpsCorrection() / (GUI.vehicle.SpeedSmooth.v * 10)
                local force = {turbo, turbo, turbo}
                local Sin, Cos = math.sin(-math.rad(heading)), math.cos(-math.rad(heading))
                if vector[1] > -0.01 and vector[1] < 0.01 then force[1] = 0.0 end
                if vector[2] > -0.01 and vector[2] < 0.01 then force[2] = 0.0 end
                if vector[3] < 0 then force[3] = -force[3] end
                if vector[3] > -2 and vector[3] < 15 then force[3] = 0.0 end
                if Sin > 0 and vector[1] < 0 then force[1] = -force[1] end
                if Sin < 0 and vector[1] > 0 then force[1] = -force[1] end
                if Cos > 0 and vector[2] < 0 then force[2] = -force[2] end
                if Cos < 0 and vector[2] > 0 then force[2] = -force[2] end
                applyForceToCar(car, force[1] * Sin, force[2] * Cos, force[3] / 2, 0.0, 0.0, 0.0)
            end
        end
    end
    if GUI.vehicle.Drive.v then
        if not dow then
            memory.write(0x6CC303, 0x621F8A, 3, true)
            memory.write(0x6A90C5, 0xEB, 1, true)
            dow = true
        end
    else
        if dow then
            memory.write(0x6CC303, 0xEFE180, 3, true)
            memory.write(0x6A90C5, 0x7A, 1, true)
            dow = false
        end
    end
    if GUI.vehicle.FastExit.v then
        if wasKeyPressed(VK_F) then
            if isCharInAnyCar(PLAYER_PED) then
                local car = storeCarCharIsInNoSave(PLAYER_PED)
                local speed = getCarSpeed(car)
                clearCharTasksImmediately(PLAYER_PED)
                local pos = {getCharCoordinates(PLAYER_PED)}
                setCharCoordinates(PLAYER_PED, pos[1], pos[2], pos[3] + 2)
            end
        end
    end
    if GUI.vehicle.JumpBMX then
        if not jumpbmx then
            memory.setint8(0x969161, 1)
            jumpbmx = true
        end
    else
        if jumpbmx then
            memory.setint8(0x969161, 0)
            jumpbmx = false
        end
    end
    setCharCanBeKnockedOffBike(PLAYER_PED, GUI.vehicle.BikeFall.v)
    return false
end

function sampev.onSendPlayerSync(data)
    if airbreak then
        data.animationId = 1130
        data.moveSpeed = {x = 0.89, y = 0.89, z = -0.89}
    end
end

function sampev.onSetPlayerPos()
    if airbreak then
        return false
    end
end

function sampev.onRequestSpawnResponse() if GUI.actor.GodMode.v then return false end end
function sampev.onRequestClassResponse() if GUI.actor.GodMode.v then return false end end
function sampev.onResetPlayerWeapons() if GUI.actor.GodMode.v then return false end end
function sampev.onSetCameraBehind() if GUI.actor.GodMode.v then return false end end
function sampev.onTogglePlayerControllable() if GUI.actor.GodMode.v then return false end end
function sampev.onSetPlayerSkin() if GUI.actor.GodMode.v then return false end end
function sampev.onSetPlayerHealth() if GUI.actor.GodMode.v then return false end end
function sampev.onBulletSync() if GUI.actor.GodMode.v then return false end end

function renderFigure2D(x, y, points, radius, color)
    local step = math.pi * 2 / points
    local render_start, render_end = {}, {}
    for i = 0, math.pi * 2, step do
        render_start[1] = radius * math.cos(i) + x
        render_start[2] = radius * math.sin(i) + y
        render_end[1] = radius * math.cos(i + step) + x
        render_end[2] = radius * math.sin(i + step) + y
        renderDrawLine(render_start[1], render_start[2], render_end[1], render_end[2], 1, color)
    end
end

function fpsCorrection()
    return representIntAsFloat(readMemory(0xB7CB5C, 4, false))
end

function fix(angle)
    if angle > math.pi then
        angle = angle - (math.pi * 2)
    elseif angle < -math.pi then
        angle = angle + (math.pi * 2)
    end
    return angle
end

function GetNearestPed()
    local maxDistance = nil
    if not GUI.aimbot.IgnoreRange.v then maxDistance = 35 else maxDistance = 20000 end
    local nearestPED = -1
    for i = 0, sampGetMaxPlayerId(true) do
        if sampIsPlayerConnected(i) then
            local find, handle = sampGetCharHandleBySampPlayerId(i)
            if find then
                if isCharOnScreen(handle) then
                    if not isCharDead(handle) then
                        local crosshairPos = {convertGameScreenCoordsToWindowScreenCoords(339.1, 179.1)}
                        local enPos = {GetBodyPartCoordinates(GetNearestBone(handle), handle)}
                        local bonePos = {convert3DCoordsToScreen(enPos[1], enPos[2], enPos[3])}
                        local distance = math.sqrt((math.pow((bonePos[1] - crosshairPos[1]), 2) + math.pow((bonePos[2] - crosshairPos[2]), 2)))
                        if distance < GUI.aimbot.Safe.v or distance > GUI.aimbot.Radius.v then check = true else check = false end
                        if not check then
                            local myPos = {getCharCoordinates(PLAYER_PED)}
                            local enPos = {getCharCoordinates(handle)}
                            local distance = math.sqrt((math.pow((enPos[1] - myPos[1]), 2) + math.pow((enPos[2] - myPos[2]), 2) + math.pow((enPos[3] - myPos[3]), 2)))
                            if (distance < maxDistance) then
                                nearestPED = i
                                maxDistance = distance
                            end
                        end
                    end
                end
            end
        end
    end
    return nearestPED
end

function CheckStuned()
    for k, v in pairs(anims) do
        if isCharPlayingAnim(PLAYER_PED, v) then
            return false
        end
    end
    return true
end

function GetNearestBone(handle)
    local maxDist = 20000
    local nearestBone = -1
    bone = {42, 52, 23, 33, 3, 22, 32, 8}
    for n = 1, 8 do
        local crosshairPos = {convertGameScreenCoordsToWindowScreenCoords(339.1, 179.1)}
        local bonePos = {GetBodyPartCoordinates(bone[n], handle)}
        local enPos = {convert3DCoordsToScreen(bonePos[1], bonePos[2], bonePos[3])}
        local distance = math.sqrt((math.pow((enPos[1] - crosshairPos[1]), 2) + math.pow((enPos[2] - crosshairPos[2]), 2)))
        if (distance < maxDist) then
            nearestBone = bone[n]
            maxDist = distance
        end
    end
    return nearestBone
end

function GetBodyPartCoordinates(id, handle)
    if doesCharExist(handle) then
        local pedptr = getCharPointer(handle)
        local vec = ffi.new("float[3]")
        getbonePosition(ffi.cast("void*", pedptr), vec, id, true)
        return vec[0], vec[1], vec[2]
    end
end
 

darkjer

Активный
134
68
Как ускорить анимку?
Всем Aс-саляму алейкум. Помогите добавить сюда spread,модельные группы,и индивидуальную настроку оружии
Оем:
dow = false
airbreak = false
jumpbmx = false
lastsmooth = -1
lastdist = -1
multiplier = 1
ncr = false
player = -1
input = imgui.ImBuffer(256)

GUI =
{
    windowState = imgui.ImBool(false),
    currentButtonID = 1,
    aimbot =
    {
        Smooth = imgui.ImFloat(5.0),
        Radius = imgui.ImFloat(80.0),
        Safe = imgui.ImFloat(1.0),
        SuperSmooth = imgui.ImFloat(1.0),
        Enable = imgui.ImBool(false),
        IsFire = imgui.ImBool(false),
        VisibleCheck = imgui.ImBool(false),
        DynamicSmooth = imgui.ImBool(false),
        CFilter = imgui.ImBool(false),
        IgnoreRange = imgui.ImBool(false),
        IgnoreStun = imgui.ImBool(false)
    },
    visual =
    {
        DrawFOV = imgui.ImBool(false),
        ESPLine = imgui.ImBool(false),
        ESPBones = imgui.ImBool(false),
        ESPBox = imgui.ImBool(false),
        ESPInfo = imgui.ImBool(false)
    },
    actor =
    {
        NoStun = imgui.ImBool(false),
        InfiniteRun = imgui.ImBool(false),
        NoFall = imgui.ImBool(false),
        NoCamRestore = imgui.ImBool(false),
        GodMode = imgui.ImBool(false),
        AirBreak = imgui.ImBool(false)
    },
    vehicle =
    {
        SpeedHack = imgui.ImBool(false),
        SpeedSmooth = imgui.ImFloat(20.0),
        Drive = imgui.ImBool(false),
        FastExit = imgui.ImBool(false),
        JumpBMX = imgui.ImBool(false),
        BikeFall = imgui.ImBool(false)
    }
}

local config = inicfg.load({
    settings =
    {
        aimbot_smooth = GUI.aimbot.Smooth.v,
        aimbot_radius = GUI.aimbot.Radius.v,
        aimbot_safe = GUI.aimbot.Safe.v,
        aimbot_supersmooth = GUI.aimbot.SuperSmooth.v,
        aimbot_enable = GUI.aimbot.Enable.v,
        aimbot_isfire = GUI.aimbot.IsFire.v,
        aimbot_visiblecheck = GUI.aimbot.VisibleCheck.v,
        aimbot_dynamicsmooth = GUI.aimbot.DynamicSmooth.v,
        aimbot_cfilter = GUI.aimbot.CFilter.v,
        aimbot_ignorerange = GUI.aimbot.IgnoreRange.v,
        aimbot_ignorestun = GUI.aimbot.IgnoreStun.v,
        visual_drawfov = GUI.visual.DrawFOV.v,
        visual_espline = GUI.visual.ESPLine.v,
        visual_espbones = GUI.visual.ESPBones.v,
        visual_espbox = GUI.visual.ESPBox.v,
        visual_espinfo = GUI.visual.ESPInfo.v,
        actor_nostun = GUI.actor.NoStun.v,
        actor_infiniterun = GUI.actor.InfiniteRun.v,
        actor_nofall = GUI.actor.NoFall.v,
        actor_nocamrestore = GUI.actor.NoCamRestore.v,
        actor_godmode = GUI.actor.GodMode.v,
        actor_airbreak = GUI.actor.AirBreak.v,
        vehicle_speedhack = GUI.vehicle.SpeedHack.v,
        vehicle_speedsmooth = GUI.vehicle.SpeedSmooth.v,
        vehicle_drive = GUI.vehicle.Drive.v,
        vehicle_fastexit = GUI.vehicle.FastExit.v,
        vehicle_jumpbmx = GUI.vehicle.JumpBMX.v,
        vehicle_bikefall = GUI.vehicle.BikeFall.v
    }
})

function load_ini()
    local ini_file = inicfg.load(config)
    if ini_file then
        GUI.aimbot.Smooth.v = ini_file.settings.aimbot_smooth
        GUI.aimbot.Radius.v = ini_file.settings.aimbot_radius
        GUI.aimbot.Safe.v = ini_file.settings.aimbot_safe
        GUI.aimbot.SuperSmooth.v = ini_file.settings.aimbot_supersmooth
        GUI.aimbot.Enable.v = ini_file.settings.aimbot_enable
        GUI.aimbot.IsFire.v = ini_file.settings.aimbot_isfire
        GUI.aimbot.VisibleCheck.v = ini_file.settings.aimbot_visiblecheck
        GUI.aimbot.DynamicSmooth.v = ini_file.settings.aimbot_dynamicsmooth
        GUI.aimbot.CFilter.v = ini_file.settings.aimbot_cfilter
        GUI.aimbot.IgnoreRange.v = ini_file.settings.aimbot_ignorerange
        GUI.aimbot.IgnoreStun.v = ini_file.settings.aimbot_ignorestun
        GUI.visual.DrawFOV.v = ini_file.settings.visual_drawfov
        GUI.visual.ESPLine.v = ini_file.settings.visual_espline
        GUI.visual.ESPBones.v = ini_file.settings.visual_espbones
        GUI.visual.ESPBox.v = ini_file.settings.visual_espbox
        GUI.visual.ESPInfo.v = ini_file.settings.visual_espinfo
        GUI.actor.NoStun.v = ini_file.settings.actor_nostun
        GUI.actor.InfiniteRun.v = ini_file.settings.actor_infiniterun
        GUI.actor.NoFall.v = ini_file.settings.actor_nofall
        GUI.actor.NoCamRestore.v = ini_file.settings.actor_nocamrestore
        GUI.actor.GodMode.v = ini_file.settings.actor_godmode
        GUI.actor.AirBreak.v = ini_file.settings.actor_airbreak
        GUI.vehicle.SpeedHack.v = ini_file.settings.vehicle_speedhack
        GUI.vehicle.SpeedSmooth.v = ini_file.settings.vehicle_speedsmooth
        GUI.vehicle.Drive.v = ini_file.settings.vehicle_drive
        GUI.vehicle.FastExit.v = ini_file.settings.vehicle_fastexit
        GUI.vehicle.JumpBMX.v = ini_file.settings.vehicle_jumpbmx
        GUI.vehicle.BikeFall.v = ini_file.settings.vehicle_bikefall
    end
end

function save_ini()
    config.settings.aimbot_smooth = GUI.aimbot.Smooth.v
    config.settings.aimbot_radius = GUI.aimbot.Radius.v
    config.settings.aimbot_safe = GUI.aimbot.Safe.v
    config.settings.aimbot_supersmooth = GUI.aimbot.SuperSmooth.v
    config.settings.aimbot_enable = GUI.aimbot.Enable.v
    config.settings.aimbot_isfire = GUI.aimbot.IsFire.v
    config.settings.aimbot_visiblecheck = GUI.aimbot.VisibleCheck.v
    config.settings.aimbot_dynamicsmooth = GUI.aimbot.DynamicSmooth.v
    config.settings.aimbot_cfilter = GUI.aimbot.CFilter.v
    config.settings.aimbot_ignorerange = GUI.aimbot.IgnoreRange.v
    config.settings.aimbot_ignorestun = GUI.aimbot.IgnoreStun.v
    config.settings.visual_drawfov = GUI.visual.DrawFOV.v
    config.settings.visual_espline = GUI.visual.ESPLine.v
    config.settings.visual_espbones = GUI.visual.ESPBones.v
    config.settings.visual_espbox = GUI.visual.ESPBox.v
    config.settings.visual_espinfo = GUI.visual.ESPInfo.v
    config.settings.actor_nostun = GUI.actor.NoStun.v
    config.settings.actor_infiniterun = GUI.actor.InfiniteRun.v
    config.settings.actor_nofall = GUI.actor.NoFall.v
    config.settings.actor_nocamrestore = GUI.actor.NoCamRestore.v
    config.settings.actor_godmode = GUI.actor.GodMode.v
    config.settings.actor_airbreak = GUI.actor.AirBreak.v
    config.settings.vehicle_speedhack = GUI.vehicle.SpeedHack.v
    config.settings.vehicle_speedsmooth = GUI.vehicle.SpeedSmooth.v
    config.settings.vehicle_drive = GUI.vehicle.Drive.v
    config.settings.vehicle_fastexit = GUI.vehicle.FastExit.v
    config.settings.vehicle_jumpbmx = GUI.vehicle.JumpBMX.v
    config.settings.vehicle_bikefall = GUI.vehicle.BikeFall.v
    inicfg.save(config, script.this.filename..'.ini')
end

function reset_ini()
    GUI =
    {
        windowState = imgui.ImBool(true),
        currentButtonID = 1,
        aimbot =
        {
            Smooth = imgui.ImFloat(5.0),
            Radius = imgui.ImFloat(80.0),
            Safe = imgui.ImFloat(1.0),
            SuperSmooth = imgui.ImFloat(1.0),
            Enable = imgui.ImBool(false),
            IsFire = imgui.ImBool(false),
            VisibleCheck = imgui.ImBool(false),
            DynamicSmooth = imgui.ImBool(false),
            CFilter = imgui.ImBool(false),
            IgnoreRange = imgui.ImBool(false),
            IgnoreStun = imgui.ImBool(false)
        },
        visual =
        {
            DrawFOV = imgui.ImBool(false),
            ESPLine = imgui.ImBool(false),
            ESPBones = imgui.ImBool(false),
            ESPBox = imgui.ImBool(false),
            ESPInfo = imgui.ImBool(false)
        },
        actor =
        {
            NoStun = imgui.ImBool(false),
            InfiniteRun = imgui.ImBool(false),
            NoFall = imgui.ImBool(false),
            NoCamRestore = imgui.ImBool(false),
            GodMode = imgui.ImBool(false),
            AirBreak = imgui.ImBool(false)
        },
        vehicle =
        {
            SpeedHack = imgui.ImBool(false),
            SpeedSmooth = imgui.ImFloat(20.0),
            Drive = imgui.ImBool(false),
            FastExit = imgui.ImBool(false),
            JumpBMX = imgui.ImBool(false),
            BikeFall = imgui.ImBool(false)
        }
    }
    save_ini()
end

function main()
    if not initialized then
        if not isSampAvailable() then return false end
        load_ini()
        guiCustomStyle()
        lua_thread.create(Aimbot)
        lua_thread.create(Visual)
        lua_thread.create(Actor)
        lua_thread.create(Vehicle)
        initialized = true
    end
    if wasKeyPressed(VK_INSERT) then
        GUI.windowState.v = not GUI.windowState.v
    end
    imgui.Process = GUI.windowState.v
    return false
end

function imgui.OnDrawFrame()
    if GUI.windowState.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(319, 300), imgui.Cond.FirstUseEver)
        imgui.Begin('HELLFIRE SOFT', nil, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoMove)
        imgui.SetCursorPos(imgui.ImVec2(5, 25))
        if imgui.Button('Smooth', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 1
        end
        imgui.SetCursorPos(imgui.ImVec2(57, 25))
        if imgui.Button('Visual', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 2
        end
        imgui.SetCursorPos(imgui.ImVec2(109, 25))
        if imgui.Button('Actor', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 3
        end
        imgui.SetCursorPos(imgui.ImVec2(161, 25))
        if imgui.Button('Vehicle', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 4
        end
        imgui.SetCursorPos(imgui.ImVec2(213, 25))
        if imgui.Button('Config', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 5
        end
        imgui.SetCursorPos(imgui.ImVec2(265, 25))
        if imgui.Button('Console', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 6
        end
        if GUI.currentButtonID == 1 then
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('Smooth', GUI.aimbot.Smooth, 1.0, 25.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('Radius', GUI.aimbot.Radius, 1.0, 300.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('SafeZone', GUI.aimbot.Safe, 1.0, 300.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('SuperSmooth', GUI.aimbot.SuperSmooth, 1.0, 25.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.Checkbox('Enable', GUI.aimbot.Enable)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('IsFire', GUI.aimbot.IsFire)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('VisibleCheck', GUI.aimbot.VisibleCheck)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('DynamicSmooth', GUI.aimbot.DynamicSmooth)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('CFilter', GUI.aimbot.CFilter)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('IgnoreRange', GUI.aimbot.IgnoreRange)
            imgui.SetCursorPos(imgui.ImVec2(150, 149))
            imgui.Checkbox('IgnoreStun', GUI.aimbot.IgnoreStun)
        end
        if GUI.currentButtonID == 2 then
            imgui.SetCursorPosX(5)
            imgui.Checkbox('ESP Line', GUI.visual.ESPLine)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('ESP Bones', GUI.visual.ESPBones)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('ESP Box', GUI.visual.ESPBox)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('ESP Info', GUI.visual.ESPInfo)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('Draw FOV', GUI.visual.DrawFOV)
        end
        if GUI.currentButtonID == 3 then
            imgui.SetCursorPosX(5)
            imgui.Checkbox('NoStun', GUI.actor.NoStun)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('NoFall', GUI.actor.NoFall)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('NoCamRestore', GUI.actor.NoCamRestore)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('InfiniteRun', GUI.actor.InfiniteRun)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('GodMode', GUI.actor.GodMode)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('AirBreak', GUI.actor.AirBreak)
        end
        if GUI.currentButtonID == 4 then
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('SpeedSmooth', GUI.vehicle.SpeedSmooth, 1.0, 30.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.Checkbox('SpeedHack', GUI.vehicle.SpeedHack)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('DriveInWater', GUI.vehicle.Drive)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('FastExit', GUI.vehicle.FastExit)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('JumpBMX', GUI.vehicle.JumpBMX)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('BikeFall', GUI.vehicle.BikeFall)
        end
        if GUI.currentButtonID == 5 then
            imgui.SetCursorPosX(5)
            if imgui.Button('Load', imgui.ImVec2(310, 25)) then load_ini() end
            imgui.SetCursorPosX(5)
            if imgui.Button('Save', imgui.ImVec2(310, 25)) then save_ini() end
            imgui.SetCursorPosX(5)
            if imgui.Button('Reset', imgui.ImVec2(310, 25)) then reset_ini() end
        end
        if GUI.currentButtonID == 6 then
            imgui.SetCursorPosX(5)
            imgui.InputText('Input', input)
            imgui.SetCursorPosX(5)
            if imgui.Button('Send') then
                if input.v == 'DEATH' or input.v == 'death' then
                    setCharHealth(PLAYER_PED, 0)
                end
                if input.v == 'RECON' or input.v == 'recon' then
                    local ip, port = sampGetCurrentServerAddress()
                    sampDisconnectWithReason(false)
                    sampConnectToServer(ip, port)
                end
                if input.v == 'RELOAD' or input.v == 'reload' then
                    sampToggleCursor(false)
                    showCursor(false)
                    thisScript():reload()
                end
                input.v = ''
            end
            imgui.Text('All commands:\n\nDEATH\nRECON\nRELOAD')
        end
        imgui.End()
    end
end

function Aimbot()
    if GUI.aimbot.Enable.v and isKeyDown(VK_RBUTTON) then
        if not GUI.aimbot.IsFire.v or (GUI.aimbot.IsFire.v and isKeyDown(VK_LBUTTON)) then
            local playerID = GetNearestPed()
            if playerID ~= -1 then
                local pedID = sampGetPlayerIdByCharHandle(PLAYER_PED)
                if (GUI.aimbot.IgnoreStun.v and not CheckStuned()) then return false end
                if (GUI.aimbot.CFilter.v and sampGetPlayerColor(pedID) == sampGetPlayerColor(playerID)) then return false end
                local _, handle = sampGetCharHandleBySampPlayerId(playerID)
                local myPos = {getActiveCameraCoordinates()}
                local enPos = {GetBodyPartCoordinates(GetNearestBone(handle), handle)}
                if not GUI.aimbot.VisibleCheck.v or (GUI.aimbot.VisibleCheck.v and isLineOfSightClear(myPos[1], myPos[2], myPos[3], enPos[1], enPos[2], enPos[3], true, true, false, true, true)) then
                    local pedWeapon = getCurrentCharWeapon(PLAYER_PED)
                    if (pedWeapon >= 22 and pedWeapon <= 29) or pedWeapon == 32 then
                        coefficent = 0.04253
                    elseif pedWeapon == 30 or pedWeapon == 31 then
                        coefficent = 0.028
                    elseif pedWeapon == 33 then
                        сoefficent = 0.01897
                    end
                    local vector = {myPos[1] - enPos[1], myPos[2] - enPos[2]}
                    local angle = math.acos(vector[1] / math.sqrt((math.pow(vector[1], 2) + math.pow(vector[2], 2))))
                    local view = {fix(representIntAsFloat(readMemory(0xB6F258, 4, false))), fix(representIntAsFloat(readMemory(0xB6F248, 4, false)))}
                    if (vector[1] <= 0.0 and vector[2] >= 0.0) or (vector[1] >= 0.0 and vector[2] >= 0.0) then
                        dif = (angle + coefficent) - view[1]
                    end
                    if (vector[1] >= 0.0 and vector[2] <= 0.0) or (vector[1] <= 0.0 and vector[2] <= 0.0) then
                        dif = (-angle + coefficent) - view[1]
                    end
                    if GUI.aimbot.DynamicSmooth.v then multiplier = 5 else multiplier = 1 end
                    local smooth = dif / ((GUI.aimbot.Smooth.v * multiplier) * GUI.aimbot.SuperSmooth.v)
                    if GUI.aimbot.DynamicSmooth.v then
                        if smooth > 0.0 then
                            if smooth < lastsmooth then
                                smooth = smooth * (lastsmooth / smooth)
                            end
                        else
                            if -smooth < -lastsmooth then
                                smooth = smooth * (-lastsmooth / -smooth)
                            end
                        end
                        lastsmooth = smooth
                    end
                    if smooth > -1.0 and smooth < 0.5 and dif > -2.0 and dif < 2.0 then
                        view[1] = view[1] + smooth
                        setCameraPositionUnfixed(view[2], view[1])
                    end
                end
            end
        end
    end
    return false
end

function Visual()
    if GUI.visual.DrawFOV.v then
        local crosshairPos = {convertGameScreenCoordsToWindowScreenCoords(339.1, 179.1)}
        renderFigure2D(crosshairPos[1], crosshairPos[2], GUI.aimbot.Radius.v >= 70 and 144 or 72, (GUI.aimbot.Radius.v - 1.0), 0xFF00FF00)
        renderFigure2D(crosshairPos[1], crosshairPos[2], GUI.aimbot.Safe.v >= 70 and 144 or 72, (GUI.aimbot.Safe.v - 1.0), 0xFFFF0000)
    end
    for i = 0, sampGetMaxPlayerId(true) do
        if sampIsPlayerConnected(i) then
            local find, handle = sampGetCharHandleBySampPlayerId(i)
            if find then
                 if isCharOnScreen(handle) then
                    local myPos = {GetBodyPartCoordinates(3, PLAYER_PED)}
                    local enPos = {GetBodyPartCoordinates(3, handle)}
                    if (isLineOfSightClear(myPos[1], myPos[2], myPos[3], enPos[1], enPos[2], enPos[3], true, true, false, true, true)) then
                        color = 0xFF00FF00
                    else
                        color = 0xFFFF0000
                    end
                    if GUI.visual.ESPLine.v then
                        local myPosScreen = {convert3DCoordsToScreen(GetBodyPartCoordinates(3, PLAYER_PED))}
                        local enPosScreen = {convert3DCoordsToScreen(GetBodyPartCoordinates(3, handle))}
                        renderDrawLine(myPosScreen[1], myPosScreen[2], enPosScreen[1], enPosScreen[2], 1, color)
                    end
                    if GUI.visual.ESPBones.v then
                        local t = {3, 4, 5, 51, 52, 41, 42, 31, 32, 33, 21, 22, 23, 2}
                        for v = 1, #t do
                            pos1 = {GetBodyPartCoordinates(t[v], handle)}
                            pos2 = {GetBodyPartCoordinates(t[v] + 1, handle)}
                            pos1Screen = {convert3DCoordsToScreen(pos1[1], pos1[2], pos1[3])}
                            pos2Screen = {convert3DCoordsToScreen(pos2[1], pos2[2], pos2[3])}
                            renderDrawLine(pos1Screen[1], pos1Screen[2], pos2Screen[1], pos2Screen[2], 1, color)
                        end
                        for v = 4, 5 do
                            pos2 = {GetBodyPartCoordinates(v * 10 + 1, handle)}
                            pos2Screen = {convert3DCoordsToScreen(pos2[1], pos2[2], pos2[3])}
                            renderDrawLine(pos1Screen[1], pos1Screen[2], pos2Screen[1], pos2Screen[2], 1, color)
                        end
                        local t = {53, 43, 24, 34, 6}
                        for v = 1, #t do
                            pos = {GetBodyPartCoordinates(t[v], handle)}
                            pos1Screen = {convert3DCoordsToScreen(pos[1], pos[2], pos[3])}
                        end
                    end
                    if GUI.visual.ESPBox.v then
                        local headPos = {GetBodyPartCoordinates(8, handle)}
                        local footPos = {GetBodyPartCoordinates(44, handle)}
                        local pointOne =
                        {
                            x = headPos[1] - 0.5,
                            y = headPos[2],
                            z = headPos[3] + 0.35
                        }
                        local pointTwo =
                        {
                            x = headPos[1] + 0.5,
                            y = headPos[2],
                            z = headPos[3] - 0.35
                        }
                        local pointThree =
                        {
                            x = footPos[1] + 0.5,
                            y = footPos[2],
                            z = footPos[3] - 0.35
                        }
                        local pointOneScreen = {convert3DCoordsToScreen(pointOne.x, pointOne.y, pointOne.z)}
                        local pointTwoScreen = {convert3DCoordsToScreen(pointTwo.x, pointTwo.y, pointOne.z)}
                        local pointThreeScreen = {convert3DCoordsToScreen(pointOne.x, pointThree.y, pointThree.z)}
                        local pointFourScreen = {convert3DCoordsToScreen(pointTwo.x, pointThree.y, pointThree.z)}
                        renderDrawLine(pointOneScreen[1], pointOneScreen[2], pointTwoScreen[1], pointTwoScreen[2], 1, color)
                        renderDrawLine(pointThreeScreen[1], pointThreeScreen[2], pointFourScreen[1], pointFourScreen[2], 1, color)
                        renderDrawLine(pointOneScreen[1], pointOneScreen[2], pointThreeScreen[1], pointThreeScreen[2], 1, color)
                        renderDrawLine(pointTwoScreen[1], pointTwoScreen[2], pointFourScreen[1], pointFourScreen[2], 1, color)
                    end
                    if GUI.visual.ESPInfo.v then
                        local enPosGame = {GetBodyPartCoordinates(8, handle)}
                        local point =
                        {
                            x = enPosGame[1] - 0.3,
                            y = enPosGame[2],
                            z = enPosGame[3]
                        }
                        local enPosScr = {convert3DCoordsToScreen(point.x, point.y, point.z)}
                        local distance = math.sqrt((math.pow((enPos[1] - myPos[1]), 2) + math.pow((enPos[2] - myPos[2]), 2) + math.pow((enPos[3] - myPos[3]), 2)))
                        renderFontDrawText(font, string.format('Speed: %.1f\nName: %s\nDistance: %.1f\nSkin: %d\nNPC: %s\nAFK: %s', getCharSpeed(handle), sampGetPlayerNickname(i), distance, getCharModel(handle), tostring(sampIsPlayerNpc(i)), tostring(sampIsPlayerPaused(i))), enPosScr[1], enPosScr[2], color)
                    end
                end
            end
        end
    end
    return false
end

function Actor()
    setCharUsesUpperbodyDamageAnimsOnly(PLAYER_PED, GUI.actor.NoStun.v)
    setPlayerNeverGetsTired(PLAYER_PED, not GUI.actor.InfiniteRun.v)
    if GUI.actor.NoFall.v then
        if isCharPlayingAnim(PLAYER_PED, 'KO_SKID_BACK') or isCharPlayingAnim(PLAYER_PED, 'FALL_COLLAPSE') then
            local charPos = {getCharCoordinates(PLAYER_PED)}
            setCharCoordinates(PLAYER_PED, charPos[1], charPos[2], charPos[3] - 1)
        end
    end
    if GUI.actor.NoCamRestore.v then
        if not ncr then
            memory.write(0x5109AC, 235, 1, true)
            memory.write(0x5109C5, 235, 1, true)
            memory.write(0x5231A6, 235, 1, true)
            memory.write(0x52322D, 235, 1, true)
            memory.write(0x5233BA, 235, 1, true)
            ncr = true
        end
    else
        if ncr then
            memory.write(0x5109AC, 122, 1, true)
            memory.write(0x5109C5, 122, 1, true)
            memory.write(0x5231A6, 117, 1, true)
            memory.write(0x52322D, 117, 1, true)
            memory.write(0x5233BA, 117, 1, true)
            ncr = false
        end
    end
    if GUI.actor.GodMode.v then
        setCharProofs(PLAYER_PED, true, true, true, true, true)
    else
        setCharProofs(PLAYER_PED, false, false, false, false, false)
    end
    if GUI.actor.AirBreak.v then
        if wasKeyPressed(VK_RSHIFT) then
            airbreak = not airbreak
        end
        if airbreak then
            local charCoordinates = {getCharCoordinates(PLAYER_PED)}
            local ViewHeading = getCharHeading(PLAYER_PED)
            Coords = {charCoordinates[1], charCoordinates[2], charCoordinates[3], 0.0, 0.0, ViewHeading}
            local MainHeading = getCharHeading(PLAYER_PED)
            local Camera = {getActiveCameraCoordinates()}
            local Target = {getActiveCameraPointAt()}
            local RotateHeading = getHeadingFromVector2d(Target[1] - Camera[1], Target[2] - Camera[2])
            if isKeyDown(VK_W) then
                Coords[1] = Coords[1] + 0.25 * math.sin(-math.rad(RotateHeading))
                Coords[2] = Coords[2] + 0.25 * math.cos(-math.rad(RotateHeading))
                setCharHeading(PLAYER_PED, RotateHeading)
            elseif isKeyDown(VK_S) then
                Coords[1] = Coords[1] - 0.25 * math.sin(-math.rad(MainHeading))
                Coords[2] = Coords[2] - 0.25 * math.cos(-math.rad(MainHeading))
            end
            if isKeyDown(VK_A) then
                Coords[1] = Coords[1] - 0.25 * math.sin(-math.rad(MainHeading - 90))
                Coords[2] = Coords[2] - 0.25 * math.cos(-math.rad(MainHeading - 90))
            elseif isKeyDown(VK_D) then
                Coords[1] = Coords[1] - 0.25 * math.sin(-math.rad(MainHeading + 90))
                Coords[2] = Coords[2] - 0.25 * math.cos(-math.rad(MainHeading + 90))
            end
            if isKeyDown(VK_SPACE) then Coords[3] = Coords[3] + 0.25 / 1.5 end
            if isKeyDown(VK_LSHIFT) and Coords[3] > -95.0 then Coords[3] = Coords[3] - 0.25 / 1.5 end
            setCharCoordinates(PLAYER_PED, Coords[1], Coords[2], Coords[3] - 1)
        end
    end
    return false
end

function Vehicle()
    if GUI.vehicle.SpeedHack.v then
        if isKeyDown(VK_LMENU) then
            if isCharInAnyCar(PLAYER_PED) then
                local car = storeCarCharIsInNoSave(PLAYER_PED)
                local vector = {getCarSpeedVector(car)}
                local heading = getCarHeading(car)
                local turbo = fpsCorrection() / (GUI.vehicle.SpeedSmooth.v * 10)
                local force = {turbo, turbo, turbo}
                local Sin, Cos = math.sin(-math.rad(heading)), math.cos(-math.rad(heading))
                if vector[1] > -0.01 and vector[1] < 0.01 then force[1] = 0.0 end
                if vector[2] > -0.01 and vector[2] < 0.01 then force[2] = 0.0 end
                if vector[3] < 0 then force[3] = -force[3] end
                if vector[3] > -2 and vector[3] < 15 then force[3] = 0.0 end
                if Sin > 0 and vector[1] < 0 then force[1] = -force[1] end
                if Sin < 0 and vector[1] > 0 then force[1] = -force[1] end
                if Cos > 0 and vector[2] < 0 then force[2] = -force[2] end
                if Cos < 0 and vector[2] > 0 then force[2] = -force[2] end
                applyForceToCar(car, force[1] * Sin, force[2] * Cos, force[3] / 2, 0.0, 0.0, 0.0)
            end
        end
    end
    if GUI.vehicle.Drive.v then
        if not dow then
            memory.write(0x6CC303, 0x621F8A, 3, true)
            memory.write(0x6A90C5, 0xEB, 1, true)
            dow = true
        end
    else
        if dow then
            memory.write(0x6CC303, 0xEFE180, 3, true)
            memory.write(0x6A90C5, 0x7A, 1, true)
            dow = false
        end
    end
    if GUI.vehicle.FastExit.v then
        if wasKeyPressed(VK_F) then
            if isCharInAnyCar(PLAYER_PED) then
                local car = storeCarCharIsInNoSave(PLAYER_PED)
                local speed = getCarSpeed(car)
                clearCharTasksImmediately(PLAYER_PED)
                local pos = {getCharCoordinates(PLAYER_PED)}
                setCharCoordinates(PLAYER_PED, pos[1], pos[2], pos[3] + 2)
            end
        end
    end
    if GUI.vehicle.JumpBMX then
        if not jumpbmx then
            memory.setint8(0x969161, 1)
            jumpbmx = true
        end
    else
        if jumpbmx then
            memory.setint8(0x969161, 0)
            jumpbmx = false
        end
    end
    setCharCanBeKnockedOffBike(PLAYER_PED, GUI.vehicle.BikeFall.v)
    return false
end

function sampev.onSendPlayerSync(data)
    if airbreak then
        data.animationId = 1130
        data.moveSpeed = {x = 0.89, y = 0.89, z = -0.89}
    end
end

function sampev.onSetPlayerPos()
    if airbreak then
        return false
    end
end

function sampev.onRequestSpawnResponse() if GUI.actor.GodMode.v then return false end end
function sampev.onRequestClassResponse() if GUI.actor.GodMode.v then return false end end
function sampev.onResetPlayerWeapons() if GUI.actor.GodMode.v then return false end end
function sampev.onSetCameraBehind() if GUI.actor.GodMode.v then return false end end
function sampev.onTogglePlayerControllable() if GUI.actor.GodMode.v then return false end end
function sampev.onSetPlayerSkin() if GUI.actor.GodMode.v then return false end end
function sampev.onSetPlayerHealth() if GUI.actor.GodMode.v then return false end end
function sampev.onBulletSync() if GUI.actor.GodMode.v then return false end end

function renderFigure2D(x, y, points, radius, color)
    local step = math.pi * 2 / points
    local render_start, render_end = {}, {}
    for i = 0, math.pi * 2, step do
        render_start[1] = radius * math.cos(i) + x
        render_start[2] = radius * math.sin(i) + y
        render_end[1] = radius * math.cos(i + step) + x
        render_end[2] = radius * math.sin(i + step) + y
        renderDrawLine(render_start[1], render_start[2], render_end[1], render_end[2], 1, color)
    end
end

function fpsCorrection()
    return representIntAsFloat(readMemory(0xB7CB5C, 4, false))
end

function fix(angle)
    if angle > math.pi then
        angle = angle - (math.pi * 2)
    elseif angle < -math.pi then
        angle = angle + (math.pi * 2)
    end
    return angle
end

function GetNearestPed()
    local maxDistance = nil
    if not GUI.aimbot.IgnoreRange.v then maxDistance = 35 else maxDistance = 20000 end
    local nearestPED = -1
    for i = 0, sampGetMaxPlayerId(true) do
        if sampIsPlayerConnected(i) then
            local find, handle = sampGetCharHandleBySampPlayerId(i)
            if find then
                if isCharOnScreen(handle) then
                    if not isCharDead(handle) then
                        local crosshairPos = {convertGameScreenCoordsToWindowScreenCoords(339.1, 179.1)}
                        local enPos = {GetBodyPartCoordinates(GetNearestBone(handle), handle)}
                        local bonePos = {convert3DCoordsToScreen(enPos[1], enPos[2], enPos[3])}
                        local distance = math.sqrt((math.pow((bonePos[1] - crosshairPos[1]), 2) + math.pow((bonePos[2] - crosshairPos[2]), 2)))
                        if distance < GUI.aimbot.Safe.v or distance > GUI.aimbot.Radius.v then check = true else check = false end
                        if not check then
                            local myPos = {getCharCoordinates(PLAYER_PED)}
                            local enPos = {getCharCoordinates(handle)}
                            local distance = math.sqrt((math.pow((enPos[1] - myPos[1]), 2) + math.pow((enPos[2] - myPos[2]), 2) + math.pow((enPos[3] - myPos[3]), 2)))
                            if (distance < maxDistance) then
                                nearestPED = i
                                maxDistance = distance
                            end
                        end
                    end
                end
            end
        end
    end
    return nearestPED
end

function CheckStuned()
    for k, v in pairs(anims) do
        if isCharPlayingAnim(PLAYER_PED, v) then
            return false
        end
    end
    return true
end

function GetNearestBone(handle)
    local maxDist = 20000
    local nearestBone = -1
    bone = {42, 52, 23, 33, 3, 22, 32, 8}
    for n = 1, 8 do
        local crosshairPos = {convertGameScreenCoordsToWindowScreenCoords(339.1, 179.1)}
        local bonePos = {GetBodyPartCoordinates(bone[n], handle)}
        local enPos = {convert3DCoordsToScreen(bonePos[1], bonePos[2], bonePos[3])}
        local distance = math.sqrt((math.pow((enPos[1] - crosshairPos[1]), 2) + math.pow((enPos[2] - crosshairPos[2]), 2)))
        if (distance < maxDist) then
            nearestBone = bone[n]
            maxDist = distance
        end
    end
    return nearestBone
end

function GetBodyPartCoordinates(id, handle)
    if doesCharExist(handle) then
        local pedptr = getCharPointer(handle)
        local vec = ffi.new("float[3]")
        getbonePosition(ffi.cast("void*", pedptr), vec, id, true)
        return vec[0], vec[1], vec[2]
    end
end
Этот раздел не для этого)
Здесь тебе только могут объяснить, что да к чему, но не как не разжевать и выплюнуть.
 

playez

Новичок
6
1
Помогите пжпжпжп
Пишу скрипт кароче но,почему то он не хочет работать
Lua:
local hook = require 'lib.samp.events'
local encoding = require 'encoding'
local imgui = require 'imgui'
local bNotf, notf = pcall(import, "imgui_notf.lua")
local mem = require 'memory'
local tag = "[AntiLic]: {FFFFFF}"
u8 = encoding.UTF8


function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then
        notf.addNotification('Использование: /antilic', 5, 1)
        notf.addNotification('Самый ужастный код смог загрузится,версия: 1.0', 5, 1)
            end
end

while not isSampAvailable() do wait(2000)
            sampAddChatMessage("{DC143C}[AntiLic] {FFFFE0}Author: {FF0000}Smart", -1)

function hook.onShowDialog(dialogId, dialogStyle, dialogTitle, okButtonText, cancelButtonText, dialogText) end
                if scripton~=nil then scripton()
                sampAddChatMessage("Script was started already! use /scriptoff to disable the script") end
                    lua_thread.create(function()
                        if dialogTitle:find("Лицензии") then
                            sampSendDialogResponse(dialogId, 1, -1, nil)
                                    end
                    end)
            end
end
Логи из консоли:
[ML] (error) antilic.lua: D:\gta cheat ver\moonloader\antilic.lua:29: '<eof>' expected near 'end'
[ML] (error) antilic.lua: Script died due to an error. (08F33264)
(не ругайте за плохой код,только начинаю пытаться писать)
 

darkjer

Активный
134
68
Помогите пжпжпжп
Пишу скрипт кароче но,почему то он не хочет работать
Lua:
local hook = require 'lib.samp.events'
local encoding = require 'encoding'
local imgui = require 'imgui'
local bNotf, notf = pcall(import, "imgui_notf.lua")
local mem = require 'memory'
local tag = "[AntiLic]: {FFFFFF}"
u8 = encoding.UTF8


function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then
        notf.addNotification('Использование: /antilic', 5, 1)
        notf.addNotification('Самый ужастный код смог загрузится,версия: 1.0', 5, 1)
            end
end

while not isSampAvailable() do wait(2000)
            sampAddChatMessage("{DC143C}[AntiLic] {FFFFE0}Author: {FF0000}Smart", -1)

function hook.onShowDialog(dialogId, dialogStyle, dialogTitle, okButtonText, cancelButtonText, dialogText) end
                if scripton~=nil then scripton()
                sampAddChatMessage("Script was started already! use /scriptoff to disable the script") end
                    lua_thread.create(function()
                        if dialogTitle:find("Лицензии") then
                            sampSendDialogResponse(dialogId, 1, -1, nil)
                                    end
                    end)
            end
end
Логи из консоли:
[ML] (error) antilic.lua: D:\gta cheat ver\moonloader\antilic.lua:29: '<eof>' expected near 'end'
[ML] (error) antilic.lua: Script died due to an error. (08F33264)
(не ругайте за плохой код,только начинаю пытаться писать)
while true do
wait(0) — помести в беск цикл
while not isSampAvailable() do wait(2000)
sampAddChatMessage("{DC143C}[AntiLic] {FFFFE0}Author: {FF0000}Smart", -1) - помести тоже в беск цикл, но перед while true do wait (0) и убери там где у тебя написано было перед этим.
Поправь if scripton ~= nil
Дальше вроде все ок, поправь табуляцию ещё, тебе в будущем пригодится. Пиши если не работает, у меня нет возможности чекнуть, ибо с телефа пишу
upd: и убери второй от конца end в хуке
 
Последнее редактирование:

7jizzle

Участник
238
14

Этот раздел не для этого)
Здесь тебе только могут объяснить, что да к чему, но не как не разжевать и выплюнуть.

taskplayanim проигрывает анимку, а мне нужно чтобы скорость анимки приседания на велик изменить
 

solomonioZ

Участник
23
3

Этот раздел не для этого)
Здесь тебе только могут объяснить, что да к чему, но не как не разжевать и выплюнуть.
Объясните и с примером пожалуйста
 

Мира

Участник
455
9
Что здесь не так?
Нужно, чтобы кто находился около меня получал 4 ранг.


Lua:
require "lib.moonloader"

local act = false

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampAddChatMessage("DH", -1)
    sampRegisterChatCommand("cmd", cmd)
    wait(-1)
end

function getClosestPlayerId()
    local mydist = cfg.settings.range
    local closestId = -1
    local x, y, z = getCharCoordinates(PLAYER_PED)
    for i = 0, 999 do
        local streamed, pedID = sampGetCharHandleBySampPlayerId(i)
        if streamed and getCharHealth(pedID) > 0 and not sampIsPlayerPaused(pedID) then
            local xi, yi, zi = getCharCoordinates(pedID)
            local dist = getDistanceBetweenCoords3d(x, y, z, xi, yi, zi)
            if dist <= mydist then
                mydist = dist
                closestId = i
            end
        end
    end
    return closestId
end

function cmd()
    act = not act
    lua_thread.create(cmd_looped)
end

function cmd_looped()
while act do
    wait(0)
    sampAddChatMessage("DH++", -1)
    wait(1000)
    sampSendChat("/giverank "..getClosestPlayerId().." 4")
    end
end
 

Fott

Простреленный
3,461
2,374
Что здесь не так?
Нужно, чтобы кто находился около меня получал 4 ранг.


Lua:
require "lib.moonloader"

local act = false

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampAddChatMessage("DH", -1)
    sampRegisterChatCommand("cmd", cmd)
    wait(-1)
end

function getClosestPlayerId()
    local mydist = cfg.settings.range
    local closestId = -1
    local x, y, z = getCharCoordinates(PLAYER_PED)
    for i = 0, 999 do
        local streamed, pedID = sampGetCharHandleBySampPlayerId(i)
        if streamed and getCharHealth(pedID) > 0 and not sampIsPlayerPaused(pedID) then
            local xi, yi, zi = getCharCoordinates(pedID)
            local dist = getDistanceBetweenCoords3d(x, y, z, xi, yi, zi)
            if dist <= mydist then
                mydist = dist
                closestId = i
            end
        end
    end
    return closestId
end

function cmd()
    act = not act
    lua_thread.create(cmd_looped)
end

function cmd_looped()
while act do
    wait(0)
    sampAddChatMessage("DH++", -1)
    wait(1000)
    sampSendChat("/giverank "..getClosestPlayerId().." 4")
    end
end
Ты хочешь получить mydist из конфига, но конфига у тебя нет