Skip to content

Hook Control

If you took a look at main.lua, you have the option of enabling/disabling hooks. When a hook is disabled, fantasy.moonlight will not monitor it.

This can be useful for security and frame optimization. If you do not need a hook, don't use it. All hooks are disabled by default except:

  • hook_create_move
  • hook_draw_model
  • hook_lock_cursor
  • hook_frame_stage_notify

Disabling any of these 4 hooks will create unwanted issues with fantasy.moonlight.

Certain scripts require you to have a hook enabled to use it. This is for security reasons. In the FOV Changer I made, you can see that certain features are disabled due to hooks being disabled.

        FOV Changer
        OnOverrideView is called in the CS:GO menu.
        Making changes to the FOV while in the main menu will not do anything.

local fov_changer = {
    name = "settings_fov_changer",
    viewmodel = "settings_fov_changer_viewmodel",

    -- FOV Changers won't work if the player is scoped.
    m_bIsScoped = 0

function fov_changer.PostInitialize()

    -- "hook_override_view" is disabled. No point of running the script.
    if moonlight.vars.get( "hook_override_view" ) == 0 then return end

    -- Create FantasyVar
    moonlight.vars.add(, 90 )

    -- Add FOV Slider to menu.
    moonlight.imgui.add( "FOV",, "slider", 90, 180 )

    -- Scope Netvar
    fov_changer.m_bIsScoped = moonlight.memory.netvar( "DT_CSPlayer->m_bIsScoped" )

    -- Viewmodel Changer
    if moonlight.vars.get( "hook_get_view_model_fov" ) == 1 then

        -- Create FantasyVar
        moonlight.vars.add( fov_changer.viewmodel, 68 )
        -- Add Viewmodel Slider to menu.
        moonlight.imgui.add( "ViewModel FOV", fov_changer.viewmodel, "slider", 0, 120 )


function fov_changer.OnOverrideView( fov )
    -- Get our FantasyVar
    local new_fov = moonlight.vars.get( )

    -- OnOverrideView is called before PostInitialize.
    if new_fov ~= nil then

        -- Get localplayer
        local player = )

        -- Do not apply FOV changer if scoped.
        if moonlight.memory.get_boolean( player["address"] + fov_changer.m_bIsScoped ) == false then
            fov = new_fov


    -- Return OnOverrideView so Moonlight can make changes.
    return fov

function fov_changer.OnGetViewModelFOV()
    -- Get our FantasyVar
    local new_viewmodel_fov = moonlight.vars.get( fov_changer.viewmodel )

    -- OnGetViewModelFOV is called before PostInitialize.
    if new_viewmodel_fov ~= nil then
        return new_viewmodel_fov

return fov_changer