не запускается скрипт

Zеro

Известный
Автор темы
93
28
Версия SA-MP
  1. 0.3.7 (R1)
все должно работать, но на 210 строке не могу понять что там не так, help
[15:48:54.818401] (error) test.lua: build\moonloader\test.lua:210: 'end' expected near '<eof>'
[15:48:54.818401] (error) test.lua: Script died due to an error. (018BA124)

код
Lua:
require 'lib.moonloader'

local sampev = require 'lib.samp.events'
local inicfg = require 'inicfg'
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local direct = 'moonloader\\config\\airbrake.ini'

local cfg = inicfg.load({
    config =
    {
            speed_player = 0.76,
            speed_vehicle = 1.5,
            speed_passenger = 0.2,
            speed_player_sync = 1.8,
            speed_vehicle_sync = 1.2,
            speed_passenger_sync = 0.5
    }
},"airbrake")

local sw,sh = getScreenResolution()
local main_windows_state = imgui.ImBool(false)
local speed_player = imgui.ImFloat(cfg.config.speed_player)
local speed_vehicle = imgui.ImFloat(cfg.config.speed_vehicle)
local speed_passenger = imgui.ImFloat(cfg.config.speed_passenger)
local speed_player_sync = imgui.ImFloat(cfg.config.speed_player_sync)
local speed_vehicle_sync = imgui.ImFloat(cfg.config.speed_vehicle_sync)
local speed_passenger_sync = imgui.ImFloat(cfg.config.speed_passenger_sync)

local status = inicfg.load(cfg, 'airbrake.ini')
if not doesFileExist('moonloader/config/airbrake.ini') then inicfg.save(cfg, 'airbrake.ini') end

function main()
    while not isSampAvailable() do wait(0) end
    wait(1000)
    sampAddChatMessage('Загружен.', -1)

    sampRegisterChatCommand('airbra', function()
        main_windows_state.v = not main_windows_state.v
        imgui.Process = main_windows_state.v
    end)
   
    while true do wait(0)
    active = not active
    printStringNow(active and '~S~AirBrake ~B~Activated~N~' or '~S~AirBrake ~B~De-Activated~N~', 5000)
    if not active then return end
    while active do wait(0)

        if isCharInAnyCar(PLAYER_PED) then setCarHeading(getCarCharIsUsing(PLAYER_PED), getHeadingFromVector2d(select(1, getActiveCameraPointAt()) - select(1, getActiveCameraCoordinates()), select(2, getActiveCameraPointAt()) - select(2, getActiveCameraCoordinates()))) if getDriverOfCar(getCarCharIsUsing(PLAYER_PED)) == -1 then speed = getFullSpeed(speed_passenger, 0, 0) else speed = getFullSpeed(speed_vehicle, 0, 0) end else speed = getFullSpeed(speed_player, 0, 0) setCharHeading(PLAYER_PED, getHeadingFromVector2d(select(1, getActiveCameraPointAt()) - select(1, getActiveCameraCoordinates()), select(2, getActiveCameraPointAt()) - select(2, getActiveCameraCoordinates()))) end

        if sampIsCursorActive() then goto mark end

        if isKeyDown(VK_SPACE) then airBrkCoords[3] = airBrkCoords[3] + speed / 2 elseif isKeyDown(VK_LSHIFT) and airBrkCoords[3] > -95.0 then airBrkCoords[3] = airBrkCoords[3] - speed / 2 end

        if isKeyDown(VK_W) then airBrkCoords[1] = airBrkCoords[1] + speed * math.sin(-math.rad(getCharHeading(PLAYER_PED))) airBrkCoords[2] = airBrkCoords[2] + speed * math.cos(-math.rad(getCharHeading(PLAYER_PED))) elseif isKeyDown(VK_S) then airBrkCoords[1] = airBrkCoords[1] - speed * math.sin(-math.rad(getCharHeading(PLAYER_PED))) airBrkCoords[2] = airBrkCoords[2] - speed * math.cos(-math.rad(getCharHeading(PLAYER_PED))) end
        if isKeyDown(VK_A) then airBrkCoords[1] = airBrkCoords[1] - speed * math.sin(-math.rad(getCharHeading(PLAYER_PED) - 90)) airBrkCoords[2] = airBrkCoords[2] - speed * math.cos(-math.rad(getCharHeading(PLAYER_PED) - 90)) elseif isKeyDown(VK_D) then airBrkCoords[1] = airBrkCoords[1] + speed * math.sin(-math.rad(getCharHeading(PLAYER_PED) - 90)) airBrkCoords[2] = airBrkCoords[2] + speed * math.cos(-math.rad(getCharHeading(PLAYER_PED) - 90)) end

        ::mark::
        setCharCoordinates(PLAYER_PED, airBrkCoords[1], airBrkCoords[2], airBrkCoords[3])

        end
        if main_windows_state.v == false then imgui.Process = false end
     end
end    

function sampev.onSendPlayerSync(data)
    if not active then return end

    local fuck = getMoveSpeed(getCharHeading(PLAYER_PED), speed_player_sync)
    data.moveSpeed = {fuck.x, fuck.y, data.moveSpeed.z}
    return data
end

function sampev.onSendVehicleSync(data)
    if not active then return end

    local fuck = getMoveSpeed(getCharHeading(PLAYER_PED), speed_vehicle_sync)
    data.moveSpeed = {fuck.x, fuck.y, data.moveSpeed.z}
    return data
end

function sampev.onSendUnoccupiedSync(data)
    if not active then return end

    local fuck = getMoveSpeed(getCharHeading(PLAYER_PED), speed_passenger_sync)
    data.moveSpeed = {fuck.x, fuck.y, data.moveSpeed.z}
    return data
end

function sampev.onSendPassengerSync(data)
    if not active then return end

    pcall(onSendUnoccupiedSync, data.vehicleId, data.seatId)
    data.position = {getCharCoordinates(PLAYER_PED)}
    return data
end

function getMoveSpeed(heading, speed)
    moveSpeed = {x = math.sin(-math.rad(heading)) * (speed), y = math.cos(-math.rad(heading)) * (speed), z = 0}
    return moveSpeed
end  
   
function imgui.OnDrawFrame()
    imgui.SetNextWindowSize(imgui.ImVec2(350, 200), imgui.Cond.FirstUseEver)
    imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    imgui.Begin('AirBrake',main_windows_state,imgui.WindowFlags.NoResize)
    imgui.BeginChild('', imgui.ImVec2(300, 130), true)
    imgui.PushItemWidth(90)
    imgui.InputInt(u8'Скорость персонажа', speed_player)
    imgui.PushItemWidth(65)
    imgui.InputFloat(u8'Скорость машины',speed_vehicle)
    imgui.PushItemWidth(65)
    imgui.InputFloat(u8'Скорость пассажира',speed_passenger)
    imgui.PushItemWidth(65)
    imgui.InputFloat(u8'Скорость синхр. персонажа',speed_player_sync)
    imgui.PushItemWidth(65)
    imgui.InputFloat(u8'Скорость синхр. машины',speed_vehicle_sync)
    imgui.PushItemWidth(65)
    imgui.InputFloat(u8'Скорость синхр. пассажира',speed_passenger_sync)
    imgui.EndChild()
    if imgui.Button(u8'Сохранить настройки', imgui.ImVec2(300, 30)) then
        saveSettings()
        sampAddChatMessage('{696969}[AirBrake]: {ffffff}Настройки сохранены.', -1)
    end
    imgui.End()
end

function saveSettings()
    cfg.config.speed_player = speed_player.v
    cfg.config.speed_vehicle = speed_vehicle.v
    cfg.config.speed_passenger = speed_passenger.v
    cfg.config.speed_player_sync = speed_player_sync.v
    cfg.config.speed_vehicle_sync = speed_vehicle_sync.v
    cfg.config.speed_passenger_sync = speed_passenger_sync.v
    inicfg.save(cfg, 'airbrake.ini')
end

function darkgreentheme()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
    local ImVec2 = imgui.ImVec2
 
    style.WindowPadding = ImVec2(6, 4)
    style.WindowRounding = 5.0
    style.ChildWindowRounding = 5.0
    style.FramePadding = ImVec2(5, 2)
    style.FrameRounding = 5.0
    style.ItemSpacing = ImVec2(7, 5)
    style.ItemInnerSpacing = ImVec2(1, 1)
    style.TouchExtraPadding = ImVec2(0, 0)
    style.IndentSpacing = 6.0
    style.ScrollbarSize = 12.0
    style.ScrollbarRounding = 5.0
    style.GrabMinSize = 20.0
    style.GrabRounding = 2.0
    style.WindowTitleAlign = ImVec2(0.5, 0.5)

    colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.TextDisabled]           = ImVec4(0.28, 0.30, 0.35, 1.00)
    colors[clr.WindowBg]               = ImVec4(0.16, 0.18, 0.22, 1.00)
    colors[clr.ChildWindowBg]          = ImVec4(0.19, 0.22, 0.26, 1)
    colors[clr.PopupBg]                = ImVec4(0.05, 0.05, 0.10, 0.90)
    colors[clr.Border]                 = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.FrameBg]                = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.FrameBgHovered]         = ImVec4(0.22, 0.25, 0.30, 1.00)
    colors[clr.FrameBgActive]          = ImVec4(0.22, 0.25, 0.29, 1.00)
    colors[clr.TitleBg]                = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.19, 0.22, 0.26, 0.59)
    colors[clr.MenuBarBg]              = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.ScrollbarBg]            = ImVec4(0.20, 0.25, 0.30, 0.60)
    colors[clr.ScrollbarGrab]          = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.49, 0.63, 0.86, 1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.49, 0.63, 0.86, 1.00)
    colors[clr.ComboBg]                = ImVec4(0.20, 0.20, 0.20, 0.99)
    colors[clr.CheckMark]              = ImVec4(0.90, 0.90, 0.90, 0.50)
    colors[clr.SliderGrab]             = ImVec4(1.00, 1.00, 1.00, 0.30)
    colors[clr.SliderGrabActive]       = ImVec4(0.80, 0.50, 0.50, 1.00)
    colors[clr.Button]                 = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.ButtonHovered]          = ImVec4(0.49, 0.62, 0.85, 1.00)
    colors[clr.ButtonActive]           = ImVec4(0.49, 0.62, 0.85, 1.00)
    colors[clr.Header]                 = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.HeaderHovered]          = ImVec4(0.22, 0.24, 0.28, 1.00)
    colors[clr.HeaderActive]           = ImVec4(0.22, 0.24, 0.28, 1.00)
    colors[clr.Separator]              = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.SeparatorHovered]       = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.SeparatorActive]        = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.ResizeGrip]             = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.ResizeGripHovered]      = ImVec4(0.49, 0.61, 0.83, 1.00)
    colors[clr.ResizeGripActive]       = ImVec4(0.49, 0.62, 0.83, 1.00)
    colors[clr.CloseButton]            = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.CloseButtonHovered]     = ImVec4(0.50, 0.63, 0.84, 1.00)
    colors[clr.CloseButtonActive]      = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.PlotLines]              = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.PlotLinesHovered]       = ImVec4(0.90, 0.70, 0.00, 1.00)
    colors[clr.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
    colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00)
    colors[clr.TextSelectedBg]         = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.16, 0.18, 0.22, 0.76)
end
darkgreentheme()

function getFullSpeed(speed, ping, min_ping) local fps = require('memory').getfloat(0xB7CB50, true) local result = (speed / (fps / 60)) if ping == 1 then local ping = sampGetPlayerPing(select(2, sampGetPlayerIdByCharHandle(PLAYER_PED))) if min_ping < ping then result = (result / (min_ping / ping)) end end return result end function onWindowMessage(msg, wparam, lparam) if(msg == 0x100 or msg == 0x101) then if lparam == 3538945 and not sampIsChatInputActive() and not sampIsDialogActive() and not sampIsCursorActive() then airBrkCoords = {getCharCoordinates(PLAYER_PED)} if not isCharInAnyCar(PLAYER_PED) then airBrkCoords[3] = airBrkCoords[3] - 1 end end end
 
Последнее редактирование:
  • Ха-ха
Реакции: ................

Sidney31

Известный
1,132
385
Lua:
function getFullSpeed(speed, ping, min_ping)
    local fps = require('memory').getfloat(0xB7CB50, true)
    local result = (speed / (fps / 60))
    if ping == 1 then
        local ping = sampGetPlayerPing(select(2, sampGetPlayerIdByCharHandle(PLAYER_PED)))
        if min_ping < ping then
            result = (result / (min_ping / ping))
        end
    end
    return result
end
function onWindowMessage(msg, wparam, lparam)
    if(msg == 0x100 or msg == 0x101) then
        if lparam == 3538945 and not sampIsChatInputActive() and not sampIsDialogActive() and not sampIsCursorActive() then
            airBrkCoords = {getCharCoordinates(PLAYER_PED)}
            if not isCharInAnyCar(PLAYER_PED) then
                airBrkCoords[3] = airBrkCoords[3] - 1
            end
        end
    end
end
ласт строку на это замени
 

Zеro

Известный
Автор темы
93
28
Lua:
function getFullSpeed(speed, ping, min_ping)
    local fps = require('memory').getfloat(0xB7CB50, true)
    local result = (speed / (fps / 60))
    if ping == 1 then
        local ping = sampGetPlayerPing(select(2, sampGetPlayerIdByCharHandle(PLAYER_PED)))
        if min_ping < ping then
            result = (result / (min_ping / ping))
        end
    end
    return result
end
function onWindowMessage(msg, wparam, lparam)
    if(msg == 0x100 or msg == 0x101) then
        if lparam == 3538945 and not sampIsChatInputActive() and not sampIsDialogActive() and not sampIsCursorActive() then
            airBrkCoords = {getCharCoordinates(PLAYER_PED)}
            if not isCharInAnyCar(PLAYER_PED) then
                airBrkCoords[3] = airBrkCoords[3] - 1
            end
        end
    end
end
ласт строку на это замени
теперь это пишет
(error) test.lua: build\moonloader\test.lua:212: attempt to perform arithmetic on local 'speed' (a userdata value)
stack traceback:
build\moonloader\test.lua: in function 'getFullSpeed'
build\moonloader\test.lua:52: in function <build\moonloader\test.lua:36>