Как открыть Im-gui по активации команды в чат?

Sirccet

Участник
Автор темы
142
21
Версия SA-MP
  1. 0.3.7 (R1)
Вот к примеру скрипт. Я хочу не сочетание клавиш, а командой в чат.
Код:
script_name("Animation Manager")
script_author("Grinch_")
script_description("Animation manager for GTA San Andreas")
script_dependencies("imgui")
script_version("1.0")

--Keys
local keys =
{
    menu_key1        = 0xA4,  -- Left Alt
    menu_key2         = 0x6B,  -- Numpad +
}

-- Script Dependencies
local imgui       = require 'imgui'

local tmain =
{
    window         = imgui.ImBool(false),
    current_btn    = 1,
    loop           = imgui.ImBool(false),
    secondary      = imgui.ImBool(false),
    search_text    = imgui.ImBuffer(24),
    ifp_name       = imgui.ImBuffer(24),
    animation_name = imgui.ImBuffer(24),
}


local animations = {
    "AIRPORT$thrw_barl_thrw",
    "ATTRACTORS$Stepsit_in",
    "ATTRACTORS$Stepsit_loop",
    "ATTRACTORS$Stepsit_out",
    "BAR$Barcustom_get",
    "BAR$Barcustom_loop",
    "BAR$Barcustom_order",
    "BAR$BARman_idle",
    "BAR$Barserve_bottle",
    "BAR$Barserve_give",
    "BAR$Barserve_glass",
    "BAR$Barserve_in",
    "BAR$Barserve_loop",
    "BAR$Barserve_order",
    "BAR$dnk_stndF_loop",
    "BAR$dnk_stndM_loop",
    "BASEBALL$Bat_1",
    "BASEBALL$Bat_2",
    "BASEBALL$Bat_3",
    "BASEBALL$Bat_4",
    "BASEBALL$Bat_block",
    "BASEBALL$Bat_Hit_1",
    "BASEBALL$Bat_Hit_2",
    "BASEBALL$Bat_Hit_3",
    "BASEBALL$Bat_IDLE",
    "BASEBALL$Bat_M",
    "BASEBALL$BAT_PART",
    "BD_FIRE$BD_Fire1",
    "BD_FIRE$BD_Fire2",
    "BD_FIRE$BD_Fire3",
    "BD_FIRE$BD_GF_Wave",
    "BD_FIRE$BD_Panic_01",
    "BD_FIRE$BD_Panic_02",
    "BD_FIRE$BD_Panic_03",
    "BD_FIRE$BD_Panic_04",
    "BD_FIRE$BD_Panic_Loop",
    "BD_FIRE$Grlfrd_Kiss_03",
    "BD_FIRE$M_smklean_loop",
    "BD_FIRE$Playa_Kiss_03",
    "BD_FIRE$wash_up",
    "BEACH$bather",
    "BEACH$Lay_Bac_Loop",
    "BEACH$ParkSit_M_loop",
    "BEACH$ParkSit_W_loop",
    "BEACH$SitnWait_loop_W",
    "BENCHPRESS$gym_bp_celebrate",
    "BENCHPRESS$gym_bp_down",
    "BENCHPRESS$gym_bp_getoff",
    "BENCHPRESS$gym_bp_geton",
    "BENCHPRESS$gym_bp_up_A",
    "BENCHPRESS$gym_bp_up_B",
    "BENCHPRESS$gym_bp_up_smooth",
    "BF_INJECTION$BF_getin_LHS",
    "BF_INJECTION$BF_getin_RHS",
    "BF_INJECTION$BF_getout_LHS",
    "BF_INJECTION$BF_getout_RHS",
    "BIKED$BIKEd_Back",
    "BIKED$BIKEd_drivebyFT",
    "BIKED$BIKEd_drivebyLHS",
    "BIKED$BIKEd_drivebyRHS",
    "BIKED$BIKEd_Fwd",
    "BIKED$BIKEd_getoffBACK",
    "BIKED$BIKEd_getoffLHS",
    "BIKED$BIKEd_getoffRHS",
    "BIKED$BIKEd_hit",
    "BIKED$BIKEd_jumponL",
    "BIKED$BIKEd_jumponR",
    "BIKED$BIKEd_kick",
    "BIKED$BIKEd_Left",
    "BIKED$BIKEd_passenger",
    "BIKED$BIKEd_pushes",
    "POOL$POOL_Walk_Start",
    "POOL$POOL_XLong_Shot",
    "POOL$POOL_XLong_Shot_O",
    "POOL$POOL_XLong_Start",
    "POOL$POOL_XLong_Start_O",
    "POOR$WINWASH_Start",
    "POOR$WINWASH_Wash2Beg",
    "PYTHON$python_crouchfire",
    "PYTHON$python_crouchreload",
    "PYTHON$python_fire",
    "PYTHON$python_fire_poor",
    "PYTHON$python_reload",
    "QUAD$QUAD_back",
    "QUAD$QUAD_driveby_FT",
    "QUAD$QUAD_driveby_LHS",
    "QUAD$QUAD_driveby_RHS",
    "QUAD$QUAD_FWD",
    "QUAD$QUAD_getoff_B",
    "QUAD$QUAD_getoff_LHS",
    "QUAD$QUAD_getoff_RHS",
    "QUAD$QUAD_geton_LHS",
    "QUAD$QUAD_geton_RHS",
    "QUAD$QUAD_hit",
    "QUAD$QUAD_kick",
    "QUAD$QUAD_Left",
    "QUAD$QUAD_passenger",
    "QUAD$QUAD_reverse",
    "QUAD$QUAD_ride",
    "QUAD$QUAD_Right",
    "QUAD_DBZ$Pass_Driveby_BWD",
    "QUAD_DBZ$Pass_Driveby_FWD",
    "QUAD_DBZ$Pass_Driveby_LHS",
    "QUAD_DBZ$Pass_Driveby_RHS",
    "RAPPING$Laugh_01",
    "RAPPING$RAP_A_IN",
    "RAPPING$RAP_A_Loop",
    "RAPPING$RAP_A_OUT",
    "RAPPING$RAP_B_IN",
    "RAPPING$RAP_B_Loop",
    "RAPPING$RAP_B_OUT",
    "RAPPING$RAP_C_Loop",
    "RIFLE$RIFLE_crouchfire",
    "RIFLE$RIFLE_crouchload",
    "RIFLE$RIFLE_fire",
    "RIFLE$RIFLE_fire_poor",
    "RIFLE$RIFLE_load",
    "RIOT$RIOT_ANGRY",
    "RIOT$RIOT_ANGRY_B",
    "RIOT$RIOT_challenge",
    "RIOT$RIOT_CHANT",
    "RIOT$RIOT_FUKU",
    "RIOT$RIOT_PUNCHES",
    "RIOT$RIOT_shout",
    "ROB_BANK$CAT_Safe_End",
    "ROB_BANK$CAT_Safe_Open",
    "ROB_BANK$CAT_Safe_Open_O",
    "ROB_BANK$CAT_Safe_Rob",
    "ROB_BANK$SHP_HandsUp_Scr",
    "ROCKET$idle_rocket",
    "ROCKET$RocketFire",
    "ROCKET$run_rocket",
    "ROCKET$walk_rocket",
    "ROCKET$WALK_start_rocket",
    "RUSTLER$Plane_align_LHS",
    "RUSTLER$Plane_close",
    "RUSTLER$Plane_getin",
    "RUSTLER$Plane_getout",
    "RUSTLER$Plane_open",
    "RYDER$RYD_Beckon_01",
    "RYDER$RYD_Beckon_02",
    "RYDER$RYD_Beckon_03",
    "RYDER$RYD_Die_PT1",
    "RYDER$RYD_Die_PT2",
    "RYDER$Van_Crate_L",
    "RYDER$Van_Crate_R",
    "RYDER$Van_Fall_L",
    "RYDER$Van_Fall_R",
    "RYDER$Van_Lean_L",
    "RYDER$Van_Lean_R",
    "RYDER$VAN_PickUp_E",
    "RYDER$VAN_PickUp_S",
    "RYDER$Van_Stand",
    "RYDER$Van_Stand_Crate",
    "RYDER$Van_Throw",
    "SCRATCHING$scdldlp",
    "SCRATCHING$scdlulp",
    "SCRATCHING$scdrdlp",
    "SCRATCHING$scdrulp",
    "SCRATCHING$sclng_l",
    "SCRATCHING$sclng_r",
    "SCRATCHING$scmid_l",
    "SCRATCHING$scmid_r",
    "SCRATCHING$scshrtl",
    "SCRATCHING$scshrtr",
    "SCRATCHING$sc_ltor",
    "SCRATCHING$sc_rtol",
    "SHAMAL$SHAMAL_align",
    "SHAMAL$SHAMAL_getin_LHS",
    "SHAMAL$SHAMAL_getout_LHS",
    "SHAMAL$SHAMAL_open",
    "SHOP$ROB_2Idle",
    "SHOP$ROB_Loop",
    "SHOP$ROB_Loop_Threat",
    "SHOP$ROB_Shifty",
    "SHOP$ROB_StickUp_In",
    "SHOP$SHP_Duck",
    "SHOP$SHP_Duck_Aim",
    "SHOP$SHP_Duck_Fire",
    "SHOP$SHP_Gun_Aim",
    "SHOP$SHP_Gun_Duck",
    "SHOP$SHP_Gun_Fire",
    "SHOP$SHP_Gun_Grab",
    "SHOP$SHP_Gun_Threat",
    "SHOP$SHP_HandsUp_Scr",
    "SHOP$SHP_Jump_Glide",
    "SHOP$SHP_Jump_Land",
    "SHOP$SHP_Jump_Launch",
    "SHOP$SHP_Rob_GiveCash",
    "SHOP$SHP_Rob_HandsUp",
    "SHOP$SHP_Rob_React",
    "SHOP$SHP_Serve_End",
    "SHOP$SHP_Serve_Idle",
    "SHOP$SHP_Serve_Loop",
    "SHOP$SHP_Serve_Start",
    "SHOP$Smoke_RYD",
    "SHOTGUN$shotgun_crouchfire",
    "SHOTGUN$shotgun_fire",
    "SHOTGUN$shotgun_fire_poor",
    "SILENCED$CrouchReload",
    "SILENCED$SilenceCrouchfire",
    "SILENCED$Silence_fire",
    "SILENCED$Silence_reload",
    "SKATE$skate_idle",
    "SKATE$skate_run",
    "SKATE$skate_sprint",
    "SMOKING$F_smklean_loop",
    "SMOKING$M_smklean_loop",
    "SMOKING$M_smkstnd_loop",
    "SMOKING$M_smk_drag",
    "SMOKING$M_smk_in",
    "SMOKING$M_smk_loop",
    "SMOKING$M_smk_out",
    "SMOKING$M_smk_tap",
    "SNIPER$WEAPON_sniper",
    "SPRAYCAN$spraycan_fire",
    "SPRAYCAN$spraycan_full",
    "STRIP$PLY_CASH",
    "STRIP$PUN_CASH",
    "WEAPONS$SHP_2H_Lift",
    "WEAPONS$SHP_2H_Lift_End",
    "WEAPONS$SHP_2H_Ret",
    "WEAPONS$SHP_2H_Ret_S",
    "WEAPONS$SHP_Ar_Lift",
    "WEAPONS$SHP_Ar_Lift_End",
    "WEAPONS$SHP_Ar_Ret",
    "WEAPONS$SHP_Ar_Ret_S",
    "WEAPONS$SHP_G_Lift_In",
    "WEAPONS$SHP_G_Lift_Out",
    "WEAPONS$SHP_Tray_In",
    "WEAPONS$SHP_Tray_Out",
    "WEAPONS$SHP_Tray_Pose",
    "WUZI$CS_Dead_Guy",
    "WUZI$CS_Plyr_pt1",
    "WUZI$CS_Plyr_pt2",
    "WUZI$CS_Wuzi_pt1",
    "WUZI$CS_Wuzi_pt2",
    "WUZI$Walkstart_Idle_01",
    "WUZI$Wuzi_follow",
    "WUZI$Wuzi_Greet_Plyr",
    "WUZI$Wuzi_Greet_Wuzi",
    "WUZI$Wuzi_grnd_chk",
    "WUZI$Wuzi_stand_loop",
    "WUZI$Wuzi_Walk",
}

function imgui.OnDrawFrame()
    if  tmain.window.v then

        imgui.SetNextWindowSize(imgui.ImVec2(350, 600),  imgui.Cond.FirstUseEver)

        imgui.Begin(string.format( '%s v%s by Grinch_',script.this.name,script.this.version),tmain.window,imgui.WindowFlags.NoCollapse)
        
        CreateButtons({"List","Search","Custom"},{List,Search,Custom})

        imgui.End()
    end
end

function List()
    imgui.Spacing()
    local menu_name = ""
    if imgui.BeginChild("") then
        for key,value in ipairs(animations) do
            local temp,_ = value:match("([^$]+)$([^$]+)")
            if menu_name ~= temp then
                menu_name = temp

                if imgui.CollapsingHeader(menu_name) then
                    imgui.Spacing()
                    for key,value in pairs(animations) do
                        local file,animation = value:match("([^$]+)$([^$]+)")
                        if menu_name == file then
                            AnimationEntry(file,animation)
                        end
                    end
                    imgui.Spacing()
                    imgui.Separator()
                    imgui.Spacing()
                end
            end
        end 
        imgui.EndChild()
    end

end

function Search()
    imgui.Dummy(imgui.ImVec2(0,10))

    imgui.PushItemWidth(imgui.GetWindowWidth()-100)
    imgui.InputText("Search ",tmain.search_text)
    imgui.PopItemWidth()

    imgui.Spacing()
    imgui.Text("Found entries :(" .. tmain.search_text.v .. ")")
    imgui.Separator()
    imgui.Spacing()
    if imgui.BeginChild("") then
        for key,value in pairs(animations) do
            file, animation = value:match("([^$]+)$([^$]+)")
            if (string.upper(animation):find(string.upper(tmain.search_text.v))) then
                AnimationEntry(file,animation)
            end
        end       
        imgui.Spacing()
        imgui.EndChild()
    end
end

function Custom()

    imgui.Dummy(imgui.ImVec2(0,10))
    
    imgui.InputText("IFP name",tmain.ifp_name)
    imgui.InputText("Animation name",tmain.animation_name)
    imgui.Spacing()
    if imgui.Button("Play animation",imgui.ImVec2(imgui.GetWindowWidth()-20,25)) then
        PlayAnimation(tmain.ifp_name.v,tmain.animation_name.v)
    end
end


function AnimationEntry(file,animation)
    if imgui.MenuItem(animation) then
        if file ~= "PED" then
            requestAnimation(file)
            loadAllModelsNow()
        end
        PlayAnimation(file,animation)
    end
end

function PlayAnimation(file,animation)
    if tmain.secondary.v == true then
        taskPlayAnimSecondary(PLAYER_PED,animation,file,4.0,tmain.loop.v,0,0,0,-1) 
    else
        taskPlayAnim(PLAYER_PED,animation,file,4.0,tmain.loop.v,0,0,0,-1)
    end
    printHelpString("Playing animation")
    if file ~= "ped" then
        removeAnimation(animation)
    end
end

function CreateButtons(names,func)

    local X = imgui.GetWindowWidth()/3 - 7*imgui.StyleVar.WindowPadding
    for i=1,3,1 do
        
        if i == tmain.current_btn then
            imgui.GetStyle().Colors[imgui.Col.Button] = imgui.ImVec4(0.06,  0.53,  0.98,  1.00)
        end

        if imgui.Button(names[i],imgui.ImVec2(X,25)) then
            tmain.current_btn = i
        end

        imgui.GetStyle().Colors[imgui.Col.Button] = imgui.ImVec4(0.26,  0.59,  0.98,  0.40)

        if i%3 ~= 0 then
            imgui.SameLine(0.0,0.0)
        end

    end
    imgui.NewLine()

    imgui.Spacing()
    imgui.Columns(2,nil,false)
    imgui.Checkbox("Loop", tmain.loop)
    imgui.NextColumn()
    imgui.Checkbox("Secondary", tmain.secondary)
    imgui.Columns(1)
    imgui.Spacing()
    if imgui.Button("Stop animation",imgui.ImVec2(imgui.GetWindowWidth()-20,25)) then
        clearCharTasks(PLAYER_PED)
        printHelpString("Animation stopped")
    end
    imgui.Spacing()
    imgui.Separator()
    func[tmain.current_btn]()

end

function main()
    ApplyStyle()

    while true do
        if isKeyDown(keys.menu_key1) and isKeyDown(keys.menu_key2) then
            while isKeyDown(keys.menu_key1) and isKeyDown(keys.menu_key2) do
                wait(0)
            end
            tmain.window.v = not tmain.window.v
        end

        imgui.Process = tmain.window.v
        wait(0)
    end
end

function ApplyStyle()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4

    style.WindowRounding = 2.0
    style.WindowTitleAlign = imgui.ImVec2(0.5,  0.84)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 0.0
    style.ItemSpacing = imgui.ImVec2(3.0,  3.0)
    style.ScrollbarSize = 12.0
    style.ScrollbarRounding = 2.0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0
    style.WindowPadding = imgui.ImVec2(10.0,  10.0)
    colors[clr.Text]                   = ImVec4(1.00,  1.00,  1.00,  1.00)
    colors[clr.TextDisabled]           = ImVec4(0.50,  0.50,  0.50,  1.00)
    colors[clr.WindowBg]               = ImVec4(0.06,  0.06,  0.06,  0.94)
    colors[clr.ChildWindowBg]          = ImVec4(1.00,  1.00,  1.00,  0.00)
    colors[clr.PopupBg]                = ImVec4(0.08,  0.08,  0.08,  0.94)
    colors[clr.ComboBg]                = colors[clr.PopupBg]
    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.16,  0.29,  0.48,  0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.26,  0.59,  0.98,  0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.26,  0.59,  0.98,  0.67)
    colors[clr.TitleBg]                = ImVec4(0.04,  0.04,  0.04,  1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.16,  0.29,  0.48,  1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00,  0.00,  0.00,  0.51)
    colors[clr.MenuBarBg]              = ImVec4(0.14,  0.14,  0.14,  1.00)
    colors[clr.ScrollbarBg]            = ImVec4(0.02,  0.02,  0.02,  0.53)
    colors[clr.ScrollbarGrab]          = ImVec4(0.31,  0.31,  0.31,  1.00)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.41,  0.41,  0.41,  1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.51,  0.51,  0.51,  1.00)
    colors[clr.CheckMark]              = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.SliderGrab]             = ImVec4(0.24,  0.52,  0.88,  1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.Button]                 = ImVec4(0.26,  0.59,  0.98,  0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.ButtonActive]           = ImVec4(0.06,  0.53,  0.98,  1.00)
    colors[clr.Header]                 = ImVec4(0.26,  0.59,  0.98,  0.00)
    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.Separator]              = colors[clr.Border]
    colors[clr.SeparatorHovered]       = ImVec4(0.26,  0.59,  0.98,  0.78)
    colors[clr.SeparatorActive]        = 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.26,  0.59,  0.98,  0.95)
    colors[clr.CloseButton]            = ImVec4(0.41,  0.41,  0.41,  0.50)
    colors[clr.CloseButtonHovered]     = ImVec4(0.98,  0.39,  0.36,  1.00)
    colors[clr.CloseButtonActive]      = ImVec4(0.98,  0.39,  0.36,  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.26,  0.59,  0.98,  0.35)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.80,  0.80,  0.80,  0.35)
end
 
Решение
Код:
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
  
    ApplyStyle()
 
    sampRegisterChatCommand('test111', function()
        tmain.window.v = not tmain.window.v
    end)
 
    imgui.Process = false
    tmain.window.v = false
 
    while true do  wait(0)
        imgui.Process = tmain.window.v
    end
end

script_name("Animation Manager")
script_author("Grinch_")
script_description("Animation manager for GTA San Andreas")
script_dependencies("imgui")
script_version("1.0")

-- Script Dependencies
local imgui       = require 'imgui'

local tmain =
{
    window         = imgui.ImBool(false),
    current_btn    = 1,
    loop           =...

arpix

Активный
119
32
лучше function main ставь перед имгуи

Lua:
-- из твоего кода

function main()
    ApplyStyle()
  
    sampRegisterChatCommand('test', function() -- тут меняй команду
        tmain.window.v = not tmain.window.v
    end)
  
    imgui.Process = false
    tmain.window.v = false
  
    while true do  wait(0)
        imgui.Process = tmain.window.v
    end
end
 

Sirccet

Участник
Автор темы
142
21
лучше function main ставь перед имгуи

Lua:
-- из твоего кода

function main()
    ApplyStyle()
 
    sampRegisterChatCommand('test', function() -- тут меняй команду
        tmain.window.v = not tmain.window.v
    end)
 
    imgui.Process = false
    tmain.window.v = false
 
    while true do  wait(0)
        imgui.Process = tmain.window.v
    end
end
Понял Сейчас проверю
 
  • Нравится
Реакции: arpix

arpix

Активный
119
32
А куда мне его вставлять. В самое начало?
У тебя в коде есть function main(), это тоже самое, ставь перед имгуи, желательно как первую функцию но после переменных итд

Вот к примеру скрипт. Я хочу не сочетание клавиш, а командой в чат.
Код:
script_name("Animation Manager")
script_author("Grinch_")
script_description("Animation manager for GTA San Andreas")
script_dependencies("imgui")
script_version("1.0")

--Keys
local keys =
{
    menu_key1        = 0xA4,  -- Left Alt
    menu_key2         = 0x6B,  -- Numpad +
}

-- Script Dependencies
local imgui       = require 'imgui'

local tmain =
{
    window         = imgui.ImBool(false),
    current_btn    = 1,
    loop           = imgui.ImBool(false),
    secondary      = imgui.ImBool(false),
    search_text    = imgui.ImBuffer(24),
    ifp_name       = imgui.ImBuffer(24),
    animation_name = imgui.ImBuffer(24),
}


local animations = {
    "AIRPORT$thrw_barl_thrw",
    "ATTRACTORS$Stepsit_in",
    "ATTRACTORS$Stepsit_loop",
    "ATTRACTORS$Stepsit_out",
    "BAR$Barcustom_get",
    "BAR$Barcustom_loop",
    "BAR$Barcustom_order",
    "BAR$BARman_idle",
    "BAR$Barserve_bottle",
    "BAR$Barserve_give",
    "BAR$Barserve_glass",
    "BAR$Barserve_in",
    "BAR$Barserve_loop",
    "BAR$Barserve_order",
    "BAR$dnk_stndF_loop",
    "BAR$dnk_stndM_loop",
    "BASEBALL$Bat_1",
    "BASEBALL$Bat_2",
    "BASEBALL$Bat_3",
    "BASEBALL$Bat_4",
    "BASEBALL$Bat_block",
    "BASEBALL$Bat_Hit_1",
    "BASEBALL$Bat_Hit_2",
    "BASEBALL$Bat_Hit_3",
    "BASEBALL$Bat_IDLE",
    "BASEBALL$Bat_M",
    "BASEBALL$BAT_PART",
    "BD_FIRE$BD_Fire1",
    "BD_FIRE$BD_Fire2",
    "BD_FIRE$BD_Fire3",
    "BD_FIRE$BD_GF_Wave",
    "BD_FIRE$BD_Panic_01",
    "BD_FIRE$BD_Panic_02",
    "BD_FIRE$BD_Panic_03",
    "BD_FIRE$BD_Panic_04",
    "BD_FIRE$BD_Panic_Loop",
    "BD_FIRE$Grlfrd_Kiss_03",
    "BD_FIRE$M_smklean_loop",
    "BD_FIRE$Playa_Kiss_03",
    "BD_FIRE$wash_up",
    "BEACH$bather",
    "BEACH$Lay_Bac_Loop",
    "BEACH$ParkSit_M_loop",
    "BEACH$ParkSit_W_loop",
    "BEACH$SitnWait_loop_W",
    "BENCHPRESS$gym_bp_celebrate",
    "BENCHPRESS$gym_bp_down",
    "BENCHPRESS$gym_bp_getoff",
    "BENCHPRESS$gym_bp_geton",
    "BENCHPRESS$gym_bp_up_A",
    "BENCHPRESS$gym_bp_up_B",
    "BENCHPRESS$gym_bp_up_smooth",
    "BF_INJECTION$BF_getin_LHS",
    "BF_INJECTION$BF_getin_RHS",
    "BF_INJECTION$BF_getout_LHS",
    "BF_INJECTION$BF_getout_RHS",
    "BIKED$BIKEd_Back",
    "BIKED$BIKEd_drivebyFT",
    "BIKED$BIKEd_drivebyLHS",
    "BIKED$BIKEd_drivebyRHS",
    "BIKED$BIKEd_Fwd",
    "BIKED$BIKEd_getoffBACK",
    "BIKED$BIKEd_getoffLHS",
    "BIKED$BIKEd_getoffRHS",
    "BIKED$BIKEd_hit",
    "BIKED$BIKEd_jumponL",
    "BIKED$BIKEd_jumponR",
    "BIKED$BIKEd_kick",
    "BIKED$BIKEd_Left",
    "BIKED$BIKEd_passenger",
    "BIKED$BIKEd_pushes",
    "POOL$POOL_Walk_Start",
    "POOL$POOL_XLong_Shot",
    "POOL$POOL_XLong_Shot_O",
    "POOL$POOL_XLong_Start",
    "POOL$POOL_XLong_Start_O",
    "POOR$WINWASH_Start",
    "POOR$WINWASH_Wash2Beg",
    "PYTHON$python_crouchfire",
    "PYTHON$python_crouchreload",
    "PYTHON$python_fire",
    "PYTHON$python_fire_poor",
    "PYTHON$python_reload",
    "QUAD$QUAD_back",
    "QUAD$QUAD_driveby_FT",
    "QUAD$QUAD_driveby_LHS",
    "QUAD$QUAD_driveby_RHS",
    "QUAD$QUAD_FWD",
    "QUAD$QUAD_getoff_B",
    "QUAD$QUAD_getoff_LHS",
    "QUAD$QUAD_getoff_RHS",
    "QUAD$QUAD_geton_LHS",
    "QUAD$QUAD_geton_RHS",
    "QUAD$QUAD_hit",
    "QUAD$QUAD_kick",
    "QUAD$QUAD_Left",
    "QUAD$QUAD_passenger",
    "QUAD$QUAD_reverse",
    "QUAD$QUAD_ride",
    "QUAD$QUAD_Right",
    "QUAD_DBZ$Pass_Driveby_BWD",
    "QUAD_DBZ$Pass_Driveby_FWD",
    "QUAD_DBZ$Pass_Driveby_LHS",
    "QUAD_DBZ$Pass_Driveby_RHS",
    "RAPPING$Laugh_01",
    "RAPPING$RAP_A_IN",
    "RAPPING$RAP_A_Loop",
    "RAPPING$RAP_A_OUT",
    "RAPPING$RAP_B_IN",
    "RAPPING$RAP_B_Loop",
    "RAPPING$RAP_B_OUT",
    "RAPPING$RAP_C_Loop",
    "RIFLE$RIFLE_crouchfire",
    "RIFLE$RIFLE_crouchload",
    "RIFLE$RIFLE_fire",
    "RIFLE$RIFLE_fire_poor",
    "RIFLE$RIFLE_load",
    "RIOT$RIOT_ANGRY",
    "RIOT$RIOT_ANGRY_B",
    "RIOT$RIOT_challenge",
    "RIOT$RIOT_CHANT",
    "RIOT$RIOT_FUKU",
    "RIOT$RIOT_PUNCHES",
    "RIOT$RIOT_shout",
    "ROB_BANK$CAT_Safe_End",
    "ROB_BANK$CAT_Safe_Open",
    "ROB_BANK$CAT_Safe_Open_O",
    "ROB_BANK$CAT_Safe_Rob",
    "ROB_BANK$SHP_HandsUp_Scr",
    "ROCKET$idle_rocket",
    "ROCKET$RocketFire",
    "ROCKET$run_rocket",
    "ROCKET$walk_rocket",
    "ROCKET$WALK_start_rocket",
    "RUSTLER$Plane_align_LHS",
    "RUSTLER$Plane_close",
    "RUSTLER$Plane_getin",
    "RUSTLER$Plane_getout",
    "RUSTLER$Plane_open",
    "RYDER$RYD_Beckon_01",
    "RYDER$RYD_Beckon_02",
    "RYDER$RYD_Beckon_03",
    "RYDER$RYD_Die_PT1",
    "RYDER$RYD_Die_PT2",
    "RYDER$Van_Crate_L",
    "RYDER$Van_Crate_R",
    "RYDER$Van_Fall_L",
    "RYDER$Van_Fall_R",
    "RYDER$Van_Lean_L",
    "RYDER$Van_Lean_R",
    "RYDER$VAN_PickUp_E",
    "RYDER$VAN_PickUp_S",
    "RYDER$Van_Stand",
    "RYDER$Van_Stand_Crate",
    "RYDER$Van_Throw",
    "SCRATCHING$scdldlp",
    "SCRATCHING$scdlulp",
    "SCRATCHING$scdrdlp",
    "SCRATCHING$scdrulp",
    "SCRATCHING$sclng_l",
    "SCRATCHING$sclng_r",
    "SCRATCHING$scmid_l",
    "SCRATCHING$scmid_r",
    "SCRATCHING$scshrtl",
    "SCRATCHING$scshrtr",
    "SCRATCHING$sc_ltor",
    "SCRATCHING$sc_rtol",
    "SHAMAL$SHAMAL_align",
    "SHAMAL$SHAMAL_getin_LHS",
    "SHAMAL$SHAMAL_getout_LHS",
    "SHAMAL$SHAMAL_open",
    "SHOP$ROB_2Idle",
    "SHOP$ROB_Loop",
    "SHOP$ROB_Loop_Threat",
    "SHOP$ROB_Shifty",
    "SHOP$ROB_StickUp_In",
    "SHOP$SHP_Duck",
    "SHOP$SHP_Duck_Aim",
    "SHOP$SHP_Duck_Fire",
    "SHOP$SHP_Gun_Aim",
    "SHOP$SHP_Gun_Duck",
    "SHOP$SHP_Gun_Fire",
    "SHOP$SHP_Gun_Grab",
    "SHOP$SHP_Gun_Threat",
    "SHOP$SHP_HandsUp_Scr",
    "SHOP$SHP_Jump_Glide",
    "SHOP$SHP_Jump_Land",
    "SHOP$SHP_Jump_Launch",
    "SHOP$SHP_Rob_GiveCash",
    "SHOP$SHP_Rob_HandsUp",
    "SHOP$SHP_Rob_React",
    "SHOP$SHP_Serve_End",
    "SHOP$SHP_Serve_Idle",
    "SHOP$SHP_Serve_Loop",
    "SHOP$SHP_Serve_Start",
    "SHOP$Smoke_RYD",
    "SHOTGUN$shotgun_crouchfire",
    "SHOTGUN$shotgun_fire",
    "SHOTGUN$shotgun_fire_poor",
    "SILENCED$CrouchReload",
    "SILENCED$SilenceCrouchfire",
    "SILENCED$Silence_fire",
    "SILENCED$Silence_reload",
    "SKATE$skate_idle",
    "SKATE$skate_run",
    "SKATE$skate_sprint",
    "SMOKING$F_smklean_loop",
    "SMOKING$M_smklean_loop",
    "SMOKING$M_smkstnd_loop",
    "SMOKING$M_smk_drag",
    "SMOKING$M_smk_in",
    "SMOKING$M_smk_loop",
    "SMOKING$M_smk_out",
    "SMOKING$M_smk_tap",
    "SNIPER$WEAPON_sniper",
    "SPRAYCAN$spraycan_fire",
    "SPRAYCAN$spraycan_full",
    "STRIP$PLY_CASH",
    "STRIP$PUN_CASH",
    "WEAPONS$SHP_2H_Lift",
    "WEAPONS$SHP_2H_Lift_End",
    "WEAPONS$SHP_2H_Ret",
    "WEAPONS$SHP_2H_Ret_S",
    "WEAPONS$SHP_Ar_Lift",
    "WEAPONS$SHP_Ar_Lift_End",
    "WEAPONS$SHP_Ar_Ret",
    "WEAPONS$SHP_Ar_Ret_S",
    "WEAPONS$SHP_G_Lift_In",
    "WEAPONS$SHP_G_Lift_Out",
    "WEAPONS$SHP_Tray_In",
    "WEAPONS$SHP_Tray_Out",
    "WEAPONS$SHP_Tray_Pose",
    "WUZI$CS_Dead_Guy",
    "WUZI$CS_Plyr_pt1",
    "WUZI$CS_Plyr_pt2",
    "WUZI$CS_Wuzi_pt1",
    "WUZI$CS_Wuzi_pt2",
    "WUZI$Walkstart_Idle_01",
    "WUZI$Wuzi_follow",
    "WUZI$Wuzi_Greet_Plyr",
    "WUZI$Wuzi_Greet_Wuzi",
    "WUZI$Wuzi_grnd_chk",
    "WUZI$Wuzi_stand_loop",
    "WUZI$Wuzi_Walk",
}

function imgui.OnDrawFrame()
    if  tmain.window.v then

        imgui.SetNextWindowSize(imgui.ImVec2(350, 600),  imgui.Cond.FirstUseEver)

        imgui.Begin(string.format( '%s v%s by Grinch_',script.this.name,script.this.version),tmain.window,imgui.WindowFlags.NoCollapse)
    
        CreateButtons({"List","Search","Custom"},{List,Search,Custom})

        imgui.End()
    end
end

function List()
    imgui.Spacing()
    local menu_name = ""
    if imgui.BeginChild("") then
        for key,value in ipairs(animations) do
            local temp,_ = value:match("([^$]+)$([^$]+)")
            if menu_name ~= temp then
                menu_name = temp

                if imgui.CollapsingHeader(menu_name) then
                    imgui.Spacing()
                    for key,value in pairs(animations) do
                        local file,animation = value:match("([^$]+)$([^$]+)")
                        if menu_name == file then
                            AnimationEntry(file,animation)
                        end
                    end
                    imgui.Spacing()
                    imgui.Separator()
                    imgui.Spacing()
                end
            end
        end
        imgui.EndChild()
    end

end

function Search()
    imgui.Dummy(imgui.ImVec2(0,10))

    imgui.PushItemWidth(imgui.GetWindowWidth()-100)
    imgui.InputText("Search ",tmain.search_text)
    imgui.PopItemWidth()

    imgui.Spacing()
    imgui.Text("Found entries :(" .. tmain.search_text.v .. ")")
    imgui.Separator()
    imgui.Spacing()
    if imgui.BeginChild("") then
        for key,value in pairs(animations) do
            file, animation = value:match("([^$]+)$([^$]+)")
            if (string.upper(animation):find(string.upper(tmain.search_text.v))) then
                AnimationEntry(file,animation)
            end
        end   
        imgui.Spacing()
        imgui.EndChild()
    end
end

function Custom()

    imgui.Dummy(imgui.ImVec2(0,10))
 
    imgui.InputText("IFP name",tmain.ifp_name)
    imgui.InputText("Animation name",tmain.animation_name)
    imgui.Spacing()
    if imgui.Button("Play animation",imgui.ImVec2(imgui.GetWindowWidth()-20,25)) then
        PlayAnimation(tmain.ifp_name.v,tmain.animation_name.v)
    end
end


function AnimationEntry(file,animation)
    if imgui.MenuItem(animation) then
        if file ~= "PED" then
            requestAnimation(file)
            loadAllModelsNow()
        end
        PlayAnimation(file,animation)
    end
end

function PlayAnimation(file,animation)
    if tmain.secondary.v == true then
        taskPlayAnimSecondary(PLAYER_PED,animation,file,4.0,tmain.loop.v,0,0,0,-1)
    else
        taskPlayAnim(PLAYER_PED,animation,file,4.0,tmain.loop.v,0,0,0,-1)
    end
    printHelpString("Playing animation")
    if file ~= "ped" then
        removeAnimation(animation)
    end
end

function CreateButtons(names,func)

    local X = imgui.GetWindowWidth()/3 - 7*imgui.StyleVar.WindowPadding
    for i=1,3,1 do
    
        if i == tmain.current_btn then
            imgui.GetStyle().Colors[imgui.Col.Button] = imgui.ImVec4(0.06,  0.53,  0.98,  1.00)
        end

        if imgui.Button(names[i],imgui.ImVec2(X,25)) then
            tmain.current_btn = i
        end

        imgui.GetStyle().Colors[imgui.Col.Button] = imgui.ImVec4(0.26,  0.59,  0.98,  0.40)

        if i%3 ~= 0 then
            imgui.SameLine(0.0,0.0)
        end

    end
    imgui.NewLine()

    imgui.Spacing()
    imgui.Columns(2,nil,false)
    imgui.Checkbox("Loop", tmain.loop)
    imgui.NextColumn()
    imgui.Checkbox("Secondary", tmain.secondary)
    imgui.Columns(1)
    imgui.Spacing()
    if imgui.Button("Stop animation",imgui.ImVec2(imgui.GetWindowWidth()-20,25)) then
        clearCharTasks(PLAYER_PED)
        printHelpString("Animation stopped")
    end
    imgui.Spacing()
    imgui.Separator()
    func[tmain.current_btn]()

end

function main()
    ApplyStyle()

    while true do
        if isKeyDown(keys.menu_key1) and isKeyDown(keys.menu_key2) then
            while isKeyDown(keys.menu_key1) and isKeyDown(keys.menu_key2) do
                wait(0)
            end
            tmain.window.v = not tmain.window.v
        end

        imgui.Process = tmain.window.v
        wait(0)
    end
end

function ApplyStyle()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4

    style.WindowRounding = 2.0
    style.WindowTitleAlign = imgui.ImVec2(0.5,  0.84)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 0.0
    style.ItemSpacing = imgui.ImVec2(3.0,  3.0)
    style.ScrollbarSize = 12.0
    style.ScrollbarRounding = 2.0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0
    style.WindowPadding = imgui.ImVec2(10.0,  10.0)
    colors[clr.Text]                   = ImVec4(1.00,  1.00,  1.00,  1.00)
    colors[clr.TextDisabled]           = ImVec4(0.50,  0.50,  0.50,  1.00)
    colors[clr.WindowBg]               = ImVec4(0.06,  0.06,  0.06,  0.94)
    colors[clr.ChildWindowBg]          = ImVec4(1.00,  1.00,  1.00,  0.00)
    colors[clr.PopupBg]                = ImVec4(0.08,  0.08,  0.08,  0.94)
    colors[clr.ComboBg]                = colors[clr.PopupBg]
    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.16,  0.29,  0.48,  0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.26,  0.59,  0.98,  0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.26,  0.59,  0.98,  0.67)
    colors[clr.TitleBg]                = ImVec4(0.04,  0.04,  0.04,  1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.16,  0.29,  0.48,  1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00,  0.00,  0.00,  0.51)
    colors[clr.MenuBarBg]              = ImVec4(0.14,  0.14,  0.14,  1.00)
    colors[clr.ScrollbarBg]            = ImVec4(0.02,  0.02,  0.02,  0.53)
    colors[clr.ScrollbarGrab]          = ImVec4(0.31,  0.31,  0.31,  1.00)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.41,  0.41,  0.41,  1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.51,  0.51,  0.51,  1.00)
    colors[clr.CheckMark]              = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.SliderGrab]             = ImVec4(0.24,  0.52,  0.88,  1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.Button]                 = ImVec4(0.26,  0.59,  0.98,  0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.ButtonActive]           = ImVec4(0.06,  0.53,  0.98,  1.00)
    colors[clr.Header]                 = ImVec4(0.26,  0.59,  0.98,  0.00)
    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.Separator]              = colors[clr.Border]
    colors[clr.SeparatorHovered]       = ImVec4(0.26,  0.59,  0.98,  0.78)
    colors[clr.SeparatorActive]        = 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.26,  0.59,  0.98,  0.95)
    colors[clr.CloseButton]            = ImVec4(0.41,  0.41,  0.41,  0.50)
    colors[clr.CloseButtonHovered]     = ImVec4(0.98,  0.39,  0.36,  1.00)
    colors[clr.CloseButtonActive]      = ImVec4(0.98,  0.39,  0.36,  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.26,  0.59,  0.98,  0.35)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.80,  0.80,  0.80,  0.35)
end
ещё я увидел в твоей function main что ты используешь активацию по кнопке через переменный, в которых уже указываешь виртуальную клавишу, ты можешь сразу в isKeyDown итд указывать виртуальну клавишу

Lua:
-- пример
isKeyDown(VK_TAB)
виртуальные коды клавиш: https://api.farmanager.com/ru/winapi/virtualkeycodes.html
 

Sirccet

Участник
Автор темы
142
21
function main()
ApplyStyle()

sampRegisterChatCommand('test', function(test12) -- тут меняй команду
tmain.window.v = not tmain.window.v
end)

imgui.Process = false
tmain.window.v = false

while true do wait(0)
imgui.Process = tmain.window.v
end
end

Я надеюсь всё правильно делаю? Команда /test12
Код:
function main()

    ApplyStyle()

 

    sampRegisterChatCommand('test', function(test12) -- тут меняй команду

        tmain.window.v = not tmain.window.v

    end)

 

    imgui.Process = false

    tmain.window.v = false

 

    while true do  wait(0)

        imgui.Process = tmain.window.v

    end

end
Я надесю всё правильно сделал? Команда /test12
 

arpix

Активный
119
32
function main() ApplyStyle() sampRegisterChatCommand('test', function(test12) -- тут меняй команду tmain.window.v = not tmain.window.v end) imgui.Process = false tmain.window.v = false while true do wait(0) imgui.Process = tmain.window.v end end
Я надеюсь всё правильно делаю? Команда /test12
ну близко)) команду указывай в
а точнее в "" или ''

пример:
Lua:
    sampRegisterChatCommand('test', function() -- тут меняй команду
        tmain.window.v = not tmain.window.v
    end)
    
    -- или
    
    sampRegisterChatCommand('test12', function() -- тут меняй команду
        tmain.window.v = not tmain.window.v
    end)
 

Sirccet

Участник
Автор темы
142
21
Код:
-- из твоего кода

function main()
    ApplyStyle()
 
    sampRegisterChatCommand('aaa11', function() -- тут меняй команду
        tmain.window.v = not tmain.window.v
    end)
 
    imgui.Process = false
    tmain.window.v = false
 
    while true do  wait(0)
        imgui.Process = tmain.window.v
    end
end

script_name("Animation Manager")
script_author("Grinch_")
script_description("Animation manager for GTA San Andreas")
script_dependencies("imgui")
script_version("1.0")

--Keys
local keys =
{
    menu_key1        = 0xA4,  -- Left Alt
    menu_key2         = 0x6B,  -- Numpad +
}

-- Script Dependencies
local imgui       = require 'imgui'

local tmain =
{
    window         = imgui.ImBool(false),
    current_btn    = 1,
    loop           = imgui.ImBool(false),
    secondary      = imgui.ImBool(false),
    search_text    = imgui.ImBuffer(24),
    ifp_name       = imgui.ImBuffer(24),
    animation_name = imgui.ImBuffer(24),
}


local animations = {
    "AIRPORT$thrw_barl_thrw",
    "ATTRACTORS$Stepsit_in",
    "ATTRACTORS$Stepsit_loop",
    "ATTRACTORS$Stepsit_out",
    "BAR$Barcustom_get",
    "BAR$Barcustom_loop",
    "BAR$Barcustom_order",
    "BAR$BARman_idle",
    "BAR$Barserve_bottle",
    "BAR$Barserve_give",
    "BAR$Barserve_glass",
    "BAR$Barserve_in",
    "BAR$Barserve_loop",
    "BAR$Barserve_order",
    "BAR$dnk_stndF_loop",
    "BAR$dnk_stndM_loop",
    "BASEBALL$Bat_1",
    "BASEBALL$Bat_2",
    "BASEBALL$Bat_3",
    "BASEBALL$Bat_4",
    "BASEBALL$Bat_block",
    "BASEBALL$Bat_Hit_1",
    "BASEBALL$Bat_Hit_2",
    "BASEBALL$Bat_Hit_3",
    "BASEBALL$Bat_IDLE",
    "BASEBALL$Bat_M",
    "BASEBALL$BAT_PART",
    "BD_FIRE$BD_Fire1",
    "BD_FIRE$BD_Fire2",
    "BD_FIRE$BD_Fire3",
    "BD_FIRE$BD_GF_Wave",
    "BD_FIRE$BD_Panic_01",
    "BD_FIRE$BD_Panic_02",
    "BD_FIRE$BD_Panic_03",
    "BD_FIRE$BD_Panic_04",
    "BD_FIRE$BD_Panic_Loop",
    "BD_FIRE$Grlfrd_Kiss_03",
    "BD_FIRE$M_smklean_loop",
    "BD_FIRE$Playa_Kiss_03",
    "BD_FIRE$wash_up",
    "BEACH$bather",
    "BEACH$Lay_Bac_Loop",
    "BEACH$ParkSit_M_loop",
    "BEACH$ParkSit_W_loop",
    "BEACH$SitnWait_loop_W",
    "BENCHPRESS$gym_bp_celebrate",
    "BENCHPRESS$gym_bp_down",
    "BENCHPRESS$gym_bp_getoff",
    "BENCHPRESS$gym_bp_geton",
    "BENCHPRESS$gym_bp_up_A",
    "BENCHPRESS$gym_bp_up_B",
    "BENCHPRESS$gym_bp_up_smooth",
    "BF_INJECTION$BF_getin_LHS",
    "BF_INJECTION$BF_getin_RHS",
    "BF_INJECTION$BF_getout_LHS",
    "BF_INJECTION$BF_getout_RHS",
    "BIKED$BIKEd_Back",
    "BIKED$BIKEd_drivebyFT",
    "BIKED$BIKEd_drivebyLHS",
    "BIKED$BIKEd_drivebyRHS",
    "BIKED$BIKEd_Fwd",
    "BIKED$BIKEd_getoffBACK",
    "BIKED$BIKEd_getoffLHS",
    "BIKED$BIKEd_getoffRHS",
    "BIKED$BIKEd_hit",
    "BIKED$BIKEd_jumponL",
    "BIKED$BIKEd_jumponR",
    "BIKED$BIKEd_kick",
    "BIKED$BIKEd_Left",
    "BIKED$BIKEd_passenger",
    "BIKED$BIKEd_pushes",
    "BIKED$BIKEd_Ride",
    "BIKED$BIKEd_Right",
    "BIKED$BIKEd_shuffle",
    "BIKED$BIKEd_Still",
    "BIKEH$BIKEh_Back",
    "BIKEH$BIKEh_drivebyFT",
    "BIKEH$BIKEh_drivebyLHS",
    "BIKEH$BIKEh_drivebyRHS",
    "BIKEH$BIKEh_Fwd",
    "BIKEH$BIKEh_getoffBACK",
    "BIKEH$BIKEh_getoffLHS",
    "BIKEH$BIKEh_getoffRHS",
    "BIKEH$BIKEh_hit",
    "BIKEH$BIKEh_jumponL",
    "BIKEH$BIKEh_jumponR",
    "BIKEH$BIKEh_kick",
    "BIKEH$BIKEh_Left",
    "BIKEH$BIKEh_passenger",
    "BIKEH$BIKEh_pushes",
    "BIKEH$BIKEh_Ride",
    "BIKEH$BIKEh_Right",
    "BIKEH$BIKEh_Still",
    "BIKELEAP$bk_blnce_in",
    "WEAPONS$SHP_2H_Lift",
    "WEAPONS$SHP_2H_Lift_End",
    "WEAPONS$SHP_2H_Ret",
    "WEAPONS$SHP_2H_Ret_S",
    "WEAPONS$SHP_Ar_Lift",
    "WEAPONS$SHP_Ar_Lift_End",
    "WEAPONS$SHP_Ar_Ret",
    "WEAPONS$SHP_Ar_Ret_S",
    "WEAPONS$SHP_G_Lift_In",
    "WEAPONS$SHP_G_Lift_Out",
    "WEAPONS$SHP_Tray_In",
    "WEAPONS$SHP_Tray_Out",
    "WEAPONS$SHP_Tray_Pose",
    "WUZI$CS_Dead_Guy",
    "WUZI$CS_Plyr_pt1",
    "WUZI$CS_Plyr_pt2",
    "WUZI$CS_Wuzi_pt1",
    "WUZI$CS_Wuzi_pt2",
    "WUZI$Walkstart_Idle_01",
    "WUZI$Wuzi_follow",
    "WUZI$Wuzi_Greet_Plyr",
    "WUZI$Wuzi_Greet_Wuzi",
    "WUZI$Wuzi_grnd_chk",
    "WUZI$Wuzi_stand_loop",
    "WUZI$Wuzi_Walk",
}

function imgui.OnDrawFrame()
    if  tmain.window.v then

        imgui.SetNextWindowSize(imgui.ImVec2(350, 600),  imgui.Cond.FirstUseEver)

        imgui.Begin(string.format( '%s v%s by Grinch_',script.this.name,script.this.version),tmain.window,imgui.WindowFlags.NoCollapse)
        
        CreateButtons({"List","Search","Custom"},{List,Search,Custom})

        imgui.End()
    end
end

function List()
    imgui.Spacing()
    local menu_name = ""
    if imgui.BeginChild("") then
        for key,value in ipairs(animations) do
            local temp,_ = value:match("([^$]+)$([^$]+)")
            if menu_name ~= temp then
                menu_name = temp

                if imgui.CollapsingHeader(menu_name) then
                    imgui.Spacing()
                    for key,value in pairs(animations) do
                        local file,animation = value:match("([^$]+)$([^$]+)")
                        if menu_name == file then
                            AnimationEntry(file,animation)
                        end
                    end
                    imgui.Spacing()
                    imgui.Separator()
                    imgui.Spacing()
                end
            end
        end 
        imgui.EndChild()
    end

end

function Search()
    imgui.Dummy(imgui.ImVec2(0,10))

    imgui.PushItemWidth(imgui.GetWindowWidth()-100)
    imgui.InputText("Search ",tmain.search_text)
    imgui.PopItemWidth()

    imgui.Spacing()
    imgui.Text("Found entries :(" .. tmain.search_text.v .. ")")
    imgui.Separator()
    imgui.Spacing()
    if imgui.BeginChild("") then
        for key,value in pairs(animations) do
            file, animation = value:match("([^$]+)$([^$]+)")
            if (string.upper(animation):find(string.upper(tmain.search_text.v))) then
                AnimationEntry(file,animation)
            end
        end       
        imgui.Spacing()
        imgui.EndChild()
    end
end

function Custom()

    imgui.Dummy(imgui.ImVec2(0,10))
    
    imgui.InputText("IFP name",tmain.ifp_name)
    imgui.InputText("Animation name",tmain.animation_name)
    imgui.Spacing()
    if imgui.Button("Play animation",imgui.ImVec2(imgui.GetWindowWidth()-20,25)) then
        PlayAnimation(tmain.ifp_name.v,tmain.animation_name.v)
    end
end


function AnimationEntry(file,animation)
    if imgui.MenuItem(animation) then
        if file ~= "PED" then
            requestAnimation(file)
            loadAllModelsNow()
        end
        PlayAnimation(file,animation)
    end
end

function PlayAnimation(file,animation)
    if tmain.secondary.v == true then
        taskPlayAnimSecondary(PLAYER_PED,animation,file,4.0,tmain.loop.v,0,0,0,-1) 
    else
        taskPlayAnim(PLAYER_PED,animation,file,4.0,tmain.loop.v,0,0,0,-1)
    end
    printHelpString("Playing animation")
    if file ~= "ped" then
        removeAnimation(animation)
    end
end

function CreateButtons(names,func)

    local X = imgui.GetWindowWidth()/3 - 7*imgui.StyleVar.WindowPadding
    for i=1,3,1 do
        
        if i == tmain.current_btn then
            imgui.GetStyle().Colors[imgui.Col.Button] = imgui.ImVec4(0.06,  0.53,  0.98,  1.00)
        end

        if imgui.Button(names[i],imgui.ImVec2(X,25)) then
            tmain.current_btn = i
        end

        imgui.GetStyle().Colors[imgui.Col.Button] = imgui.ImVec4(0.26,  0.59,  0.98,  0.40)

        if i%3 ~= 0 then
            imgui.SameLine(0.0,0.0)
        end

    end
    imgui.NewLine()

    imgui.Spacing()
    imgui.Columns(2,nil,false)
    imgui.Checkbox("Loop", tmain.loop)
    imgui.NextColumn()
    imgui.Checkbox("Secondary", tmain.secondary)
    imgui.Columns(1)
    imgui.Spacing()
    if imgui.Button("Stop animation",imgui.ImVec2(imgui.GetWindowWidth()-20,25)) then
        clearCharTasks(PLAYER_PED)
        printHelpString("Animation stopped")
    end
    imgui.Spacing()
    imgui.Separator()
    func[tmain.current_btn]()

end

function main()
    ApplyStyle()

    while true do
        if isKeyDown(keys.menu_key1) and isKeyDown(keys.menu_key2) then
            while isKeyDown(keys.menu_key1) and isKeyDown(keys.menu_key2) do
                wait(0)
            end
            tmain.window.v = not tmain.window.v
        end

        imgui.Process = tmain.window.v
        wait(0)
    end
end

function ApplyStyle()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4

    style.WindowRounding = 2.0
    style.WindowTitleAlign = imgui.ImVec2(0.5,  0.84)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 0.0
    style.ItemSpacing = imgui.ImVec2(3.0,  3.0)
    style.ScrollbarSize = 12.0
    style.ScrollbarRounding = 2.0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0
    style.WindowPadding = imgui.ImVec2(10.0,  10.0)
    colors[clr.Text]                   = ImVec4(1.00,  1.00,  1.00,  1.00)
    colors[clr.TextDisabled]           = ImVec4(0.50,  0.50,  0.50,  1.00)
    colors[clr.WindowBg]               = ImVec4(0.06,  0.06,  0.06,  0.94)
    colors[clr.ChildWindowBg]          = ImVec4(1.00,  1.00,  1.00,  0.00)
    colors[clr.PopupBg]                = ImVec4(0.08,  0.08,  0.08,  0.94)
    colors[clr.ComboBg]                = colors[clr.PopupBg]
    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.16,  0.29,  0.48,  0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.26,  0.59,  0.98,  0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.26,  0.59,  0.98,  0.67)
    colors[clr.TitleBg]                = ImVec4(0.04,  0.04,  0.04,  1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.16,  0.29,  0.48,  1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00,  0.00,  0.00,  0.51)
    colors[clr.MenuBarBg]              = ImVec4(0.14,  0.14,  0.14,  1.00)
    colors[clr.ScrollbarBg]            = ImVec4(0.02,  0.02,  0.02,  0.53)
    colors[clr.ScrollbarGrab]          = ImVec4(0.31,  0.31,  0.31,  1.00)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.41,  0.41,  0.41,  1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.51,  0.51,  0.51,  1.00)
    colors[clr.CheckMark]              = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.SliderGrab]             = ImVec4(0.24,  0.52,  0.88,  1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.Button]                 = ImVec4(0.26,  0.59,  0.98,  0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.ButtonActive]           = ImVec4(0.06,  0.53,  0.98,  1.00)
    colors[clr.Header]                 = ImVec4(0.26,  0.59,  0.98,  0.00)
    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.Separator]              = colors[clr.Border]
    colors[clr.SeparatorHovered]       = ImVec4(0.26,  0.59,  0.98,  0.78)
    colors[clr.SeparatorActive]        = 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.26,  0.59,  0.98,  0.95)
    colors[clr.CloseButton]            = ImVec4(0.41,  0.41,  0.41,  0.50)
    colors[clr.CloseButtonHovered]     = ImVec4(0.98,  0.39,  0.36,  1.00)
    colors[clr.CloseButtonActive]      = ImVec4(0.98,  0.39,  0.36,  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.26,  0.59,  0.98,  0.35)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.80,  0.80,  0.80,  0.35)
end
Что-то не хочет работать. SERVER: Unknown command.
 

chromiusj

Известный
Модератор
5,656
3,959
Код:
-- из твоего кода

function main()
    ApplyStyle()
 
    sampRegisterChatCommand('aaa11', function() -- тут меняй команду
        tmain.window.v = not tmain.window.v
    end)
 
    imgui.Process = false
    tmain.window.v = false
 
    while true do  wait(0)
        imgui.Process = tmain.window.v
    end
end

script_name("Animation Manager")
script_author("Grinch_")
script_description("Animation manager for GTA San Andreas")
script_dependencies("imgui")
script_version("1.0")

--Keys
local keys =
{
    menu_key1        = 0xA4,  -- Left Alt
    menu_key2         = 0x6B,  -- Numpad +
}

-- Script Dependencies
local imgui       = require 'imgui'

local tmain =
{
    window         = imgui.ImBool(false),
    current_btn    = 1,
    loop           = imgui.ImBool(false),
    secondary      = imgui.ImBool(false),
    search_text    = imgui.ImBuffer(24),
    ifp_name       = imgui.ImBuffer(24),
    animation_name = imgui.ImBuffer(24),
}


local animations = {
    "AIRPORT$thrw_barl_thrw",
    "ATTRACTORS$Stepsit_in",
    "ATTRACTORS$Stepsit_loop",
    "ATTRACTORS$Stepsit_out",
    "BAR$Barcustom_get",
    "BAR$Barcustom_loop",
    "BAR$Barcustom_order",
    "BAR$BARman_idle",
    "BAR$Barserve_bottle",
    "BAR$Barserve_give",
    "BAR$Barserve_glass",
    "BAR$Barserve_in",
    "BAR$Barserve_loop",
    "BAR$Barserve_order",
    "BAR$dnk_stndF_loop",
    "BAR$dnk_stndM_loop",
    "BASEBALL$Bat_1",
    "BASEBALL$Bat_2",
    "BASEBALL$Bat_3",
    "BASEBALL$Bat_4",
    "BASEBALL$Bat_block",
    "BASEBALL$Bat_Hit_1",
    "BASEBALL$Bat_Hit_2",
    "BASEBALL$Bat_Hit_3",
    "BASEBALL$Bat_IDLE",
    "BASEBALL$Bat_M",
    "BASEBALL$BAT_PART",
    "BD_FIRE$BD_Fire1",
    "BD_FIRE$BD_Fire2",
    "BD_FIRE$BD_Fire3",
    "BD_FIRE$BD_GF_Wave",
    "BD_FIRE$BD_Panic_01",
    "BD_FIRE$BD_Panic_02",
    "BD_FIRE$BD_Panic_03",
    "BD_FIRE$BD_Panic_04",
    "BD_FIRE$BD_Panic_Loop",
    "BD_FIRE$Grlfrd_Kiss_03",
    "BD_FIRE$M_smklean_loop",
    "BD_FIRE$Playa_Kiss_03",
    "BD_FIRE$wash_up",
    "BEACH$bather",
    "BEACH$Lay_Bac_Loop",
    "BEACH$ParkSit_M_loop",
    "BEACH$ParkSit_W_loop",
    "BEACH$SitnWait_loop_W",
    "BENCHPRESS$gym_bp_celebrate",
    "BENCHPRESS$gym_bp_down",
    "BENCHPRESS$gym_bp_getoff",
    "BENCHPRESS$gym_bp_geton",
    "BENCHPRESS$gym_bp_up_A",
    "BENCHPRESS$gym_bp_up_B",
    "BENCHPRESS$gym_bp_up_smooth",
    "BF_INJECTION$BF_getin_LHS",
    "BF_INJECTION$BF_getin_RHS",
    "BF_INJECTION$BF_getout_LHS",
    "BF_INJECTION$BF_getout_RHS",
    "BIKED$BIKEd_Back",
    "BIKED$BIKEd_drivebyFT",
    "BIKED$BIKEd_drivebyLHS",
    "BIKED$BIKEd_drivebyRHS",
    "BIKED$BIKEd_Fwd",
    "BIKED$BIKEd_getoffBACK",
    "BIKED$BIKEd_getoffLHS",
    "BIKED$BIKEd_getoffRHS",
    "BIKED$BIKEd_hit",
    "BIKED$BIKEd_jumponL",
    "BIKED$BIKEd_jumponR",
    "BIKED$BIKEd_kick",
    "BIKED$BIKEd_Left",
    "BIKED$BIKEd_passenger",
    "BIKED$BIKEd_pushes",
    "BIKED$BIKEd_Ride",
    "BIKED$BIKEd_Right",
    "BIKED$BIKEd_shuffle",
    "BIKED$BIKEd_Still",
    "BIKEH$BIKEh_Back",
    "BIKEH$BIKEh_drivebyFT",
    "BIKEH$BIKEh_drivebyLHS",
    "BIKEH$BIKEh_drivebyRHS",
    "BIKEH$BIKEh_Fwd",
    "BIKEH$BIKEh_getoffBACK",
    "BIKEH$BIKEh_getoffLHS",
    "BIKEH$BIKEh_getoffRHS",
    "BIKEH$BIKEh_hit",
    "BIKEH$BIKEh_jumponL",
    "BIKEH$BIKEh_jumponR",
    "BIKEH$BIKEh_kick",
    "BIKEH$BIKEh_Left",
    "BIKEH$BIKEh_passenger",
    "BIKEH$BIKEh_pushes",
    "BIKEH$BIKEh_Ride",
    "BIKEH$BIKEh_Right",
    "BIKEH$BIKEh_Still",
    "BIKELEAP$bk_blnce_in",
    "WEAPONS$SHP_2H_Lift",
    "WEAPONS$SHP_2H_Lift_End",
    "WEAPONS$SHP_2H_Ret",
    "WEAPONS$SHP_2H_Ret_S",
    "WEAPONS$SHP_Ar_Lift",
    "WEAPONS$SHP_Ar_Lift_End",
    "WEAPONS$SHP_Ar_Ret",
    "WEAPONS$SHP_Ar_Ret_S",
    "WEAPONS$SHP_G_Lift_In",
    "WEAPONS$SHP_G_Lift_Out",
    "WEAPONS$SHP_Tray_In",
    "WEAPONS$SHP_Tray_Out",
    "WEAPONS$SHP_Tray_Pose",
    "WUZI$CS_Dead_Guy",
    "WUZI$CS_Plyr_pt1",
    "WUZI$CS_Plyr_pt2",
    "WUZI$CS_Wuzi_pt1",
    "WUZI$CS_Wuzi_pt2",
    "WUZI$Walkstart_Idle_01",
    "WUZI$Wuzi_follow",
    "WUZI$Wuzi_Greet_Plyr",
    "WUZI$Wuzi_Greet_Wuzi",
    "WUZI$Wuzi_grnd_chk",
    "WUZI$Wuzi_stand_loop",
    "WUZI$Wuzi_Walk",
}

function imgui.OnDrawFrame()
    if  tmain.window.v then

        imgui.SetNextWindowSize(imgui.ImVec2(350, 600),  imgui.Cond.FirstUseEver)

        imgui.Begin(string.format( '%s v%s by Grinch_',script.this.name,script.this.version),tmain.window,imgui.WindowFlags.NoCollapse)
       
        CreateButtons({"List","Search","Custom"},{List,Search,Custom})

        imgui.End()
    end
end

function List()
    imgui.Spacing()
    local menu_name = ""
    if imgui.BeginChild("") then
        for key,value in ipairs(animations) do
            local temp,_ = value:match("([^$]+)$([^$]+)")
            if menu_name ~= temp then
                menu_name = temp

                if imgui.CollapsingHeader(menu_name) then
                    imgui.Spacing()
                    for key,value in pairs(animations) do
                        local file,animation = value:match("([^$]+)$([^$]+)")
                        if menu_name == file then
                            AnimationEntry(file,animation)
                        end
                    end
                    imgui.Spacing()
                    imgui.Separator()
                    imgui.Spacing()
                end
            end
        end
        imgui.EndChild()
    end

end

function Search()
    imgui.Dummy(imgui.ImVec2(0,10))

    imgui.PushItemWidth(imgui.GetWindowWidth()-100)
    imgui.InputText("Search ",tmain.search_text)
    imgui.PopItemWidth()

    imgui.Spacing()
    imgui.Text("Found entries :(" .. tmain.search_text.v .. ")")
    imgui.Separator()
    imgui.Spacing()
    if imgui.BeginChild("") then
        for key,value in pairs(animations) do
            file, animation = value:match("([^$]+)$([^$]+)")
            if (string.upper(animation):find(string.upper(tmain.search_text.v))) then
                AnimationEntry(file,animation)
            end
        end      
        imgui.Spacing()
        imgui.EndChild()
    end
end

function Custom()

    imgui.Dummy(imgui.ImVec2(0,10))
   
    imgui.InputText("IFP name",tmain.ifp_name)
    imgui.InputText("Animation name",tmain.animation_name)
    imgui.Spacing()
    if imgui.Button("Play animation",imgui.ImVec2(imgui.GetWindowWidth()-20,25)) then
        PlayAnimation(tmain.ifp_name.v,tmain.animation_name.v)
    end
end


function AnimationEntry(file,animation)
    if imgui.MenuItem(animation) then
        if file ~= "PED" then
            requestAnimation(file)
            loadAllModelsNow()
        end
        PlayAnimation(file,animation)
    end
end

function PlayAnimation(file,animation)
    if tmain.secondary.v == true then
        taskPlayAnimSecondary(PLAYER_PED,animation,file,4.0,tmain.loop.v,0,0,0,-1)
    else
        taskPlayAnim(PLAYER_PED,animation,file,4.0,tmain.loop.v,0,0,0,-1)
    end
    printHelpString("Playing animation")
    if file ~= "ped" then
        removeAnimation(animation)
    end
end

function CreateButtons(names,func)

    local X = imgui.GetWindowWidth()/3 - 7*imgui.StyleVar.WindowPadding
    for i=1,3,1 do
       
        if i == tmain.current_btn then
            imgui.GetStyle().Colors[imgui.Col.Button] = imgui.ImVec4(0.06,  0.53,  0.98,  1.00)
        end

        if imgui.Button(names[i],imgui.ImVec2(X,25)) then
            tmain.current_btn = i
        end

        imgui.GetStyle().Colors[imgui.Col.Button] = imgui.ImVec4(0.26,  0.59,  0.98,  0.40)

        if i%3 ~= 0 then
            imgui.SameLine(0.0,0.0)
        end

    end
    imgui.NewLine()

    imgui.Spacing()
    imgui.Columns(2,nil,false)
    imgui.Checkbox("Loop", tmain.loop)
    imgui.NextColumn()
    imgui.Checkbox("Secondary", tmain.secondary)
    imgui.Columns(1)
    imgui.Spacing()
    if imgui.Button("Stop animation",imgui.ImVec2(imgui.GetWindowWidth()-20,25)) then
        clearCharTasks(PLAYER_PED)
        printHelpString("Animation stopped")
    end
    imgui.Spacing()
    imgui.Separator()
    func[tmain.current_btn]()

end

function main()
    ApplyStyle()

    while true do
        if isKeyDown(keys.menu_key1) and isKeyDown(keys.menu_key2) then
            while isKeyDown(keys.menu_key1) and isKeyDown(keys.menu_key2) do
                wait(0)
            end
            tmain.window.v = not tmain.window.v
        end

        imgui.Process = tmain.window.v
        wait(0)
    end
end

function ApplyStyle()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4

    style.WindowRounding = 2.0
    style.WindowTitleAlign = imgui.ImVec2(0.5,  0.84)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 0.0
    style.ItemSpacing = imgui.ImVec2(3.0,  3.0)
    style.ScrollbarSize = 12.0
    style.ScrollbarRounding = 2.0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0
    style.WindowPadding = imgui.ImVec2(10.0,  10.0)
    colors[clr.Text]                   = ImVec4(1.00,  1.00,  1.00,  1.00)
    colors[clr.TextDisabled]           = ImVec4(0.50,  0.50,  0.50,  1.00)
    colors[clr.WindowBg]               = ImVec4(0.06,  0.06,  0.06,  0.94)
    colors[clr.ChildWindowBg]          = ImVec4(1.00,  1.00,  1.00,  0.00)
    colors[clr.PopupBg]                = ImVec4(0.08,  0.08,  0.08,  0.94)
    colors[clr.ComboBg]                = colors[clr.PopupBg]
    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.16,  0.29,  0.48,  0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.26,  0.59,  0.98,  0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.26,  0.59,  0.98,  0.67)
    colors[clr.TitleBg]                = ImVec4(0.04,  0.04,  0.04,  1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.16,  0.29,  0.48,  1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00,  0.00,  0.00,  0.51)
    colors[clr.MenuBarBg]              = ImVec4(0.14,  0.14,  0.14,  1.00)
    colors[clr.ScrollbarBg]            = ImVec4(0.02,  0.02,  0.02,  0.53)
    colors[clr.ScrollbarGrab]          = ImVec4(0.31,  0.31,  0.31,  1.00)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.41,  0.41,  0.41,  1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.51,  0.51,  0.51,  1.00)
    colors[clr.CheckMark]              = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.SliderGrab]             = ImVec4(0.24,  0.52,  0.88,  1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.Button]                 = ImVec4(0.26,  0.59,  0.98,  0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.ButtonActive]           = ImVec4(0.06,  0.53,  0.98,  1.00)
    colors[clr.Header]                 = ImVec4(0.26,  0.59,  0.98,  0.00)
    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.Separator]              = colors[clr.Border]
    colors[clr.SeparatorHovered]       = ImVec4(0.26,  0.59,  0.98,  0.78)
    colors[clr.SeparatorActive]        = 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.26,  0.59,  0.98,  0.95)
    colors[clr.CloseButton]            = ImVec4(0.41,  0.41,  0.41,  0.50)
    colors[clr.CloseButtonHovered]     = ImVec4(0.98,  0.39,  0.36,  1.00)
    colors[clr.CloseButtonActive]      = ImVec4(0.98,  0.39,  0.36,  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.26,  0.59,  0.98,  0.35)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.80,  0.80,  0.80,  0.35)
end
Что-то не хочет работать. SERVER: Unknown command.
Зачем тебе два мейна?Следи хотя бы,что копируешь
 
  • Нравится
Реакции: arpix

arpix

Активный
119
32
Код:
-- из твоего кода

function main()
    ApplyStyle()
 
    sampRegisterChatCommand('aaa11', function() -- тут меняй команду
        tmain.window.v = not tmain.window.v
    end)
 
    imgui.Process = false
    tmain.window.v = false
 
    while true do  wait(0)
        imgui.Process = tmain.window.v
    end
end

script_name("Animation Manager")
script_author("Grinch_")
script_description("Animation manager for GTA San Andreas")
script_dependencies("imgui")
script_version("1.0")

--Keys
local keys =
{
    menu_key1        = 0xA4,  -- Left Alt
    menu_key2         = 0x6B,  -- Numpad +
}

-- Script Dependencies
local imgui       = require 'imgui'

local tmain =
{
    window         = imgui.ImBool(false),
    current_btn    = 1,
    loop           = imgui.ImBool(false),
    secondary      = imgui.ImBool(false),
    search_text    = imgui.ImBuffer(24),
    ifp_name       = imgui.ImBuffer(24),
    animation_name = imgui.ImBuffer(24),
}


local animations = {
    "AIRPORT$thrw_barl_thrw",
    "ATTRACTORS$Stepsit_in",
    "ATTRACTORS$Stepsit_loop",
    "ATTRACTORS$Stepsit_out",
    "BAR$Barcustom_get",
    "BAR$Barcustom_loop",
    "BAR$Barcustom_order",
    "BAR$BARman_idle",
    "BAR$Barserve_bottle",
    "BAR$Barserve_give",
    "BAR$Barserve_glass",
    "BAR$Barserve_in",
    "BAR$Barserve_loop",
    "BAR$Barserve_order",
    "BAR$dnk_stndF_loop",
    "BAR$dnk_stndM_loop",
    "BASEBALL$Bat_1",
    "BASEBALL$Bat_2",
    "BASEBALL$Bat_3",
    "BASEBALL$Bat_4",
    "BASEBALL$Bat_block",
    "BASEBALL$Bat_Hit_1",
    "BASEBALL$Bat_Hit_2",
    "BASEBALL$Bat_Hit_3",
    "BASEBALL$Bat_IDLE",
    "BASEBALL$Bat_M",
    "BASEBALL$BAT_PART",
    "BD_FIRE$BD_Fire1",
    "BD_FIRE$BD_Fire2",
    "BD_FIRE$BD_Fire3",
    "BD_FIRE$BD_GF_Wave",
    "BD_FIRE$BD_Panic_01",
    "BD_FIRE$BD_Panic_02",
    "BD_FIRE$BD_Panic_03",
    "BD_FIRE$BD_Panic_04",
    "BD_FIRE$BD_Panic_Loop",
    "BD_FIRE$Grlfrd_Kiss_03",
    "BD_FIRE$M_smklean_loop",
    "BD_FIRE$Playa_Kiss_03",
    "BD_FIRE$wash_up",
    "BEACH$bather",
    "BEACH$Lay_Bac_Loop",
    "BEACH$ParkSit_M_loop",
    "BEACH$ParkSit_W_loop",
    "BEACH$SitnWait_loop_W",
    "BENCHPRESS$gym_bp_celebrate",
    "BENCHPRESS$gym_bp_down",
    "BENCHPRESS$gym_bp_getoff",
    "BENCHPRESS$gym_bp_geton",
    "BENCHPRESS$gym_bp_up_A",
    "BENCHPRESS$gym_bp_up_B",
    "BENCHPRESS$gym_bp_up_smooth",
    "BF_INJECTION$BF_getin_LHS",
    "BF_INJECTION$BF_getin_RHS",
    "BF_INJECTION$BF_getout_LHS",
    "BF_INJECTION$BF_getout_RHS",
    "BIKED$BIKEd_Back",
    "BIKED$BIKEd_drivebyFT",
    "BIKED$BIKEd_drivebyLHS",
    "BIKED$BIKEd_drivebyRHS",
    "BIKED$BIKEd_Fwd",
    "BIKED$BIKEd_getoffBACK",
    "BIKED$BIKEd_getoffLHS",
    "BIKED$BIKEd_getoffRHS",
    "BIKED$BIKEd_hit",
    "BIKED$BIKEd_jumponL",
    "BIKED$BIKEd_jumponR",
    "BIKED$BIKEd_kick",
    "BIKED$BIKEd_Left",
    "BIKED$BIKEd_passenger",
    "BIKED$BIKEd_pushes",
    "BIKED$BIKEd_Ride",
    "BIKED$BIKEd_Right",
    "BIKED$BIKEd_shuffle",
    "BIKED$BIKEd_Still",
    "BIKEH$BIKEh_Back",
    "BIKEH$BIKEh_drivebyFT",
    "BIKEH$BIKEh_drivebyLHS",
    "BIKEH$BIKEh_drivebyRHS",
    "BIKEH$BIKEh_Fwd",
    "BIKEH$BIKEh_getoffBACK",
    "BIKEH$BIKEh_getoffLHS",
    "BIKEH$BIKEh_getoffRHS",
    "BIKEH$BIKEh_hit",
    "BIKEH$BIKEh_jumponL",
    "BIKEH$BIKEh_jumponR",
    "BIKEH$BIKEh_kick",
    "BIKEH$BIKEh_Left",
    "BIKEH$BIKEh_passenger",
    "BIKEH$BIKEh_pushes",
    "BIKEH$BIKEh_Ride",
    "BIKEH$BIKEh_Right",
    "BIKEH$BIKEh_Still",
    "BIKELEAP$bk_blnce_in",
    "WEAPONS$SHP_2H_Lift",
    "WEAPONS$SHP_2H_Lift_End",
    "WEAPONS$SHP_2H_Ret",
    "WEAPONS$SHP_2H_Ret_S",
    "WEAPONS$SHP_Ar_Lift",
    "WEAPONS$SHP_Ar_Lift_End",
    "WEAPONS$SHP_Ar_Ret",
    "WEAPONS$SHP_Ar_Ret_S",
    "WEAPONS$SHP_G_Lift_In",
    "WEAPONS$SHP_G_Lift_Out",
    "WEAPONS$SHP_Tray_In",
    "WEAPONS$SHP_Tray_Out",
    "WEAPONS$SHP_Tray_Pose",
    "WUZI$CS_Dead_Guy",
    "WUZI$CS_Plyr_pt1",
    "WUZI$CS_Plyr_pt2",
    "WUZI$CS_Wuzi_pt1",
    "WUZI$CS_Wuzi_pt2",
    "WUZI$Walkstart_Idle_01",
    "WUZI$Wuzi_follow",
    "WUZI$Wuzi_Greet_Plyr",
    "WUZI$Wuzi_Greet_Wuzi",
    "WUZI$Wuzi_grnd_chk",
    "WUZI$Wuzi_stand_loop",
    "WUZI$Wuzi_Walk",
}

function imgui.OnDrawFrame()
    if  tmain.window.v then

        imgui.SetNextWindowSize(imgui.ImVec2(350, 600),  imgui.Cond.FirstUseEver)

        imgui.Begin(string.format( '%s v%s by Grinch_',script.this.name,script.this.version),tmain.window,imgui.WindowFlags.NoCollapse)
       
        CreateButtons({"List","Search","Custom"},{List,Search,Custom})

        imgui.End()
    end
end

function List()
    imgui.Spacing()
    local menu_name = ""
    if imgui.BeginChild("") then
        for key,value in ipairs(animations) do
            local temp,_ = value:match("([^$]+)$([^$]+)")
            if menu_name ~= temp then
                menu_name = temp

                if imgui.CollapsingHeader(menu_name) then
                    imgui.Spacing()
                    for key,value in pairs(animations) do
                        local file,animation = value:match("([^$]+)$([^$]+)")
                        if menu_name == file then
                            AnimationEntry(file,animation)
                        end
                    end
                    imgui.Spacing()
                    imgui.Separator()
                    imgui.Spacing()
                end
            end
        end
        imgui.EndChild()
    end

end

function Search()
    imgui.Dummy(imgui.ImVec2(0,10))

    imgui.PushItemWidth(imgui.GetWindowWidth()-100)
    imgui.InputText("Search ",tmain.search_text)
    imgui.PopItemWidth()

    imgui.Spacing()
    imgui.Text("Found entries :(" .. tmain.search_text.v .. ")")
    imgui.Separator()
    imgui.Spacing()
    if imgui.BeginChild("") then
        for key,value in pairs(animations) do
            file, animation = value:match("([^$]+)$([^$]+)")
            if (string.upper(animation):find(string.upper(tmain.search_text.v))) then
                AnimationEntry(file,animation)
            end
        end      
        imgui.Spacing()
        imgui.EndChild()
    end
end

function Custom()

    imgui.Dummy(imgui.ImVec2(0,10))
   
    imgui.InputText("IFP name",tmain.ifp_name)
    imgui.InputText("Animation name",tmain.animation_name)
    imgui.Spacing()
    if imgui.Button("Play animation",imgui.ImVec2(imgui.GetWindowWidth()-20,25)) then
        PlayAnimation(tmain.ifp_name.v,tmain.animation_name.v)
    end
end


function AnimationEntry(file,animation)
    if imgui.MenuItem(animation) then
        if file ~= "PED" then
            requestAnimation(file)
            loadAllModelsNow()
        end
        PlayAnimation(file,animation)
    end
end

function PlayAnimation(file,animation)
    if tmain.secondary.v == true then
        taskPlayAnimSecondary(PLAYER_PED,animation,file,4.0,tmain.loop.v,0,0,0,-1)
    else
        taskPlayAnim(PLAYER_PED,animation,file,4.0,tmain.loop.v,0,0,0,-1)
    end
    printHelpString("Playing animation")
    if file ~= "ped" then
        removeAnimation(animation)
    end
end

function CreateButtons(names,func)

    local X = imgui.GetWindowWidth()/3 - 7*imgui.StyleVar.WindowPadding
    for i=1,3,1 do
       
        if i == tmain.current_btn then
            imgui.GetStyle().Colors[imgui.Col.Button] = imgui.ImVec4(0.06,  0.53,  0.98,  1.00)
        end

        if imgui.Button(names[i],imgui.ImVec2(X,25)) then
            tmain.current_btn = i
        end

        imgui.GetStyle().Colors[imgui.Col.Button] = imgui.ImVec4(0.26,  0.59,  0.98,  0.40)

        if i%3 ~= 0 then
            imgui.SameLine(0.0,0.0)
        end

    end
    imgui.NewLine()

    imgui.Spacing()
    imgui.Columns(2,nil,false)
    imgui.Checkbox("Loop", tmain.loop)
    imgui.NextColumn()
    imgui.Checkbox("Secondary", tmain.secondary)
    imgui.Columns(1)
    imgui.Spacing()
    if imgui.Button("Stop animation",imgui.ImVec2(imgui.GetWindowWidth()-20,25)) then
        clearCharTasks(PLAYER_PED)
        printHelpString("Animation stopped")
    end
    imgui.Spacing()
    imgui.Separator()
    func[tmain.current_btn]()

end

function main()
    ApplyStyle()

    while true do
        if isKeyDown(keys.menu_key1) and isKeyDown(keys.menu_key2) then
            while isKeyDown(keys.menu_key1) and isKeyDown(keys.menu_key2) do
                wait(0)
            end
            tmain.window.v = not tmain.window.v
        end

        imgui.Process = tmain.window.v
        wait(0)
    end
end

function ApplyStyle()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4

    style.WindowRounding = 2.0
    style.WindowTitleAlign = imgui.ImVec2(0.5,  0.84)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 0.0
    style.ItemSpacing = imgui.ImVec2(3.0,  3.0)
    style.ScrollbarSize = 12.0
    style.ScrollbarRounding = 2.0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0
    style.WindowPadding = imgui.ImVec2(10.0,  10.0)
    colors[clr.Text]                   = ImVec4(1.00,  1.00,  1.00,  1.00)
    colors[clr.TextDisabled]           = ImVec4(0.50,  0.50,  0.50,  1.00)
    colors[clr.WindowBg]               = ImVec4(0.06,  0.06,  0.06,  0.94)
    colors[clr.ChildWindowBg]          = ImVec4(1.00,  1.00,  1.00,  0.00)
    colors[clr.PopupBg]                = ImVec4(0.08,  0.08,  0.08,  0.94)
    colors[clr.ComboBg]                = colors[clr.PopupBg]
    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.16,  0.29,  0.48,  0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.26,  0.59,  0.98,  0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.26,  0.59,  0.98,  0.67)
    colors[clr.TitleBg]                = ImVec4(0.04,  0.04,  0.04,  1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.16,  0.29,  0.48,  1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00,  0.00,  0.00,  0.51)
    colors[clr.MenuBarBg]              = ImVec4(0.14,  0.14,  0.14,  1.00)
    colors[clr.ScrollbarBg]            = ImVec4(0.02,  0.02,  0.02,  0.53)
    colors[clr.ScrollbarGrab]          = ImVec4(0.31,  0.31,  0.31,  1.00)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.41,  0.41,  0.41,  1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.51,  0.51,  0.51,  1.00)
    colors[clr.CheckMark]              = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.SliderGrab]             = ImVec4(0.24,  0.52,  0.88,  1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.Button]                 = ImVec4(0.26,  0.59,  0.98,  0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.ButtonActive]           = ImVec4(0.06,  0.53,  0.98,  1.00)
    colors[clr.Header]                 = ImVec4(0.26,  0.59,  0.98,  0.00)
    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.Separator]              = colors[clr.Border]
    colors[clr.SeparatorHovered]       = ImVec4(0.26,  0.59,  0.98,  0.78)
    colors[clr.SeparatorActive]        = 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.26,  0.59,  0.98,  0.95)
    colors[clr.CloseButton]            = ImVec4(0.41,  0.41,  0.41,  0.50)
    colors[clr.CloseButtonHovered]     = ImVec4(0.98,  0.39,  0.36,  1.00)
    colors[clr.CloseButtonActive]      = ImVec4(0.98,  0.39,  0.36,  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.26,  0.59,  0.98,  0.35)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.80,  0.80,  0.80,  0.35)
end
Что-то не хочет работать. SERVER: Unknown command.
забыл кое что, вставь это в начале funcrion main
Lua:
if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

и да удали function main которая у тебя внизу кода

Lua:
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    
    ApplyStyle()
 
    sampRegisterChatCommand('test', function()
        tmain.window.v = not tmain.window.v
    end)
 
    imgui.Process = false
    tmain.window.v = false
 
    while true do  wait(0)
        imgui.Process = tmain.window.v
    end
end
 

Sirccet

Участник
Автор темы
142
21
Код:
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    
    ApplyStyle()
 
    sampRegisterChatCommand('test111', function()
        tmain.window.v = not tmain.window.v
    end)
 
    imgui.Process = false
    tmain.window.v = false
 
    while true do  wait(0)
        imgui.Process = tmain.window.v
    end
end

script_name("Animation Manager")
script_author("Grinch_")
script_description("Animation manager for GTA San Andreas")
script_dependencies("imgui")
script_version("1.0")

-- Script Dependencies
local imgui       = require 'imgui'

local tmain =
{
    window         = imgui.ImBool(false),
    current_btn    = 1,
    loop           = imgui.ImBool(false),
    secondary      = imgui.ImBool(false),
    search_text    = imgui.ImBuffer(24),
    ifp_name       = imgui.ImBuffer(24),
    animation_name = imgui.ImBuffer(24),
}


local animations = {
    "AIRPORT$thrw_barl_thrw",
    "ATTRACTORS$Stepsit_in",
    "ATTRACTORS$Stepsit_loop",
    "ATTRACTORS$Stepsit_out",
    "BAR$Barcustom_get",
    "BAR$Barcustom_loop",
    "BAR$Barcustom_order",
    "BAR$BARman_idle",
    "BAR$Barserve_bottle",
    "BAR$Barserve_give",
    "BAR$Barserve_glass",
    "BAR$Barserve_in",
    "BAR$Barserve_loop",
    "BAR$Barserve_order",
    "BAR$dnk_stndF_loop",
    "BAR$dnk_stndM_loop",
    "BASEBALL$Bat_1",
    "BASEBALL$Bat_2",
    "BASEBALL$Bat_3",
    "WEAPONS$SHP_G_Lift_In",
    "WEAPONS$SHP_G_Lift_Out",
    "WEAPONS$SHP_Tray_In",
    "WEAPONS$SHP_Tray_Out",
    "WEAPONS$SHP_Tray_Pose",
    "WUZI$CS_Dead_Guy",
    "WUZI$CS_Plyr_pt1",
    "WUZI$CS_Plyr_pt2",
    "WUZI$CS_Wuzi_pt1",
    "WUZI$CS_Wuzi_pt2",
    "WUZI$Walkstart_Idle_01",
    "WUZI$Wuzi_follow",
    "WUZI$Wuzi_Greet_Plyr",
    "WUZI$Wuzi_Greet_Wuzi",
    "WUZI$Wuzi_grnd_chk",
    "WUZI$Wuzi_stand_loop",
    "WUZI$Wuzi_Walk",
}

function imgui.OnDrawFrame()
    if  tmain.window.v then

        imgui.SetNextWindowSize(imgui.ImVec2(350, 600),  imgui.Cond.FirstUseEver)

        imgui.Begin(string.format( '%s v%s by Grinch_',script.this.name,script.this.version),tmain.window,imgui.WindowFlags.NoCollapse)
        
        CreateButtons({"List","Search","Custom"},{List,Search,Custom})

        imgui.End()
    end
end

function List()
    imgui.Spacing()
    local menu_name = ""
    if imgui.BeginChild("") then
        for key,value in ipairs(animations) do
            local temp,_ = value:match("([^$]+)$([^$]+)")
            if menu_name ~= temp then
                menu_name = temp

                if imgui.CollapsingHeader(menu_name) then
                    imgui.Spacing()
                    for key,value in pairs(animations) do
                        local file,animation = value:match("([^$]+)$([^$]+)")
                        if menu_name == file then
                            AnimationEntry(file,animation)
                        end
                    end
                    imgui.Spacing()
                    imgui.Separator()
                    imgui.Spacing()
                end
            end
        end 
        imgui.EndChild()
    end

end

function Search()
    imgui.Dummy(imgui.ImVec2(0,10))

    imgui.PushItemWidth(imgui.GetWindowWidth()-100)
    imgui.InputText("Search ",tmain.search_text)
    imgui.PopItemWidth()

    imgui.Spacing()
    imgui.Text("Found entries :(" .. tmain.search_text.v .. ")")
    imgui.Separator()
    imgui.Spacing()
    if imgui.BeginChild("") then
        for key,value in pairs(animations) do
            file, animation = value:match("([^$]+)$([^$]+)")
            if (string.upper(animation):find(string.upper(tmain.search_text.v))) then
                AnimationEntry(file,animation)
            end
        end       
        imgui.Spacing()
        imgui.EndChild()
    end
end

function Custom()

    imgui.Dummy(imgui.ImVec2(0,10))
    
    imgui.InputText("IFP name",tmain.ifp_name)
    imgui.InputText("Animation name",tmain.animation_name)
    imgui.Spacing()
    if imgui.Button("Play animation",imgui.ImVec2(imgui.GetWindowWidth()-20,25)) then
        PlayAnimation(tmain.ifp_name.v,tmain.animation_name.v)
    end
end


function AnimationEntry(file,animation)
    if imgui.MenuItem(animation) then
        if file ~= "PED" then
            requestAnimation(file)
            loadAllModelsNow()
        end
        PlayAnimation(file,animation)
    end
end

function PlayAnimation(file,animation)
    if tmain.secondary.v == true then
        taskPlayAnimSecondary(PLAYER_PED,animation,file,4.0,tmain.loop.v,0,0,0,-1) 
    else
        taskPlayAnim(PLAYER_PED,animation,file,4.0,tmain.loop.v,0,0,0,-1)
    end
    printHelpString("Playing animation")
    if file ~= "ped" then
        removeAnimation(animation)
    end
end

function CreateButtons(names,func)

    local X = imgui.GetWindowWidth()/3 - 7*imgui.StyleVar.WindowPadding
    for i=1,3,1 do
        
        if i == tmain.current_btn then
            imgui.GetStyle().Colors[imgui.Col.Button] = imgui.ImVec4(0.06,  0.53,  0.98,  1.00)
        end

        if imgui.Button(names[i],imgui.ImVec2(X,25)) then
            tmain.current_btn = i
        end

        imgui.GetStyle().Colors[imgui.Col.Button] = imgui.ImVec4(0.26,  0.59,  0.98,  0.40)

        if i%3 ~= 0 then
            imgui.SameLine(0.0,0.0)
        end

    end
    imgui.NewLine()

    imgui.Spacing()
    imgui.Columns(2,nil,false)
    imgui.Checkbox("Loop", tmain.loop)
    imgui.NextColumn()
    imgui.Checkbox("Secondary", tmain.secondary)
    imgui.Columns(1)
    imgui.Spacing()
    if imgui.Button("Stop animation",imgui.ImVec2(imgui.GetWindowWidth()-20,25)) then
        clearCharTasks(PLAYER_PED)
        printHelpString("Animation stopped")
    end
    imgui.Spacing()
    imgui.Separator()
    func[tmain.current_btn]()

end

function ApplyStyle()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4

    style.WindowRounding = 2.0
    style.WindowTitleAlign = imgui.ImVec2(0.5,  0.84)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 0.0
    style.ItemSpacing = imgui.ImVec2(3.0,  3.0)
    style.ScrollbarSize = 12.0
    style.ScrollbarRounding = 2.0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0
    style.WindowPadding = imgui.ImVec2(10.0,  10.0)
    colors[clr.Text]                   = ImVec4(1.00,  1.00,  1.00,  1.00)
    colors[clr.TextDisabled]           = ImVec4(0.50,  0.50,  0.50,  1.00)
    colors[clr.WindowBg]               = ImVec4(0.06,  0.06,  0.06,  0.94)
    colors[clr.ChildWindowBg]          = ImVec4(1.00,  1.00,  1.00,  0.00)
    colors[clr.PopupBg]                = ImVec4(0.08,  0.08,  0.08,  0.94)
    colors[clr.ComboBg]                = colors[clr.PopupBg]
    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.16,  0.29,  0.48,  0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.26,  0.59,  0.98,  0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.26,  0.59,  0.98,  0.67)
    colors[clr.TitleBg]                = ImVec4(0.04,  0.04,  0.04,  1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.16,  0.29,  0.48,  1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00,  0.00,  0.00,  0.51)
    colors[clr.MenuBarBg]              = ImVec4(0.14,  0.14,  0.14,  1.00)
    colors[clr.ScrollbarBg]            = ImVec4(0.02,  0.02,  0.02,  0.53)
    colors[clr.ScrollbarGrab]          = ImVec4(0.31,  0.31,  0.31,  1.00)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.41,  0.41,  0.41,  1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.51,  0.51,  0.51,  1.00)
    colors[clr.CheckMark]              = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.SliderGrab]             = ImVec4(0.24,  0.52,  0.88,  1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.Button]                 = ImVec4(0.26,  0.59,  0.98,  0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.ButtonActive]           = ImVec4(0.06,  0.53,  0.98,  1.00)
    colors[clr.Header]                 = ImVec4(0.26,  0.59,  0.98,  0.00)
    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.Separator]              = colors[clr.Border]
    colors[clr.SeparatorHovered]       = ImVec4(0.26,  0.59,  0.98,  0.78)
    colors[clr.SeparatorActive]        = 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.26,  0.59,  0.98,  0.95)
    colors[clr.CloseButton]            = ImVec4(0.41,  0.41,  0.41,  0.50)
    colors[clr.CloseButtonHovered]     = ImVec4(0.98,  0.39,  0.36,  1.00)
    colors[clr.CloseButtonActive]      = ImVec4(0.98,  0.39,  0.36,  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.26,  0.59,  0.98,  0.35)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.80,  0.80,  0.80,  0.35)
end
Я же всё правильно делаю. Всё равно не работает.
 

arpix

Активный
119
32
Код:
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
  
    ApplyStyle()
 
    sampRegisterChatCommand('test111', function()
        tmain.window.v = not tmain.window.v
    end)
 
    imgui.Process = false
    tmain.window.v = false
 
    while true do  wait(0)
        imgui.Process = tmain.window.v
    end
end

script_name("Animation Manager")
script_author("Grinch_")
script_description("Animation manager for GTA San Andreas")
script_dependencies("imgui")
script_version("1.0")

-- Script Dependencies
local imgui       = require 'imgui'

local tmain =
{
    window         = imgui.ImBool(false),
    current_btn    = 1,
    loop           = imgui.ImBool(false),
    secondary      = imgui.ImBool(false),
    search_text    = imgui.ImBuffer(24),
    ifp_name       = imgui.ImBuffer(24),
    animation_name = imgui.ImBuffer(24),
}


local animations = {
    "AIRPORT$thrw_barl_thrw",
    "ATTRACTORS$Stepsit_in",
    "ATTRACTORS$Stepsit_loop",
    "ATTRACTORS$Stepsit_out",
    "BAR$Barcustom_get",
    "BAR$Barcustom_loop",
    "BAR$Barcustom_order",
    "BAR$BARman_idle",
    "BAR$Barserve_bottle",
    "BAR$Barserve_give",
    "BAR$Barserve_glass",
    "BAR$Barserve_in",
    "BAR$Barserve_loop",
    "BAR$Barserve_order",
    "BAR$dnk_stndF_loop",
    "BAR$dnk_stndM_loop",
    "BASEBALL$Bat_1",
    "BASEBALL$Bat_2",
    "BASEBALL$Bat_3",
    "WEAPONS$SHP_G_Lift_In",
    "WEAPONS$SHP_G_Lift_Out",
    "WEAPONS$SHP_Tray_In",
    "WEAPONS$SHP_Tray_Out",
    "WEAPONS$SHP_Tray_Pose",
    "WUZI$CS_Dead_Guy",
    "WUZI$CS_Plyr_pt1",
    "WUZI$CS_Plyr_pt2",
    "WUZI$CS_Wuzi_pt1",
    "WUZI$CS_Wuzi_pt2",
    "WUZI$Walkstart_Idle_01",
    "WUZI$Wuzi_follow",
    "WUZI$Wuzi_Greet_Plyr",
    "WUZI$Wuzi_Greet_Wuzi",
    "WUZI$Wuzi_grnd_chk",
    "WUZI$Wuzi_stand_loop",
    "WUZI$Wuzi_Walk",
}

function imgui.OnDrawFrame()
    if  tmain.window.v then

        imgui.SetNextWindowSize(imgui.ImVec2(350, 600),  imgui.Cond.FirstUseEver)

        imgui.Begin(string.format( '%s v%s by Grinch_',script.this.name,script.this.version),tmain.window,imgui.WindowFlags.NoCollapse)
      
        CreateButtons({"List","Search","Custom"},{List,Search,Custom})

        imgui.End()
    end
end

function List()
    imgui.Spacing()
    local menu_name = ""
    if imgui.BeginChild("") then
        for key,value in ipairs(animations) do
            local temp,_ = value:match("([^$]+)$([^$]+)")
            if menu_name ~= temp then
                menu_name = temp

                if imgui.CollapsingHeader(menu_name) then
                    imgui.Spacing()
                    for key,value in pairs(animations) do
                        local file,animation = value:match("([^$]+)$([^$]+)")
                        if menu_name == file then
                            AnimationEntry(file,animation)
                        end
                    end
                    imgui.Spacing()
                    imgui.Separator()
                    imgui.Spacing()
                end
            end
        end
        imgui.EndChild()
    end

end

function Search()
    imgui.Dummy(imgui.ImVec2(0,10))

    imgui.PushItemWidth(imgui.GetWindowWidth()-100)
    imgui.InputText("Search ",tmain.search_text)
    imgui.PopItemWidth()

    imgui.Spacing()
    imgui.Text("Found entries :(" .. tmain.search_text.v .. ")")
    imgui.Separator()
    imgui.Spacing()
    if imgui.BeginChild("") then
        for key,value in pairs(animations) do
            file, animation = value:match("([^$]+)$([^$]+)")
            if (string.upper(animation):find(string.upper(tmain.search_text.v))) then
                AnimationEntry(file,animation)
            end
        end     
        imgui.Spacing()
        imgui.EndChild()
    end
end

function Custom()

    imgui.Dummy(imgui.ImVec2(0,10))
  
    imgui.InputText("IFP name",tmain.ifp_name)
    imgui.InputText("Animation name",tmain.animation_name)
    imgui.Spacing()
    if imgui.Button("Play animation",imgui.ImVec2(imgui.GetWindowWidth()-20,25)) then
        PlayAnimation(tmain.ifp_name.v,tmain.animation_name.v)
    end
end


function AnimationEntry(file,animation)
    if imgui.MenuItem(animation) then
        if file ~= "PED" then
            requestAnimation(file)
            loadAllModelsNow()
        end
        PlayAnimation(file,animation)
    end
end

function PlayAnimation(file,animation)
    if tmain.secondary.v == true then
        taskPlayAnimSecondary(PLAYER_PED,animation,file,4.0,tmain.loop.v,0,0,0,-1)
    else
        taskPlayAnim(PLAYER_PED,animation,file,4.0,tmain.loop.v,0,0,0,-1)
    end
    printHelpString("Playing animation")
    if file ~= "ped" then
        removeAnimation(animation)
    end
end

function CreateButtons(names,func)

    local X = imgui.GetWindowWidth()/3 - 7*imgui.StyleVar.WindowPadding
    for i=1,3,1 do
      
        if i == tmain.current_btn then
            imgui.GetStyle().Colors[imgui.Col.Button] = imgui.ImVec4(0.06,  0.53,  0.98,  1.00)
        end

        if imgui.Button(names[i],imgui.ImVec2(X,25)) then
            tmain.current_btn = i
        end

        imgui.GetStyle().Colors[imgui.Col.Button] = imgui.ImVec4(0.26,  0.59,  0.98,  0.40)

        if i%3 ~= 0 then
            imgui.SameLine(0.0,0.0)
        end

    end
    imgui.NewLine()

    imgui.Spacing()
    imgui.Columns(2,nil,false)
    imgui.Checkbox("Loop", tmain.loop)
    imgui.NextColumn()
    imgui.Checkbox("Secondary", tmain.secondary)
    imgui.Columns(1)
    imgui.Spacing()
    if imgui.Button("Stop animation",imgui.ImVec2(imgui.GetWindowWidth()-20,25)) then
        clearCharTasks(PLAYER_PED)
        printHelpString("Animation stopped")
    end
    imgui.Spacing()
    imgui.Separator()
    func[tmain.current_btn]()

end

function ApplyStyle()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4

    style.WindowRounding = 2.0
    style.WindowTitleAlign = imgui.ImVec2(0.5,  0.84)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 0.0
    style.ItemSpacing = imgui.ImVec2(3.0,  3.0)
    style.ScrollbarSize = 12.0
    style.ScrollbarRounding = 2.0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0
    style.WindowPadding = imgui.ImVec2(10.0,  10.0)
    colors[clr.Text]                   = ImVec4(1.00,  1.00,  1.00,  1.00)
    colors[clr.TextDisabled]           = ImVec4(0.50,  0.50,  0.50,  1.00)
    colors[clr.WindowBg]               = ImVec4(0.06,  0.06,  0.06,  0.94)
    colors[clr.ChildWindowBg]          = ImVec4(1.00,  1.00,  1.00,  0.00)
    colors[clr.PopupBg]                = ImVec4(0.08,  0.08,  0.08,  0.94)
    colors[clr.ComboBg]                = colors[clr.PopupBg]
    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.16,  0.29,  0.48,  0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.26,  0.59,  0.98,  0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.26,  0.59,  0.98,  0.67)
    colors[clr.TitleBg]                = ImVec4(0.04,  0.04,  0.04,  1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.16,  0.29,  0.48,  1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00,  0.00,  0.00,  0.51)
    colors[clr.MenuBarBg]              = ImVec4(0.14,  0.14,  0.14,  1.00)
    colors[clr.ScrollbarBg]            = ImVec4(0.02,  0.02,  0.02,  0.53)
    colors[clr.ScrollbarGrab]          = ImVec4(0.31,  0.31,  0.31,  1.00)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.41,  0.41,  0.41,  1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.51,  0.51,  0.51,  1.00)
    colors[clr.CheckMark]              = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.SliderGrab]             = ImVec4(0.24,  0.52,  0.88,  1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.Button]                 = ImVec4(0.26,  0.59,  0.98,  0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.ButtonActive]           = ImVec4(0.06,  0.53,  0.98,  1.00)
    colors[clr.Header]                 = ImVec4(0.26,  0.59,  0.98,  0.00)
    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.Separator]              = colors[clr.Border]
    colors[clr.SeparatorHovered]       = ImVec4(0.26,  0.59,  0.98,  0.78)
    colors[clr.SeparatorActive]        = 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.26,  0.59,  0.98,  0.95)
    colors[clr.CloseButton]            = ImVec4(0.41,  0.41,  0.41,  0.50)
    colors[clr.CloseButtonHovered]     = ImVec4(0.98,  0.39,  0.36,  1.00)
    colors[clr.CloseButtonActive]      = ImVec4(0.98,  0.39,  0.36,  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.26,  0.59,  0.98,  0.35)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.80,  0.80,  0.80,  0.35)
end
Я же всё правильно делаю. Всё равно не работает.
ну я же написал, после переменных)

ставь function main перед function imgui.OnDrawFrame()

Lua:
script_name("Animation Manager")
script_author("Grinch_")
script_description("Animation manager for GTA San Andreas")
script_dependencies("imgui")
script_version("1.0")

--Keys
local keys =
{
    menu_key1        = 0xA4,  -- Left Alt
    menu_key2         = 0x6B,  -- Numpad +
}

-- Script Dependencies
local imgui       = require 'imgui'

local tmain =
{
    window         = imgui.ImBool(false),
    current_btn    = 1,
    loop           = imgui.ImBool(false),
    secondary      = imgui.ImBool(false),
    search_text    = imgui.ImBuffer(24),
    ifp_name       = imgui.ImBuffer(24),
    animation_name = imgui.ImBuffer(24),
}


local animations = {
    "AIRPORT$thrw_barl_thrw",
    "ATTRACTORS$Stepsit_in",
    "ATTRACTORS$Stepsit_loop",
    "ATTRACTORS$Stepsit_out",
    "BAR$Barcustom_get",
    "BAR$Barcustom_loop",
    "BAR$Barcustom_order",
    "BAR$BARman_idle",
    "BAR$Barserve_bottle",
    "BAR$Barserve_give",
    "BAR$Barserve_glass",
    "BAR$Barserve_in",
    "BAR$Barserve_loop",
    "BAR$Barserve_order",
    "BAR$dnk_stndF_loop",
    "BAR$dnk_stndM_loop",
    "BASEBALL$Bat_1",
    "BASEBALL$Bat_2",
    "BASEBALL$Bat_3",
    "BASEBALL$Bat_4",
    "BASEBALL$Bat_block",
    "BASEBALL$Bat_Hit_1",
    "BASEBALL$Bat_Hit_2",
    "BASEBALL$Bat_Hit_3",
    "BASEBALL$Bat_IDLE",
    "BASEBALL$Bat_M",
    "BASEBALL$BAT_PART",
    "BD_FIRE$BD_Fire1",
    "BD_FIRE$BD_Fire2",
    "BD_FIRE$BD_Fire3",
    "BD_FIRE$BD_GF_Wave",
    "BD_FIRE$BD_Panic_01",
    "BD_FIRE$BD_Panic_02",
    "BD_FIRE$BD_Panic_03",
    "BD_FIRE$BD_Panic_04",
    "BD_FIRE$BD_Panic_Loop",
    "BD_FIRE$Grlfrd_Kiss_03",
    "BD_FIRE$M_smklean_loop",
    "BD_FIRE$Playa_Kiss_03",
    "BD_FIRE$wash_up",
    "BEACH$bather",
    "BEACH$Lay_Bac_Loop",
    "BEACH$ParkSit_M_loop",
    "BEACH$ParkSit_W_loop",
    "BEACH$SitnWait_loop_W",
    "BENCHPRESS$gym_bp_celebrate",
    "BENCHPRESS$gym_bp_down",
    "BENCHPRESS$gym_bp_getoff",
    "BENCHPRESS$gym_bp_geton",
    "BENCHPRESS$gym_bp_up_A",
    "BENCHPRESS$gym_bp_up_B",
    "BENCHPRESS$gym_bp_up_smooth",
    "BF_INJECTION$BF_getin_LHS",
    "BF_INJECTION$BF_getin_RHS",
    "BF_INJECTION$BF_getout_LHS",
    "BF_INJECTION$BF_getout_RHS",
    "BIKED$BIKEd_Back",
    "BIKED$BIKEd_drivebyFT",
    "BIKED$BIKEd_drivebyLHS",
    "BIKED$BIKEd_drivebyRHS",
    "BIKED$BIKEd_Fwd",
    "BIKED$BIKEd_getoffBACK",
    "BIKED$BIKEd_getoffLHS",
    "BIKED$BIKEd_getoffRHS",
    "BIKED$BIKEd_hit",
    "BIKED$BIKEd_jumponL",
    "BIKED$BIKEd_jumponR",
    "BIKED$BIKEd_kick",
    "BIKED$BIKEd_Left",
    "BIKED$BIKEd_passenger",
    "BIKED$BIKEd_pushes",
    "POOL$POOL_Walk_Start",
    "POOL$POOL_XLong_Shot",
    "POOL$POOL_XLong_Shot_O",
    "POOL$POOL_XLong_Start",
    "POOL$POOL_XLong_Start_O",
    "POOR$WINWASH_Start",
    "POOR$WINWASH_Wash2Beg",
    "PYTHON$python_crouchfire",
    "PYTHON$python_crouchreload",
    "PYTHON$python_fire",
    "PYTHON$python_fire_poor",
    "PYTHON$python_reload",
    "QUAD$QUAD_back",
    "QUAD$QUAD_driveby_FT",
    "QUAD$QUAD_driveby_LHS",
    "QUAD$QUAD_driveby_RHS",
    "QUAD$QUAD_FWD",
    "QUAD$QUAD_getoff_B",
    "QUAD$QUAD_getoff_LHS",
    "QUAD$QUAD_getoff_RHS",
    "QUAD$QUAD_geton_LHS",
    "QUAD$QUAD_geton_RHS",
    "QUAD$QUAD_hit",
    "QUAD$QUAD_kick",
    "QUAD$QUAD_Left",
    "QUAD$QUAD_passenger",
    "QUAD$QUAD_reverse",
    "QUAD$QUAD_ride",
    "QUAD$QUAD_Right",
    "QUAD_DBZ$Pass_Driveby_BWD",
    "QUAD_DBZ$Pass_Driveby_FWD",
    "QUAD_DBZ$Pass_Driveby_LHS",
    "QUAD_DBZ$Pass_Driveby_RHS",
    "RAPPING$Laugh_01",
    "RAPPING$RAP_A_IN",
    "RAPPING$RAP_A_Loop",
    "RAPPING$RAP_A_OUT",
    "RAPPING$RAP_B_IN",
    "RAPPING$RAP_B_Loop",
    "RAPPING$RAP_B_OUT",
    "RAPPING$RAP_C_Loop",
    "RIFLE$RIFLE_crouchfire",
    "RIFLE$RIFLE_crouchload",
    "RIFLE$RIFLE_fire",
    "RIFLE$RIFLE_fire_poor",
    "RIFLE$RIFLE_load",
    "RIOT$RIOT_ANGRY",
    "RIOT$RIOT_ANGRY_B",
    "RIOT$RIOT_challenge",
    "RIOT$RIOT_CHANT",
    "RIOT$RIOT_FUKU",
    "RIOT$RIOT_PUNCHES",
    "RIOT$RIOT_shout",
    "ROB_BANK$CAT_Safe_End",
    "ROB_BANK$CAT_Safe_Open",
    "ROB_BANK$CAT_Safe_Open_O",
    "ROB_BANK$CAT_Safe_Rob",
    "ROB_BANK$SHP_HandsUp_Scr",
    "ROCKET$idle_rocket",
    "ROCKET$RocketFire",
    "ROCKET$run_rocket",
    "ROCKET$walk_rocket",
    "ROCKET$WALK_start_rocket",
    "RUSTLER$Plane_align_LHS",
    "RUSTLER$Plane_close",
    "RUSTLER$Plane_getin",
    "RUSTLER$Plane_getout",
    "RUSTLER$Plane_open",
    "RYDER$RYD_Beckon_01",
    "RYDER$RYD_Beckon_02",
    "RYDER$RYD_Beckon_03",
    "RYDER$RYD_Die_PT1",
    "RYDER$RYD_Die_PT2",
    "RYDER$Van_Crate_L",
    "RYDER$Van_Crate_R",
    "RYDER$Van_Fall_L",
    "RYDER$Van_Fall_R",
    "RYDER$Van_Lean_L",
    "RYDER$Van_Lean_R",
    "RYDER$VAN_PickUp_E",
    "RYDER$VAN_PickUp_S",
    "RYDER$Van_Stand",
    "RYDER$Van_Stand_Crate",
    "RYDER$Van_Throw",
    "SCRATCHING$scdldlp",
    "SCRATCHING$scdlulp",
    "SCRATCHING$scdrdlp",
    "SCRATCHING$scdrulp",
    "SCRATCHING$sclng_l",
    "SCRATCHING$sclng_r",
    "SCRATCHING$scmid_l",
    "SCRATCHING$scmid_r",
    "SCRATCHING$scshrtl",
    "SCRATCHING$scshrtr",
    "SCRATCHING$sc_ltor",
    "SCRATCHING$sc_rtol",
    "SHAMAL$SHAMAL_align",
    "SHAMAL$SHAMAL_getin_LHS",
    "SHAMAL$SHAMAL_getout_LHS",
    "SHAMAL$SHAMAL_open",
    "SHOP$ROB_2Idle",
    "SHOP$ROB_Loop",
    "SHOP$ROB_Loop_Threat",
    "SHOP$ROB_Shifty",
    "SHOP$ROB_StickUp_In",
    "SHOP$SHP_Duck",
    "SHOP$SHP_Duck_Aim",
    "SHOP$SHP_Duck_Fire",
    "SHOP$SHP_Gun_Aim",
    "SHOP$SHP_Gun_Duck",
    "SHOP$SHP_Gun_Fire",
    "SHOP$SHP_Gun_Grab",
    "SHOP$SHP_Gun_Threat",
    "SHOP$SHP_HandsUp_Scr",
    "SHOP$SHP_Jump_Glide",
    "SHOP$SHP_Jump_Land",
    "SHOP$SHP_Jump_Launch",
    "SHOP$SHP_Rob_GiveCash",
    "SHOP$SHP_Rob_HandsUp",
    "SHOP$SHP_Rob_React",
    "SHOP$SHP_Serve_End",
    "SHOP$SHP_Serve_Idle",
    "SHOP$SHP_Serve_Loop",
    "SHOP$SHP_Serve_Start",
    "SHOP$Smoke_RYD",
    "SHOTGUN$shotgun_crouchfire",
    "SHOTGUN$shotgun_fire",
    "SHOTGUN$shotgun_fire_poor",
    "SILENCED$CrouchReload",
    "SILENCED$SilenceCrouchfire",
    "SILENCED$Silence_fire",
    "SILENCED$Silence_reload",
    "SKATE$skate_idle",
    "SKATE$skate_run",
    "SKATE$skate_sprint",
    "SMOKING$F_smklean_loop",
    "SMOKING$M_smklean_loop",
    "SMOKING$M_smkstnd_loop",
    "SMOKING$M_smk_drag",
    "SMOKING$M_smk_in",
    "SMOKING$M_smk_loop",
    "SMOKING$M_smk_out",
    "SMOKING$M_smk_tap",
    "SNIPER$WEAPON_sniper",
    "SPRAYCAN$spraycan_fire",
    "SPRAYCAN$spraycan_full",
    "STRIP$PLY_CASH",
    "STRIP$PUN_CASH",
    "WEAPONS$SHP_2H_Lift",
    "WEAPONS$SHP_2H_Lift_End",
    "WEAPONS$SHP_2H_Ret",
    "WEAPONS$SHP_2H_Ret_S",
    "WEAPONS$SHP_Ar_Lift",
    "WEAPONS$SHP_Ar_Lift_End",
    "WEAPONS$SHP_Ar_Ret",
    "WEAPONS$SHP_Ar_Ret_S",
    "WEAPONS$SHP_G_Lift_In",
    "WEAPONS$SHP_G_Lift_Out",
    "WEAPONS$SHP_Tray_In",
    "WEAPONS$SHP_Tray_Out",
    "WEAPONS$SHP_Tray_Pose",
    "WUZI$CS_Dead_Guy",
    "WUZI$CS_Plyr_pt1",
    "WUZI$CS_Plyr_pt2",
    "WUZI$CS_Wuzi_pt1",
    "WUZI$CS_Wuzi_pt2",
    "WUZI$Walkstart_Idle_01",
    "WUZI$Wuzi_follow",
    "WUZI$Wuzi_Greet_Plyr",
    "WUZI$Wuzi_Greet_Wuzi",
    "WUZI$Wuzi_grnd_chk",
    "WUZI$Wuzi_stand_loop",
    "WUZI$Wuzi_Walk",
}

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    
    ApplyStyle()
 
    sampRegisterChatCommand('test', function()
        tmain.window.v = not tmain.window.v
    end)
 
    imgui.Process = false
    tmain.window.v = false
 
    while true do  wait(0)
        imgui.Process = tmain.window.v
    end
end

function imgui.OnDrawFrame()
    if  tmain.window.v then

        imgui.SetNextWindowSize(imgui.ImVec2(350, 600),  imgui.Cond.FirstUseEver)

        imgui.Begin(string.format( '%s v%s by Grinch_',script.this.name,script.this.version),tmain.window,imgui.WindowFlags.NoCollapse)
        
        CreateButtons({"List","Search","Custom"},{List,Search,Custom})

        imgui.End()
    end
end

function List()
    imgui.Spacing()
    local menu_name = ""
    if imgui.BeginChild("") then
        for key,value in ipairs(animations) do
            local temp,_ = value:match("([^$]+)$([^$]+)")
            if menu_name ~= temp then
                menu_name = temp

                if imgui.CollapsingHeader(menu_name) then
                    imgui.Spacing()
                    for key,value in pairs(animations) do
                        local file,animation = value:match("([^$]+)$([^$]+)")
                        if menu_name == file then
                            AnimationEntry(file,animation)
                        end
                    end
                    imgui.Spacing()
                    imgui.Separator()
                    imgui.Spacing()
                end
            end
        end
        imgui.EndChild()
    end

end

function Search()
    imgui.Dummy(imgui.ImVec2(0,10))

    imgui.PushItemWidth(imgui.GetWindowWidth()-100)
    imgui.InputText("Search ",tmain.search_text)
    imgui.PopItemWidth()

    imgui.Spacing()
    imgui.Text("Found entries :(" .. tmain.search_text.v .. ")")
    imgui.Separator()
    imgui.Spacing()
    if imgui.BeginChild("") then
        for key,value in pairs(animations) do
            file, animation = value:match("([^$]+)$([^$]+)")
            if (string.upper(animation):find(string.upper(tmain.search_text.v))) then
                AnimationEntry(file,animation)
            end
        end       
        imgui.Spacing()
        imgui.EndChild()
    end
end

function Custom()

    imgui.Dummy(imgui.ImVec2(0,10))
    
    imgui.InputText("IFP name",tmain.ifp_name)
    imgui.InputText("Animation name",tmain.animation_name)
    imgui.Spacing()
    if imgui.Button("Play animation",imgui.ImVec2(imgui.GetWindowWidth()-20,25)) then
        PlayAnimation(tmain.ifp_name.v,tmain.animation_name.v)
    end
end


function AnimationEntry(file,animation)
    if imgui.MenuItem(animation) then
        if file ~= "PED" then
            requestAnimation(file)
            loadAllModelsNow()
        end
        PlayAnimation(file,animation)
    end
end

function PlayAnimation(file,animation)
    if tmain.secondary.v == true then
        taskPlayAnimSecondary(PLAYER_PED,animation,file,4.0,tmain.loop.v,0,0,0,-1)
    else
        taskPlayAnim(PLAYER_PED,animation,file,4.0,tmain.loop.v,0,0,0,-1)
    end
    printHelpString("Playing animation")
    if file ~= "ped" then
        removeAnimation(animation)
    end
end

function CreateButtons(names,func)

    local X = imgui.GetWindowWidth()/3 - 7*imgui.StyleVar.WindowPadding
    for i=1,3,1 do
        
        if i == tmain.current_btn then
            imgui.GetStyle().Colors[imgui.Col.Button] = imgui.ImVec4(0.06,  0.53,  0.98,  1.00)
        end

        if imgui.Button(names[i],imgui.ImVec2(X,25)) then
            tmain.current_btn = i
        end

        imgui.GetStyle().Colors[imgui.Col.Button] = imgui.ImVec4(0.26,  0.59,  0.98,  0.40)

        if i%3 ~= 0 then
            imgui.SameLine(0.0,0.0)
        end

    end
    imgui.NewLine()

    imgui.Spacing()
    imgui.Columns(2,nil,false)
    imgui.Checkbox("Loop", tmain.loop)
    imgui.NextColumn()
    imgui.Checkbox("Secondary", tmain.secondary)
    imgui.Columns(1)
    imgui.Spacing()
    if imgui.Button("Stop animation",imgui.ImVec2(imgui.GetWindowWidth()-20,25)) then
        clearCharTasks(PLAYER_PED)
        printHelpString("Animation stopped")
    end
    imgui.Spacing()
    imgui.Separator()
    func[tmain.current_btn]()

end


function ApplyStyle()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4

    style.WindowRounding = 2.0
    style.WindowTitleAlign = imgui.ImVec2(0.5,  0.84)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 0.0
    style.ItemSpacing = imgui.ImVec2(3.0,  3.0)
    style.ScrollbarSize = 12.0
    style.ScrollbarRounding = 2.0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0
    style.WindowPadding = imgui.ImVec2(10.0,  10.0)
    colors[clr.Text]                   = ImVec4(1.00,  1.00,  1.00,  1.00)
    colors[clr.TextDisabled]           = ImVec4(0.50,  0.50,  0.50,  1.00)
    colors[clr.WindowBg]               = ImVec4(0.06,  0.06,  0.06,  0.94)
    colors[clr.ChildWindowBg]          = ImVec4(1.00,  1.00,  1.00,  0.00)
    colors[clr.PopupBg]                = ImVec4(0.08,  0.08,  0.08,  0.94)
    colors[clr.ComboBg]                = colors[clr.PopupBg]
    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.16,  0.29,  0.48,  0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.26,  0.59,  0.98,  0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.26,  0.59,  0.98,  0.67)
    colors[clr.TitleBg]                = ImVec4(0.04,  0.04,  0.04,  1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.16,  0.29,  0.48,  1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00,  0.00,  0.00,  0.51)
    colors[clr.MenuBarBg]              = ImVec4(0.14,  0.14,  0.14,  1.00)
    colors[clr.ScrollbarBg]            = ImVec4(0.02,  0.02,  0.02,  0.53)
    colors[clr.ScrollbarGrab]          = ImVec4(0.31,  0.31,  0.31,  1.00)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.41,  0.41,  0.41,  1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.51,  0.51,  0.51,  1.00)
    colors[clr.CheckMark]              = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.SliderGrab]             = ImVec4(0.24,  0.52,  0.88,  1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.Button]                 = ImVec4(0.26,  0.59,  0.98,  0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.26,  0.59,  0.98,  1.00)
    colors[clr.ButtonActive]           = ImVec4(0.06,  0.53,  0.98,  1.00)
    colors[clr.Header]                 = ImVec4(0.26,  0.59,  0.98,  0.00)
    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.Separator]              = colors[clr.Border]
    colors[clr.SeparatorHovered]       = ImVec4(0.26,  0.59,  0.98,  0.78)
    colors[clr.SeparatorActive]        = 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.26,  0.59,  0.98,  0.95)
    colors[clr.CloseButton]            = ImVec4(0.41,  0.41,  0.41,  0.50)
    colors[clr.CloseButtonHovered]     = ImVec4(0.98,  0.39,  0.36,  1.00)
    colors[clr.CloseButtonActive]      = ImVec4(0.98,  0.39,  0.36,  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.26,  0.59,  0.98,  0.35)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.80,  0.80,  0.80,  0.35)
end
 
  • Нравится
Реакции: Sirccet