__name__ = 'ULTIMATE GENRL' __author__ = 'lay3r' __edited__ = 'scq' local inicfg = require 'inicfg' local lfs = require 'lfs' local imgui = require 'imgui' local ffi = require 'ffi' local encoding = require 'encoding' local dlstatus = require('moonloader').download_status encoding.default = 'CP1251' u8 = encoding.UTF8 local afkTick = 0 local afk = false local soundsDir = getGameDirectory()..'\\moonloader\\resource\\ugenrl\\' local settingsFile = 'ugenrl.ini' settings = inicfg.load({ main = { enable = false, weapon = true, enemyWeapon = true, enemyWeaponDist = 70, hit = true, pain = true, kill = true, hints = true, notifications = true }, volume = { weapon = 0.80, hit = 0.80, pain = 0.80, kill = 0.80 }, sounds = { [22] = '9mm.wav', [23] = 'SDPistol.wav', [24] = 'Deagle.1.wav', [25] = 'Shotgun.wav', [26] = 'Sawnoff-Shotgun.wav', [27] = 'Combat-Shotgun.wav', [28] = 'Uzi.wav', [29] = 'MP5.wav', [30] = 'AK-47.wav', [31] = 'M4.wav', [32] = 'Tec-9.wav', [33] = '1.wav', [34] = 'Sniper.wav', [38] = 'Minigun.wav', hit = 'Hit.1.wav', pain = 'Pain.1.wav', kill = 'Kill.1.mp3' } }, settingsFile) if not doesFileExist('moonloader\\config\\'..settingsFile) then inicfg.save(settings, settingsFile) end local show_main_window = imgui.ImBool(false) local show_main_settings = imgui.ImBool(false) local check_for_updates = imgui.ImBool(false) local enable_checkbox = imgui.ImBool(settings.main.enable) local weapon_checkbox = imgui.ImBool(settings.main.weapon) local enemyweapon_checkbox = imgui.ImBool(settings.main.enemyWeapon) local hit_checkbox = imgui.ImBool(settings.main.hit) local pain_checkbox = imgui.ImBool(settings.main.pain) local kill_checkbox = imgui.ImBool(settings.main.kill) local notifications_checkbox = imgui.ImBool(settings.main.notifications) local hints_checkbox = imgui.ImBool(settings.main.hints) local weapon_volume_slider = imgui.ImFloat(settings.volume.weapon) local hit_volume_slider = imgui.ImFloat(settings.volume.hit) local pain_volume_slider = imgui.ImFloat(settings.volume.pain) local kill_volume_slider = imgui.ImFloat(settings.volume.kill) local enemyweapon_dist = imgui.ImInt(settings.main.enemyWeaponDist) local deagle_selected = imgui.ImInt(-1) local shotgun_selected = imgui.ImInt(-1) local m4_selected = imgui.ImInt(-1) local rifle_selected = imgui.ImInt(-1) local hit_selected = imgui.ImInt(-1) local pain_selected = imgui.ImInt(-1) local kill_selected = imgui.ImInt(-1) function chatMessage(text) if settings.main.notifications then sampAddChatMessage('{aa3333}['..__name__..'] {ffffff}'..text, -1) end end function printMessage(text) if settings.main.notifications then printStringNow('~r~~h~~h~~h~'..__name__..' ~w~~h~'..text, 2000) end end function imgui.OnDrawFrame() if show_main_window.v then local sw, sh = getScreenResolution() imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5)) imgui.SetNextWindowSize(imgui.ImVec2(320, 180), imgui.Cond.FirstUseEver) imgui.Begin(string.upper(__name__), show_main_window, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize) if imgui.Checkbox(u8'Состояние', enable_checkbox) then switchMainSettings('enable') end if imgui.IsItemHovered() and settings.main.hints then imgui.BeginTooltip() imgui.PushTextWrapPos(450) imgui.TextUnformatted(u8'Включить или выключить Ultimate Genrl') imgui.PopTextWrapPos() imgui.EndTooltip() end if enable_checkbox.v then imgui.SameLine() imgui.SetCursorPos(imgui.ImVec2(210, 28)) imgui.SetCursorPos(imgui.ImVec2(245, 28)) if imgui.Button(u8'Настройки', show_main_settings) then imgui.OpenPopup('#Settings') end if imgui.BeginPopup('#Settings') then if imgui.BeginMenu(u8'Звуки') then if imgui.BeginMenu(u8'Deagle ('..settings.sounds[24]..')') then if imgui.ListBox('##listbox0', deagle_selected, deagleSounds, #deagleSounds) then changeSound(24, deagleSounds[deagle_selected.v+1]) end imgui.EndMenu() end if imgui.BeginMenu(u8'Shotgun ('..settings.sounds[25]..')') then if imgui.ListBox('##listbox1', shotgun_selected, shotgunSounds, #shotgunSounds) then changeSound(25, shotgunSounds[shotgun_selected.v+1]) end imgui.EndMenu() end if imgui.BeginMenu(u8'M4 ('..settings.sounds[31]..')') then if imgui.ListBox('##listbox2', m4_selected, m4Sounds, #m4Sounds) then changeSound(31, m4Sounds[m4_selected.v+1]) end imgui.EndMenu() end if imgui.BeginMenu(u8'Rifle ('..settings.sounds[33]..')') then if imgui.ListBox('##listbox6', rifle_selected, rifleSounds, #rifleSounds) then changeSound(33, rifleSounds[rifle_selected.v+1]) end imgui.EndMenu() end if imgui.BeginMenu(u8'Колокольчик ('..settings.sounds.hit..')') then if imgui.ListBox('##listbox3', hit_selected, hitSounds, #hitSounds) then changeSound('hit', hitSounds[hit_selected.v+1]) end imgui.EndMenu() end if imgui.BeginMenu(u8'Боль ('..settings.sounds.pain..')') then if imgui.ListBox('##listbox4', pain_selected, painSounds, #painSounds) then changeSound('pain', painSounds[pain_selected.v+1]) end imgui.EndMenu() end if imgui.BeginMenu(u8'Убийство ('..settings.sounds.kill..')') then if imgui.ListBox('##listbox5', kill_selected, killSounds, #killSounds) then changeSound('kill', killSounds[kill_selected.v+1]) end imgui.EndMenu() end imgui.EndMenu() end if imgui.BeginMenu(u8'Громкость') then imgui.Text(u8'Оружие') if imgui.SliderFloat('##sliderfloat0', weapon_volume_slider, 0.00, 1.00, '%.2f') then settings.volume.weapon = weapon_volume_slider.v inicfg.save(settings, settingsFile) end imgui.Text(u8'Колокольчик') if imgui.SliderFloat('##sliderfloat1', hit_volume_slider, 0.00, 1.00, '%.2f') then settings.volume.hit = hit_volume_slider.v inicfg.save(settings, settingsFile) end imgui.Text(u8'Боль') if imgui.SliderFloat('##sliderfloat2', pain_volume_slider, 0.00, 1.00, '%.2f') then settings.volume.pain = pain_volume_slider.v inicfg.save(settings, settingsFile) end imgui.Text(u8'Убийство') if imgui.SliderFloat('##sliderfloat3', kill_volume_slider, 0.00, 1.00, '%.2f') then settings.volume.kill = kill_volume_slider.v inicfg.save(settings, settingsFile) end imgui.EndMenu() end if imgui.BeginMenu(u8'Прочее') then imgui.Text(u8'Радиус звука оружия других игроков') if imgui.SliderInt('##sliderint0', enemyweapon_dist, 0, 100) then settings.main.enemyWeaponDist = enemyweapon_dist.v inicfg.save(settings, settingsFile) end if imgui.Checkbox(u8'Уведомления', notifications_checkbox) then switchMainSettings('notifications') end if imgui.Checkbox(u8'Подсказки', hints_checkbox) then switchMainSettings('hints') end imgui.EndMenu() end imgui.EndPopup() end if imgui.Checkbox(u8'Оружие', weapon_checkbox) then switchMainSettings('weapon') end if imgui.IsItemHovered() and settings.main.hints then imgui.BeginTooltip() imgui.PushTextWrapPos(450) imgui.TextUnformatted(u8'Воспроизводится при стрельбе') imgui.PopTextWrapPos() imgui.EndTooltip() end if weapon_checkbox.v then if imgui.Checkbox(u8'Оружие других игроков', enemyweapon_checkbox) then switchMainSettings('enemyWeapon') end end if imgui.IsItemHovered() and settings.main.hints and weapon_checkbox.v then imgui.BeginTooltip() imgui.PushTextWrapPos(450) imgui.TextUnformatted(u8'Воспроизводится при стрельбе других игроков') imgui.PopTextWrapPos() imgui.EndTooltip() end if imgui.Checkbox(u8'Колокольчик', hit_checkbox) then switchMainSettings('hit') end if imgui.IsItemHovered() and settings.main.hints then imgui.BeginTooltip() imgui.PushTextWrapPos(450) imgui.TextUnformatted(u8'Воспроизводится при нанесении урона') imgui.PopTextWrapPos() imgui.EndTooltip() end if imgui.Checkbox(u8'Боль', pain_checkbox) then switchMainSettings('pain') end if imgui.IsItemHovered() and settings.main.hints then imgui.BeginTooltip() imgui.PushTextWrapPos(450) imgui.TextUnformatted(u8'Воспроизводится при получении урона') imgui.PopTextWrapPos() imgui.EndTooltip() end if imgui.Checkbox(u8'Убийство', kill_checkbox) then switchMainSettings('kill') end if imgui.IsItemHovered() and settings.main.hints then imgui.BeginTooltip() imgui.PushTextWrapPos(450) imgui.TextUnformatted(u8'Воспроизводится при убийстве игрока (работает только с килллистом)') imgui.PopTextWrapPos() imgui.EndTooltip() end imgui.SameLine() imgui.SetCursorPos(imgui.ImVec2(285, 150)) imgui.TextDisabled('Info') if imgui.IsItemHovered() then imgui.BeginTooltip() imgui.PushTextWrapPos(450) imgui.TextUnformatted(u8'Автор: '..__author__..u8' (ред. '..__edited__..')') imgui.PopTextWrapPos() imgui.EndTooltip() end end imgui.End() end end function main() loadSounds() if not isSampfuncsLoaded() or not isSampLoaded() then return end while not isSampAvailable() or not sampIsLocalPlayerSpawned() do wait(100) end if settings.main.enable then offSound(true) end sampRegisterChatCommand('ugs', function() show_main_window.v = not show_main_window.v loadSounds() end) chatMessage('Загружен. Автор: {aa3333}'..__author__..'{ffffff}. Команда: {aa3333}/ugs') while true do wait(0) imgui.Process = show_main_window.v end end if not doesDirectoryExist(soundsDir) then chatMessage('Нет соответствующих папок в директории '..soundsDir..', создаю новые') lfs.mkdir(soundsDir) lfs.mkdir(soundsDir..'Deagle') lfs.mkdir(soundsDir..'M4') lfs.mkdir(soundsDir..'Shotgun') lfs.mkdir(soundsDir..'Rifle') lfs.mkdir(soundsDir..'Hit') lfs.mkdir(soundsDir..'Pain') lfs.mkdir(soundsDir..'Kill') lfs.mkdir(soundsDir..'Other') end function onSystemInitialized() writeMemory(11926728, 4, representFloatAsInt(1.0), false) end ffi.cdef([[ unsigned long GetTickCount(); ]]) local function getTickCount() return ffi.C.GetTickCount() end local painSoundDelay = getTickCount() function getListOfSounds(name) local soundFiles = {} for line in lfs.dir(soundsDir..name) do if line:find('.ogg') or line:find('.wav') or line:find('.mp3') or line:find('.mp2') or line:find('.mp1') then soundFiles[#soundFiles+1] = u8:encode(line) end end return soundFiles end function loadSounds() deagleSounds = getListOfSounds('Deagle') shotgunSounds = getListOfSounds('Shotgun') m4Sounds = getListOfSounds('M4') rifleSounds = getListOfSounds('Rifle') hitSounds = getListOfSounds('Hit') painSounds = getListOfSounds('Pain') killSounds = getListOfSounds('Kill') end function offSound(bool) if bool then callFunction(0x507430, 0, 0) writeMemory(0x507750, 1, 195, true) if getModuleHandle('__EvolveVoice.asi') == 0 then local bs = raknetNewBitStream() raknetEmulRpcReceiveBitStream(42, bs) raknetDeleteBitStream(bs) end else callFunction(0x507440, 0, 0) writeMemory(0x507750, 1, 86, true) end end function switchMainSettings(name) settings.main[name] = not settings.main[name] if name == 'enable' then offSound(settings.main[name]) end inicfg.save(settings, settingsFile) end function changeSound(id, name) playSound(getSoundDirectory(id), name, settings.volume.weapon) settings.sounds[id] = name inicfg.save(settings, settingsFile) end function playSound(directory, soundFile, soundVol) if getTickCount() < afkTick or afk or not sampIsLocalPlayerSpawned() then return false end if not soundFile or not directory or not doesFileExist(soundsDir..directory..soundFile) then chatMessage('Звук для данного оружия не был найден {aa3333}('..directory..soundFile..'){ffffff}.') return false end if audio then collectgarbage() end local audio = loadAudioStream(soundsDir..directory..soundFile) if audio == nil then chatMessage('Звук для данного оружия не был создан {aa3333}('..directory..soundFile..'){ffffff}.') else setAudioStreamVolume(audio, soundVol) setAudioStreamState(audio, 1) clearSound(audio) end end function play3dSound(directory, soundFile, soundVol, charHandle) if getTickCount() < afkTick or afk or not sampIsLocalPlayerSpawned() then return false end if not soundFile or not directory or not doesFileExist(soundsDir..directory..soundFile) then chatMessage('3D звук для данного оружия не был найден {aa3333}('..directory..soundFile..'){ffffff}.') return false end if audio3d then collectgarbage() end local audio3d = load3dAudioStream(soundsDir..directory..soundFile) if audio3d == nil then chatMessage('3D звук для данного оружия не был создан {aa3333}('..directory..soundFile..'){ffffff}.') else setPlay3dAudioStreamAtChar(audio3d, charHandle) setAudioStreamVolume(audio3d, soundVol) setAudioStreamState(audio3d, 1) clearSound(audio3d) end end function clearSound(audio) lua_thread.create(function() while getAudioStreamState(audio) == 1 do wait(50) end collectgarbage() end) end function onWindowMessage(msg, wparam, lparam) if msg == 0x0007 then offSound(settings.main.enable) afkTick = getTickCount() + 1000 afk = false end if msg == 0x0008 then afk = true end if msg == 0x0105 and wparam == 0x55 then switchMainSettings('enable') enable_checkbox = imgui.ImBool(settings.main.enable) if settings.main.enable then printMessage('is ON') else printMessage('is OFF') end end end function onSendRpc(id, bs, priority, reliability, orderingChannel, shiftTs) if settings.main.enable and getTickCount() > afkTick and not afk then if id == 115 then raknetBitStreamResetReadPointer(bs) local act = raknetBitStreamReadBool(bs) raknetBitStreamReadInt16(bs) raknetBitStreamReadFloat(bs) local dmgWeaponId = raknetBitStreamReadInt32(bs) raknetBitStreamReadInt32(bs) if settings.main.pain and act then if getTickCount() > painSoundDelay then playSound('Pain\\', settings.sounds.pain, settings.volume.pain) if dmgWeaponId == 9 or dmgWeaponId == 37 or dmgWeaponId == 41 then painSoundDelay = getTickCount() + 300 end end end if settings.main.hit and not act then playSound('Hit\\', settings.sounds.hit, settings.volume.hit) end end end end function onReceiveRpc(id, bs) if settings.main.kill and settings.main.enable and id == 55 and getTickCount() > afkTick and not afk then raknetBitStreamResetReadPointer(bs) local killerId = raknetBitStreamReadInt16(bs) local playerId = raknetBitStreamReadInt16(bs) if killerId == select(2, sampGetPlayerIdByCharHandle(PLAYER_PED)) then playSound('Kill\\', settings.sounds.kill, settings.volume.kill) end end if id == 41 then if settings.main.enable then return false end end end function onReceivePacket(id, bs) if settings.main.enable and settings.main.weapon and settings.main.enemyWeapon and getTickCount() > afkTick and not afk and id == 206 then raknetBitStreamIgnoreBits(bs, 8) local playerId = raknetBitStreamReadInt16(bs) raknetBitStreamIgnoreBits(bs, 312) local weaponId = raknetBitStreamReadInt8(bs) local result, charHandle = sampGetCharHandleBySampPlayerId(playerId) if result then local my_x, my_y, my_z = getCharCoordinates(PLAYER_PED) local char_x, char_y, char_z = getCharCoordinates(charHandle) if getDistanceBetweenCoords3d(my_x, my_y, my_z, char_x, char_y, char_z) < (settings.main.enemyWeaponDist / 2) then play3dSound(getSoundDirectory(weaponId), settings.sounds[weaponId], settings.volume.weapon, charHandle) end end end end function onSendPacket(id, bs, priority, reliability, orderingChannel) if settings.main.enable and settings.main.weapon and getTickCount() > afkTick and not afk and id == 206 then raknetBitStreamIgnoreBits(bs, 320) local weaponId = raknetBitStreamReadInt8(bs) playSound(getSoundDirectory(weaponId), settings.sounds[weaponId], settings.volume.weapon) end end function getSoundDirectory(weapon) if tonumber(weapon) == 24 then return 'Deagle\\' elseif tonumber(weapon) == 25 then return 'Shotgun\\' elseif tonumber(weapon) == 31 then return 'M4\\' elseif weapon == "hit" then return 'Hit\\' elseif weapon == "pain" then return 'Pain\\' elseif weapon == "kill" then return 'Kill\\' elseif tonumber(weapon) == 33 then return 'Rifle\\' else return 'Other\\' end end function onScriptTerminate(script, quitGame) if script == thisScript() and not quitGame then offSound(true) printMessage('is OFF') chatMessage('Скрипт был отключен.') thisScript():reload() end end function theme() imgui.SwitchContext() local style = imgui.GetStyle() local colors = style.Colors local clr = imgui.Col local ImVec4 = imgui.ImVec4 local ImVec2 = imgui.ImVec2 style.WindowPadding = imgui.ImVec2(8, 8) style.WindowRounding = 6 style.ChildWindowRounding = 5 style.FramePadding = imgui.ImVec2(5, 3) style.FrameRounding = 3.0 style.ItemSpacing = imgui.ImVec2(5, 4) style.ItemInnerSpacing = imgui.ImVec2(4, 4) style.IndentSpacing = 21 style.ScrollbarSize = 10.0 style.ScrollbarRounding = 13 style.GrabMinSize = 8 style.GrabRounding = 1 style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5) style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5) colors[clr.Text] = ImVec4(0.95, 0.96, 0.98, 1.00); colors[clr.TextDisabled] = ImVec4(0.29, 0.29, 0.29, 1.00); colors[clr.WindowBg] = ImVec4(0, 0, 0, 1.00); colors[clr.ChildWindowBg] = ImVec4(0, 0, 0, 1.00); colors[clr.PopupBg] = ImVec4(0.08, 0.08, 0.08, 1.00); colors[clr.Border] = ImVec4(0.14, 0.14, 0.14, 1.00); colors[clr.BorderShadow] = ImVec4(1.00, 1.00, 1.00, 0.10); colors[clr.FrameBg] = ImVec4(0.22, 0.22, 0.22, 1.00); colors[clr.FrameBgHovered] = ImVec4(0.18, 0.18, 0.18, 1.00); colors[clr.FrameBgActive] = ImVec4(0, 0, 0, 1.00); colors[clr.TitleBg] = ImVec4(0, 0, 0, 1.00); colors[clr.TitleBgActive] = ImVec4(0, 0, 0, 1.00); colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.00, 0.00, 1.00); colors[clr.MenuBarBg] = ImVec4(0.05, 0.05, 0.05, 1.00); colors[clr.ScrollbarBg] = ImVec4(0.02, 0.02, 0.02, 1.00); colors[clr.ScrollbarGrab] = ImVec4(0.36, 0.36, 0.36, 1.00); colors[clr.ScrollbarGrabHovered] = ImVec4(0.18, 0.22, 0.25, 1.00); colors[clr.ScrollbarGrabActive] = ImVec4(0.24, 0.24, 0.24, 1.00); colors[clr.ComboBg] = ImVec4(0, 0, 0, 1.00); colors[clr.CheckMark] = ImVec4(0.59, 0.59, 0.59, 1.00); colors[clr.SliderGrab] = ImVec4(0, 0, 0, 1.00); colors[clr.SliderGrabActive] = ImVec4(0.10, 0.10, 0.10, 1.00); colors[clr.Button] = ImVec4(0.17, 0.17, 0.17, 1.00); colors[clr.ButtonHovered] = ImVec4(0.31, 0.31, 0.31, 1.00); colors[clr.ButtonActive] = ImVec4(0.11, 0.11, 0.11, 1.00); colors[clr.Header] = ImVec4(0.22, 0.22, 0.22, 1.00); colors[clr.HeaderHovered] = ImVec4(0.18, 0.18, 0.18, 1.00); colors[clr.HeaderActive] = ImVec4(0.09, 0.12, 0.14, 1.00); colors[clr.ResizeGrip] = ImVec4(0.25, 0.25, 0.25, 1.00); colors[clr.ResizeGripHovered] = ImVec4(0.25, 0.25, 0.25, 1.00); colors[clr.ResizeGripActive] = ImVec4(0.25, 0.25, 0.25, 1.00); colors[clr.CloseButton] = ImVec4(0.53, 0.53, 0.53, 1.00); colors[clr.CloseButtonHovered] = ImVec4(0.29, 0.29, 0.29, 1.00); colors[clr.CloseButtonActive] = ImVec4(0.15, 0.15, 0.15, 1.00); colors[clr.PlotLines] = ImVec4(0.61, 0.61, 0.61, 1.00); colors[clr.PlotLinesHovered] = ImVec4(0, 0, 0, 1.00); colors[clr.PlotHistogram] = ImVec4(0, 0, 0, 1.00); colors[clr.PlotHistogramHovered] = ImVec4(0, 0, 0, 1.00); colors[clr.TextSelectedBg] = ImVec4(0, 0, 0, 1.00); colors[clr.ModalWindowDarkening] = ImVec4(0.15, 0.15, 0.15, 1.00); end theme()