- Версия MoonLoader
- Другое
Почему крашит игру?
Lua:
local ffi = require('ffi');
local imgui = require('mimgui');
local encoding = require('encoding');
encoding.default = 'CP1251';
local u8 = encoding.UTF8;
local sliders = {}
local checkboxes = {}
local window = imgui.new.bool(false);
local inicfg = require("inicfg")
local directIni = "Aspect Ration.ini"
local ini = inicfg.load({
settings = {
aspectratio = 1.33,
CustomFov = false,
fov = 70.0,
}}, directIni)
inicfg.save(ini, directIni)
function save()
inicfg.save(ini, directIni)
end
local new = imgui.new
sliders.aspectratio = new.float(tonumber(ini.settings.aspectratio))
imgui.OnInitialize(function()
imgui.GetIO().IniFilename = nil;
end)
imgui.OnFrame(
function() return window[0] end,
function(this)
local size, res = imgui.ImVec2(450, 250), imgui.ImVec2(getScreenResolution());
imgui.SetNextWindowPos(imgui.ImVec2(res.x / 2, res.y / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5));
imgui.SetNextWindowSize(size, imgui.Cond.FirstUseEver);
if imgui.Begin('', window, imgui.WindowFlags.NoCollapse) then
if imgui.SliderFloat(u8'##Соотношение сторон', sliders.aspectratio, 0.5, 3.0, u8"Соотношение сторон: %.2f") then
ini.settings.aspectratio = ("%.2f"):format(sliders.aspectratio[0])
save()
gotofunc("ScreenOptions")
end
imgui.PopItemWidth()
imgui.SameLine()
if imgui.Button(u8'Сбросить', imgui.ImVec2(70, 25)) then
ini.settings.aspectratio = 1.33
save()
sliders.aspectratio[0] = ini.settings.aspectratio
gotofunc("ScreenOptions")
end
if imgui.Checkbox(u8"Свой угол обзора", checkboxes.CustomFov) then
ini.settings.CustomFov = checkboxes.CustomFov[0]
save()
end
if ini.settings.CustomFov then
if imgui.SliderFloat(u8'##угол обзора', sliders.fov, 70.0, 100.0, u8"Угол обзора: %.2f") then
ini.settings.fov = ("%.2f"):format(sliders.fov[0])
save()
gotofunc("ScreenOptions")
end
end
end
imgui.End()
end
)
function main()
while not isSampAvailable() do wait(0) end
sampRegisterChatCommand('mimgui', function()
window[0] = not window[0];
end)
end
function gotofunc(fnc)
if fnc == "ScreenOptions" or fnc == "all" then
writeMemory(0xFCFAED, 4, representFloatAsInt(ini.settings.aspectratio, false))
writeMemory(0x6FF43F+2, 4, 0xFCFAED, false)
writeMemory(0x6FF43D, 2, 0x9090, false)
end
end