0% found this document useful (0 votes)
108 views5 pages

Emberlash Lua: MoreSettings Script

The document describes a script named 'MoreSettings' for modifying game settings, including sensitivity, aspect ratio, and external aim. It includes functions for loading and saving configurations in JSON format, as well as a graphical user interface for adjusting these settings. The script is designed to work with the MONET framework and integrates with the game's memory to apply changes in real-time.

Uploaded by

vnpecinha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
108 views5 pages

Emberlash Lua: MoreSettings Script

The document describes a script named 'MoreSettings' for modifying game settings, including sensitivity, aspect ratio, and external aim. It includes functions for loading and saving configurations in JSON format, as well as a graphical user interface for adjusting these settings. The script is designed to work with the MONET framework and integrates with the game's memory to apply changes in real-time.

Uploaded by

vnpecinha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

script_author("OSPx")

script_name("MoreSettings")
script_description("An additional settings menu. Currently sensitivity, aspect
ratio, and external aim.")
script_version("1.1")

local memory = require 'memory'


local encoding = require 'encoding'
[Link] = 'CP1251'
local u8 = encoding.UTF8

local ffi = require 'ffi'


local hook = require('monethook')
local imgui = require 'mimgui'

local cf = (function()
local a = '/'
if MONET_VERSION == nil then a = '\\' end
local function b(c, d)
d = d or {}
if c == nil then return nil end
if d[c] then return d[c] end
local e
if type(c) == 'table' then
e = {}
d[c] = e
for f, g in next, c, nil do e[b(f, d)] = b(g, d) end
setmetatable(e, b(getmetatable(c), d))
else
e = c
end
return e
end

local function h(i, j)


for f, g in next, j, nil do
if i[f] == nil then
i[b(f)] = b(g)
else
if type(g) == 'table' and type(i[f]) == 'table' then
h(i[f], g)
end
end
end
end

local function k(l, m, n)


local l = l or {}
local n = n or '.json'
local m = m or [Link] .. n
m:gsub('\\', a)
if MONET_VERSION ~= nil then
m:gsub('moonloader/', 'monetloader/')
end
local o = getWorkingDirectory() .. a .. 'config' .. a .. m .. n
local p = getWorkingDirectory() .. a .. 'config' .. a .. m
local q = m
local r = [Link](o, 'r')
if not r then r = [Link](p, 'r') end
if not r then r = [Link](q, 'r') end
if r then
local s = r:read('*a')
if #s == 0 then r:close() return b(l) end
local t, u = pcall(decodeJson, s)
r:close()
if not t or not u then
if not t then print('jsoncfg: failed to decode json, error:', u)
end
return b(l)
end
h(u, l)
return u
else
return b(l)
end
end

local function v(w, m, n)


local n = n or '.json'
local m = m or [Link] .. n
m:gsub('\\', a)
if MONET_VERSION ~= nil then
m:gsub('moonloader/', 'monetloader/')
end
local x = getWorkingDirectory() .. a .. 'config' .. a
if m:find(a, 1, true) ~= nil then
local y = m:match('.*' .. a)
createDirectory(y)
x = m
elseif m:match('%' .. n .. '$') ~= nil then
createDirectory(x)
x = x .. m
else
createDirectory(x)
x = x .. m .. n
end
local r, z = [Link](x, 'w')
if r then
local t, A = pcall(encodeJson, w)
if t then
r:write(A)
else
print('jsoncfg: failed to encode json, error:', A)
end
r:close()
return t
else
print('jsoncfg: failed to open file, error:', z)
return false
end
end

return { load = k, save = v }


end)()

local sens_addr = MONET_GTASA_BASE + 0x6A9F30


local function getSensitivity()
return [Link](sens_addr)
end

---@type table
local cfg = [Link]({
locale = getWorkingDirectory():find("[Link]") and "ru" or "en",
sensitivity = getSensitivity(),
aspectratio = 0,
external_aim = false
}, "MoreSettings")
[Link] = [Link] / 1000000

local function save()


[Link] = [Link] * 1000000
[Link](cfg, "MoreSettings")
[Link] = [Link] / 1000000
end

local locales = {
en = {
language_switch = "Language switch (en)",
save_settings = "Save settings",
auto = "Off",
sensitivity = "Sensitivity",
aspectratio = "Aspect Ratio",
external_aim = "External Aim",
},
ru = {
language_switch = "Trocar Idioma (PT)",
save_settings = "Salvar Configuracoes",
auto = "Off",
sensitivity = "Sensibilidade",
aspectratio = "Resolucao",
external_aim = "Mira Externa",
},
}

local shared = require '[Link]'


[Link] 'RenderWare'
[Link][[
typedef struct RwRect RwRect;
typedef struct RwCamera RwCamera;

void _Z10CameraSizeP8RwCameraP6RwRectff(RwCamera *camera, RwRect *rect, float


unk, float aspect);
]]
local gta = [Link]('GTASA')

local function setSensitivity(value)


[Link](sens_addr, 0.001 + value / 3000.0)
end

local MDS = MONET_DPI_SCALE


local window = [Link](false)
local m_sens = [Link]([Link])

local m_aspectratio = [Link]([Link])


local aspectratio_list = {
u8(locales[[Link]].auto),
"3:2",
"4:3",
"5:4",
"6:4",
"7:5",
"8:3",
"16:9",
"16:10",
"21:9",
"32:9",
}
local aspectratio_nums = {
0.0,
3.0 / 2.0,
4.0 / 3.0,
5.0 / 4.0,
6.0 / 4.0,
7.0 / 5.0,
8.0 / 3.0,
16.0 / 9.0,
16.0 / 10.0,
21.0 / 9.0,
32.0 / 9.0,
}
local m_aspectratio_list = [Link]['const char*'][#aspectratio_list]
(aspectratio_list)

function aspectHook(camera, rect, unk, aspect)


if [Link] == nil or [Link] == 0 then
return aspectHook(camera, rect, unk, aspect)
end

return aspectHook(camera, rect, unk, aspectratio_nums[[Link]+1])


end

aspectHook = [Link]('void(*)(RwCamera *camera, RwRect *rect, float unk, float


aspect)', aspectHook, [Link]('uintptr_t', [Link]('void*',
gta._Z10CameraSizeP8RwCameraP6RwRectff)))

[Link](function()
[Link]().IniFilename = nil
[Link]():ScaleAllSizes(MDS)
end)

[Link](function ()
return window[0]
end, function()
local resX, resY = getScreenResolution()

[Link](imgui.ImVec2(resX / 2, resY / 2),


[Link], imgui.ImVec2(0.5, 0.5))
[Link](imgui.ImVec2(250 * MDS, 150 * MDS),
[Link])
[Link]("More Settings by OSPx", window)

[Link](u8(locales[[Link]].sensitivity))
[Link]()
[Link]([Link]() - [Link]() -
[Link]().FramePadding.x * 2)
[Link]("##sens", m_sens, 0.0, 150.0)
[Link](u8(locales[[Link]].aspectratio))
[Link]()
[Link]([Link]() - [Link]() -
[Link]().FramePadding.x * 2)
[Link]("##aspect", m_aspectratio, m_aspectratio_list, #aspectratio_list)

[Link](u8(locales[[Link]].external_aim))
[Link]()
[Link]([Link]() - [Link]() -
[Link]().FramePadding.x * 2)
[Link]("##external_aim", [Link](cfg.external_aim))

if [Link](u8(locales[[Link]].language_switch),
imgui.ImVec2(GetMiddleButtonX(2), 23 * MDS)) then
if [Link] == "en" then
[Link] = "ru"
else
[Link] = "en"
end
end
[Link]()
if [Link](u8(locales[[Link]].save_settings),
imgui.ImVec2(GetMiddleButtonX(2), 23 * MDS)) then
save()
end

if m_sens[0] ~= [Link] then


[Link] = m_sens[0]
setSensitivity([Link])
end

if m_aspectratio[0] ~= [Link] then


[Link] = m_aspectratio[0]
end

if [Link]().MouseDown[0] then
if cfg.external_aim then
else
end
end

[Link]()

end)

sampRegisterChatCommand("sensi", function()
window[0] = not window[0]
end)

function GetMiddleButtonX(width)
local resX, _ = getScreenResolution()
return (resX / 2) - (width * 125 * MDS)
end

end

You might also like