- 44
- 13
Нужно сохранять все чекбоксы, слайдер и комбо в конфиг так, что бы после перезапуска игры все значения оставались как и перед выходом, перепробовал способы от разных людей, ни один не работает. Объясните пожалуйста на примере моего кода( для удобства выделил линии с одним из чекбоксов).
Lua:
script_name('CreamTools')
script_author('Shvchuk')
script_description('CreamTools 3.2')
require("lib.moonloader")
local memory = require 'memory'
local q = require 'samp.events'
local imgui = require("imgui")
local encoding = require("encoding")
encoding.default = "CP1251"
u8 = encoding.UTF8
local selecselect_imgui_window = 1
local tag = '[Cream Tools]: '
local label = 0
local main_color = 0xFDF4E3
local main_color_text = '{FDF4E3}'
local white_color = '{FFFFFF}'
local arr_str = {}
local mem = require "memory"
local sw, sh = getScreenResolution()
local exit_data ="\x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0D\x49\x48\x44\x52\x00\x00\x01\x1B\x00\x00\x00\x61\x08\x06\x00\x00\x00\xE6\xE3\x05\x32\x00\x00\x01\x96\x49\x44\x41\x54\x78\xDA\xED\xDC\x3D\x6E\xC2\x30\x18\x06\x60\x53\x75\xE8\x3D\x7A\xB7\x70\x83\x0E\x5D\x90\x90\xBA\x77\x2D\x67\xE2\x0A\x9C\xA3\x23\x5D\x98\x00\x41\x63\xC8\xE7\xBF\xE7\x91\x3C\xF1\x13\xEC\x84\x97\xCF\x89\x49\x4A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xF4\xE4\x38\xA3\x4D\xAD\x75\xEE\xC5\xFE\x05\x84\x0D\x20\x6C\x00\x84\x0D\x20\x6C\x00\x61\x03\x20\x6C\x00\x61\x03\xF0\xF4\xB0\x39\x2E\xDC\x26\xBB\xA4\x0B\x4B\x1C\x1B\xA8\x6C\x00\x84\x0D\x20\x6C\xB2\x4B\xF1\xCF\x7F\x96\xEA\x25\xA6\x7E\x4B\x6F\xEB\xDE\x76\x7E\x4F\x8F\x4F\x19\xEF\xFB\xD1\xC8\x14\xB8\xA7\xFD\x39\x55\x3E\x26\x2A\x1B\x40\x65\x03\x20\x6C\x80\x72\x5E\x1B\xFC\xCC\x5F\xA7\xC6\xA5\xB7\xCC\xB9\xB6\x4B\xCB\x34\x5D\xD9\xAC\x53\x4A\x2B\x43\x3C\xA4\xD5\x95\x96\x73\xEC\xE4\xBE\x1E\xD3\xA8\x21\xBF\x64\xB7\xDA\xBB\x21\xA3\xD2\x63\xF3\xE9\x01\x2F\x6C\x00\x95\x4D\x81\xB2\xFB\xD1\xA9\xDF\xDC\x75\x0C\x87\xC0\xB1\x19\x71\x0A\x1C\xD9\x8F\xDA\xC7\xAC\xF8\x3A\x9B\x88\x13\xC4\x9B\x19\xCF\xDD\xCB\x7F\xE8\x53\x44\xD8\x6C\x0D\x33\x10\x31\x8D\xF2\xAF\x6F\xC0\x09\xE2\x33\x3F\x29\x6E\xCD\xC9\x3A\xB9\x1A\x85\xB0\x01\x68\x27\x6C\x22\xAB\x04\x40\x65\x03\x20\x6C\xCE\x5D\x5B\xAF\x73\xAF\xED\x1E\xA8\xFC\x0E\x86\x7C\x51\x91\xD5\x75\xC9\x4A\xBE\xF8\xEA\x60\x61\x03\xA8\x6C\x2A\xFF\x25\x74\xB9\x9E\x96\x34\x71\x03\x79\x61\x03\x08\x9B\xC1\x7C\x27\xB7\x52\x18\xDD\xA6\xE7\xCE\x09\x1B\xA8\xC7\xB6\xE7\xC0\x11\x36\x20\x70\x84\x0D\x08\x1C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\xF2\x07\x86\xD6\x35\x27\xF4\xCF\x3F\x7E\x00\x00\x00\x00\x49\x45\x4E\x44\xAE\x42\x60\x82"
local imgExit = nil
local selected_item = imgui.ImInt(0)
local text_buffer = imgui.ImBuffer(256)
local main_window_state = imgui.ImBool(false)
local checkbox_sprinthook = imgui.ImBool(false)
local checkbox_infinityrun = imgui.ImBool(false)
local checkbox_asp = imgui.ImBool(false)
local checkbox_asppp = imgui.ImBool(false)
local checkbox_bhop = imgui.ImBool(false)
local setbrigh = imgui.ImBool(false)
local slider_brightness = imgui.ImInt(0)
local checkbox_noreload = imgui.ImBool(false)
local checkbox_nitro = imgui.ImBool(false)
local checkbox_mjump = imgui.ImBool(false)
local checkbox_gm = imgui.ImBool(false)
local checkbox_hz = imgui.ImBool(false)
local checkbox_radar = imgui.ImBool(false)
local checkbox_serradar = imgui.ImBool(false)
local checkbox_drift = imgui.ImBool(false)
local slider_drift = imgui.ImInt(0)
local checkbox_fluder = imgui.ImBool(false)
sprint = false
function main()
while not isSampAvailable() do wait(0) end
msg('Загружен.')
msg('Активация - {fae7b5}/ctools')
msg('Автор - {fae7b5}Shvchuk.')
sampRegisterChatCommand("ctools", function()
main_window_state.v = not main_window_state.v
end)
while true do
wait(0)
if checkbox_sprinthook.v then
if isCharOnFoot(playerPed) and isKeyDown(0x10) and isKeyCheckAvailable() then
setGameKeyState(16, 256)
wait(10)
setGameKeyState(16, 0)
end
end
if checkbox_infinityrun.v then
mem.setint8(0xB7CEE4, 1)
end
if checkbox_noreload.v then
memory.setint32(0x969178, 1)
else
memory.setint32(0x969178, 0)
end
if checkbox_nitro.v then
memory.setint32(0x969165, 1)
else
memory.setint32(0x969165, 0)
end
if checkbox_mjump.v then
memory.setint32(0x96916C, 1)
else
memory.setint32(0x96916C, 0)
end
if checkbox_gm.v then
memory.setint32(0x96916D, 1)
else
memory.setint32(0x96916D, 0)
end
if checkbox_hz.v then
memory.setint32(0xBA6794, 1)
else
memory.setint32(0xBA6794, 0)
end
if checkbox_radar.v then
memory.setint32(0xBA676C, 1)
else
memory.setint32(0xBA676C, 0)
end
if checkbox_serradar.v then
memory.setint32(0xA444A4, 1)
else
memory.setint32(0xA444A4, 0)
end
if checkbox_fluder.v then
sampSendChat(u8:decode(text_buffer.v))
else
end
if checkbox_drift.v then
if isCharInAnyCar(playerPed) then
local car = storeCarCharIsInNoSave(playerPed)
local speed = getCarSpeed(car)
isCarInAirProper(car)
setCarCollision(car, true)
if isKeyDown(VK_LSHIFT) and isVehicleOnAllWheels(car) and doesVehicleExist(car) and speed > 5.0 then
setCarCollision(car, false)
if isCarInAirProper(car) then setCarCollision(car, true)
if isKeyDown(VK_A)
then
addToCarRotationVelocity(car, 0, 0, 0.1)
end
if isKeyDown(VK_D)
then
addToCarRotationVelocity(car, 0, 0, -0.1)
end
end
end
end
else
end
if setbrigh.v then
setBrightness(slider_brightness.v)
end
imgui.Process = main_window_state.v
end
end
function msg(text)
sampAddChatMessage('[Cream Tools]: {FFFFFF}'.. text,0xfae7b5)
end
function imgui.OnDrawFrame()
imgui.SetNextWindowPos(imgui.ImVec2(sw /2, sh /2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.SetNextWindowSize(imgui.ImVec2(640, 480), imgui.Cond.FirstUseEver)
imgui.Begin('Cream Tools by Shvchuk 3.2', main_window_state,imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize)
if imgui.Button(u8'Чат', imgui.ImVec2(195, 35)) then selecselect_imgui_window = 1 end imgui.SameLine() if imgui.Button(u8'Скрипты', imgui.ImVec2(195, 35)) then selecselect_imgui_window = 2 end imgui.SameLine() if imgui.Button(u8'Параметры экрана', imgui.ImVec2(195, 35)) then selecselect_imgui_window = 3 end
imgui.Text(os.date())
imgui.Separator()
if selecselect_imgui_window == 1 then
imgui.Text(u8 'Взаимодействие с чатом')
imgui.PushItemWidth(400)
imgui.InputText(u8 'поле ввода', text_buffer)
if imgui.Button(u8 'Сохранить в чате', imgui.ImVec2(400, 0)) then
msg(u8:decode(text_buffer.v))
end
if imgui.Button(u8 'Отправить в чат', imgui.ImVec2(400, 0)) then
sampSendChat(u8:decode(text_buffer.v))
end
if imgui.Button(u8 'Очистить чат') then
ClearChat()
end
imgui.SameLine()
if imgui.Checkbox(u8"Флудер", checkbox_fluder) then
if checkbox_fluder.v then
printStringNow('Flooder ON', 50000)
else
printStringNow('Flooder OFF', 1500)
end
end
elseif selecselect_imgui_window == 2 then
imgui.Text(u8'Вспомогательные скрипты:')
if imgui.Checkbox(u8"Sprinthook - Быстрый бег", checkbox_sprinthook) then
if checkbox_sprinthook.v then
msg("{fae7b5}SprintHook - {50c878}activated")
else
msg("{fae7b5}SprintHook - {ff2b2b}deactivated")
end
end
if imgui.Checkbox(u8"Infinity Run - Бесконечный бег", checkbox_infinityrun) then
if checkbox_infinityrun.v then
msg("{fae7b5}Infinity Run - {50c878}activated")
else
msg("{fae7b5}Infinity Run - {ff2b2b}deactivated")
end
end
if imgui.Checkbox(u8"Allow Bhop - Помощь в банни хопе", checkbox_bhop) then
if checkbox_bhop.v then
msg("{fae7b5}Allow Bhop - {50c878}activated")
else
msg("{fae7b5}Allow Bhop - {ff2b2b}deactivated")
end
end
if imgui.Checkbox(u8"Drift Mod - Дрифт на shift", checkbox_drift) then
if checkbox_drift.v then
msg("{fae7b5}Drift Mod - {50c878}activated")
else
msg("{fae7b5}Drift Mod - {ff2b2b}deactivated")
end
end
imgui.Text(u8'Читы:')
if imgui.Checkbox(u8"No reload - нет перезарядки", checkbox_noreload) then
if checkbox_noreload.v then
msg("{fae7b5}No reload - {50c878}activated")
else
msg("{fae7b5}No reload - {ff2b2b}deactivated")
end
end
if imgui.Checkbox(u8"All car nitro - На всех машинах есть нитро", checkbox_nitro) then
if checkbox_nitro.v then
msg("{fae7b5}All car nitro - {50c878}activated")
else
msg("{fae7b5}All car nitro - {ff2b2b}deactivated")
end
end
if imgui.Checkbox(u8"Mega Jump - Мега прыжок", checkbox_mjump) then
if checkbox_mjump.v then
msg("{fae7b5}Mega Jump - {50c878}activated")
else
msg("{fae7b5}Mega Jump - {ff2b2b}deactivated")
end
end
if imgui.Checkbox(u8"GodMode - Бесконечное здоровье", checkbox_gm) then
if checkbox_gm.v then
msg("{fae7b5}GodMode - {50c878}activated")
else
msg("{fae7b5}GodMode - {ff2b2b}deactivated")
end
end
elseif selecselect_imgui_window == 3 then
if imgui.Combo(u8'', selected_item, {'16:9 (~1920x1080)', '16:10 (~1728x1080)', '4:3 (~1440x1080)'}, 3) then
if selected_item.v == 0 then
memory.fill(0x6FF452, 0x90, 6, true)
memory.setfloat(0xC3EFA4, 1.3, true)
msg('Разрешение экрана изменено на 16:9')
end
if selected_item.v == 1 then
memory.fill(0x6FF452, 0x90, 6, true)
memory.setfloat(0xC3EFA4, 1.1, true)
msg('Разрешение экрана изменено на 16:10')
end
if selected_item.v == 2 then
memory.fill(0x6FF452, 0x90, 6, true)
memory.setfloat(0xC3EFA4, 0.999, true)
msg('Разрешение экрана изменено на 4:3')
end
end
imgui.SameLine() imgui.Text(u8"разрешение экрана")
imgui.Text('Brightness')
imgui.SameLine()
imgui.Checkbox(u8"изменить яркость игры", setbrigh)
imgui.SliderInt('##bright', slider_brightness, 0, 700)
if imgui.Checkbox(u8"Синхронизировать FPS c герцовкой монитора", checkbox_hz) then
if checkbox_hz.v then
msg("{fae7b5}Синхронизация FPS c hz - {50c878}activated")
else
msg("{fae7b5}Синхронизация FPS c hz - {ff2b2b}deactivated")
end
end
if imgui.Checkbox(u8"Прозрачный радар", checkbox_radar) then
if checkbox_radar.v then
msg("{fae7b5}Прозрачный радар - {50c878}activated")
else
msg("{fae7b5}Прозрачный радар - {ff2b2b}deactivated")
end
end
imgui.SameLine()
if imgui.Checkbox(u8"Серый радар", checkbox_serradar) then
if checkbox_serradar.v then
msg("{fae7b5}Прозрачный радар - {50c878}activated")
else
msg("{fae7b5}Прозрачный радар - {ff2b2b}deactivated")
end
end
end
imgui.End()
end
function setBrightness(int)
memory.setint32(0x00BA6784, int)
end
function q.onSendPlayerSync(data)
if checkbox_bhop.v then
if data.keysData == 40 or data.keysData == 42 then sendOnfootSync(); data.keysData = 32 end
end
end
function sendOnfootSync()
local _, myId = sampGetPlayerIdByCharHandle(PLAYER_PED)
local data = allocateMemory(68)
sampStorePlayerOnfootData(myId, data)
setStructElement(data, 4, 1, 0, false)
sampSendOnfootData(data)
freeMemory(data)
end
function isKeyCheckAvailable()
if not isSampLoaded() then
return true
end
if not isSampfuncsLoaded() then
return not sampIsChatInputActive() and not sampIsDialogActive()
end
return not sampIsChatInputActive() and not sampIsDialogActive() and not isSampfuncsConsoleActive()
end
function ClearChat()
memory.fill(sampGetChatInfoPtr() + 306, 0x0, 25200)
memory.write(sampGetChatInfoPtr() + 306, 25562, 4, 0x0)
memory.write(sampGetChatInfoPtr() + 0x63DA, 1, 1)
end
function apply_custom_style()
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(15, 15)
style.WindowRounding = 15.0
style.FramePadding = ImVec2(5, 5)
style.ItemSpacing = ImVec2(12, 8)
style.ItemInnerSpacing = ImVec2(8, 6)
style.IndentSpacing = 25.0
style.ScrollbarSize = 15.0
style.ScrollbarRounding = 15.0
style.GrabMinSize = 15.0
style.GrabRounding = 7.0
style.ChildWindowRounding = 8.0
style.FrameRounding = 6.0
colors[clr.Text] = ImVec4(0.95, 0.96, 0.98, 1.00)
colors[clr.TextDisabled] = ImVec4(0.36, 0.42, 0.47, 1.00)
colors[clr.WindowBg] = ImVec4(0.11, 0.15, 0.17, 0.98)
colors[clr.ChildWindowBg] = ImVec4(0.15, 0.18, 0.22, 1.00)
colors[clr.PopupBg] = ImVec4(0.08, 0.08, 0.08, 0.94)
colors[clr.Border] = ImVec4(0.43, 0.43, 0.50, 0.50)
colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.FrameBg] = ImVec4(0.20, 0.25, 0.29, 1.00)
colors[clr.FrameBgHovered] = ImVec4(0.12, 0.20, 0.28, 1.00)
colors[clr.FrameBgActive] = ImVec4(0.09, 0.12, 0.14, 1.00)
colors[clr.TitleBg] = ImVec4(0.09, 0.12, 0.14, 0.65)
colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.00, 0.00, 0.51)
colors[clr.TitleBgActive] = ImVec4(0.08, 0.10, 0.12, 1.00)
colors[clr.MenuBarBg] = ImVec4(0.15, 0.18, 0.22, 1.00)
colors[clr.ScrollbarBg] = ImVec4(0.02, 0.02, 0.02, 0.39)
colors[clr.ScrollbarGrab] = ImVec4(0.20, 0.25, 0.29, 1.00)
colors[clr.ScrollbarGrabHovered] = ImVec4(0.18, 0.22, 0.25, 1.00)
colors[clr.ScrollbarGrabActive] = ImVec4(0.09, 0.21, 0.31, 1.00)
colors[clr.ComboBg] = ImVec4(0.20, 0.25, 0.29, 1.00)
colors[clr.CheckMark] = ImVec4(0.28, 0.56, 1.00, 1.00)
colors[clr.SliderGrab] = ImVec4(0.28, 0.56, 1.00, 1.00)
colors[clr.SliderGrabActive] = ImVec4(0.37, 0.61, 1.00, 1.00)
colors[clr.Button] = ImVec4(0.20, 0.25, 0.29, 1.00)
colors[clr.ButtonHovered] = ImVec4(0.28, 0.56, 1.00, 1.00)
colors[clr.ButtonActive] = ImVec4(0.06, 0.53, 0.98, 1.00)
colors[clr.Header] = ImVec4(0.20, 0.25, 0.29, 0.55)
colors[clr.HeaderHovered] = ImVec4(0.26, 0.59, 0.98, 0.80)
colors[clr.HeaderActive] = ImVec4(0.26, 0.59, 0.98, 1.00)
colors[clr.ResizeGrip] = ImVec4(0.26, 0.59, 0.98, 0.25)
colors[clr.ResizeGripHovered] = ImVec4(0.26, 0.59, 0.98, 0.67)
colors[clr.ResizeGripActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
colors[clr.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16)
colors[clr.CloseButtonHovered] = ImVec4(0.40, 0.39, 0.38, 0.39)
colors[clr.CloseButtonActive] = ImVec4(0.40, 0.39, 0.38, 1.00)
colors[clr.PlotLines] = ImVec4(0.61, 0.61, 0.61, 1.00)
colors[clr.PlotLinesHovered] = ImVec4(1.00, 0.43, 0.35, 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.25, 1.00, 0.00, 0.43)
colors[clr.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
end
apply_custom_style()