Загрузка данных
script_name('FOV Changer')
script_author('Claude')
script_version('2.0')
require 'lib.moonloader'
local inicfg = require 'inicfg'
local encoding = require 'encoding'
-- Файл должен быть сохранён в UTF-8
encoding.default = 'CP1251'
local u8 = encoding.UTF8
local function t(s) return u8:decode(s) end
local MIN_FOV, MAX_FOV, DEFAULT_FOV = 30, 120, 70
local CFG_NAME = 'fov_changer.ini'
local cfg = inicfg.load({
main = { fov = DEFAULT_FOV, enabled = true }
}, CFG_NAME)
local DLG_MENU, DLG_INPUT, DLG_PRESET = 7100, 7101, 7102
local presets = { 60, 70, 80, 90, 100, 110 }
local function save() inicfg.save(cfg, CFG_NAME) end
local function msg(text)
sampAddChatMessage(t('{00BFFF}[FOV]{FFFFFF} ' .. text), -1)
end
local function applyFov()
if cfg.main.enabled then
cameraSetLerpFov(cfg.main.fov, cfg.main.fov, 1000, true)
else
cameraSetLerpFov(70.0, 70.0, 1000, true)
end
end
local function setFov(value)
value = tonumber(value)
if not value then
msg('Введите число, например: /fov 90')
return false
end
if value < MIN_FOV or value > MAX_FOV then
msg(('Допустимый диапазон: %d-%d'):format(MIN_FOV, MAX_FOV))
return false
end
cfg.main.fov = value
cfg.main.enabled = true
save()
msg('FOV установлен: {FFD700}' .. value)
return true
end
local function openMenu()
local status = cfg.main.enabled and '{00FF00}включён' or '{FF4444}выключен'
local text = table.concat({
'Скрипт: ' .. status,
'Задать значение FOV (сейчас: {FFD700}' .. cfg.main.fov .. '{FFFFFF})',
'Выбрать готовый пресет',
'Сбросить на стандартный (' .. DEFAULT_FOV .. ')',
}, '\n')
sampShowDialog(DLG_MENU, t('{00BFFF}Настройки FOV'), t(text),
t('Выбрать'), t('Закрыть'), 2)
end
local function openInput()
local text = ('Введите значение от %d до %d:'):format(MIN_FOV, MAX_FOV)
sampShowDialog(DLG_INPUT, t('{00BFFF}Значение FOV'), t(text),
t('Применить'), t('Назад'), 1)
end
local function openPresets()
local lines = {}
for _, p in ipairs(presets) do
local mark = (p == cfg.main.fov) and ' {00FF00}(текущий)' or ''
lines[#lines + 1] = 'FOV ' .. p .. mark
end
sampShowDialog(DLG_PRESET, t('{00BFFF}Пресеты FOV'), t(table.concat(lines, '\n')),
t('Применить'), t('Назад'), 2)
end
local function handleDialogs()
-- Главное меню
local ok, button, list = sampHasDialogRespond(DLG_MENU)
if ok then
if button == 1 then
if list == 0 then
cfg.main.enabled = not cfg.main.enabled
save()
msg(cfg.main.enabled and 'Скрипт включён.' or 'Скрипт выключен.')
openMenu()
elseif list == 1 then
openInput()
elseif list == 2 then
openPresets()
elseif list == 3 then
cfg.main.fov, cfg.main.enabled = DEFAULT_FOV, true
save()
msg('FOV сброшен: {FFD700}' .. DEFAULT_FOV)
openMenu()
end
end
return
end
-- Ввод значения
local ok2, button2, _, input = sampHasDialogRespond(DLG_INPUT)
if ok2 then
if button2 == 1 then setFov(input) end
openMenu()
return
end
-- Пресеты
local ok3, button3, list3 = sampHasDialogRespond(DLG_PRESET)
if ok3 then
if button3 == 1 and presets[list3 + 1] then
setFov(presets[list3 + 1])
end
openMenu()
end
end
function main()
while not isSampAvailable() do wait(100) end
sampRegisterChatCommand('fov', function(arg)
arg = (arg or ''):match('^%s*(.-)%s*$')
if arg == '' then
openMenu()
elseif arg == 'reset' then
cfg.main.fov, cfg.main.enabled = DEFAULT_FOV, true
save()
msg('FOV сброшен: {FFD700}' .. DEFAULT_FOV)
elseif arg == 'off' then
cfg.main.enabled = false
save()
msg('Скрипт выключен, FOV возвращён к стандартному.')
elseif arg == 'on' then
cfg.main.enabled = true
save()
msg('Скрипт включён.')
else
setFov(arg)
end
end)
msg('Загружен. Меню настроек: {FFD700}/fov{FFFFFF}, быстрая смена: {FFD700}/fov [число]')
while true do
wait(0)
applyFov()
handleDialogs()
end
end